NonVisual.cpp 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "NonVisual.h"
  5. #include <Common.h>
  6. #include <ScpMain.h>
  7. #include <TextsWin.h>
  8. #include <Tools.h>
  9. #include <Setup.h>
  10. #include <Log.h>
  11. #include <Interface.h>
  12. #include "WinConfiguration.h"
  13. #include "TerminalManager.h"
  14. #include "TBX.hpp"
  15. //---------------------------------------------------------------------------
  16. #pragma package(smart_init)
  17. #pragma link "TB2Item"
  18. #pragma link "TBX"
  19. #pragma resource "*.dfm"
  20. TNonVisualDataModule *NonVisualDataModule;
  21. //---------------------------------------------------------------------------
  22. #define SCPCOMMANDER ((TScpCommanderForm *)ScpExplorer)
  23. #define UPDEX(HandleAction, Condition, OtherEnabled, OtherDisabled) if (Action == HandleAction) { \
  24. ((TCustomAction *)Action)->Enabled = (Condition); \
  25. if (((TCustomAction *)Action)->Enabled) { OtherEnabled; } else { OtherDisabled; }; \
  26. Handled = true; } else
  27. #define UPD(HandleAction, Condition) if (Action == HandleAction) { \
  28. ((TCustomAction *)Action)->Enabled = (Condition); Handled = true; } else
  29. #define EXE(HandleAction, Command) if (Action == HandleAction) { \
  30. Command; Handled = true; } else
  31. #define UPDACT(HandleAction, Command) \
  32. EXE(HandleAction, ((TCustomAction *)Action)->Enabled = true; Command)
  33. #define UPDCOMP(COMP) if (Action == COMP ## Action) { COMP ## Action->Enabled = true; \
  34. COMP ## Action->Checked = ScpExplorer->ComponentVisible[fc ## COMP]; Handled = true; } else
  35. #define EXECOMP(COMP) EXE(COMP ## Action, \
  36. ScpExplorer->ComponentVisible[fc ## COMP] = !ScpExplorer->ComponentVisible[fc ## COMP] )
  37. #define COLPROPS(SIDE) \
  38. ((TCustomDirViewColProperties*)ScpExplorer->DirView(os ## SIDE)->ColProperties)
  39. #define UPDSORT(SIDE, PREFIX, COL) if (Action == SIDE ## SortBy ## COL ## Action) { \
  40. SIDE ## SortBy ## COL ## Action->Enabled = true; Handled = true; \
  41. SIDE ## SortBy ## COL ## Action->Checked = (COLPROPS(SIDE)->SortColumn == PREFIX ## COL); } else
  42. #define EXESORT(SIDE, PREFIX, COL) EXE(SIDE ## SortBy ## COL ## Action, \
  43. if (COLPROPS(SIDE)->SortColumn == PREFIX ## COL) \
  44. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; \
  45. else COLPROPS(SIDE)->SortColumn = PREFIX ## COL )
  46. #define UPDSORTA(SIDE) if (Action == SIDE ## SortAscendingAction) { \
  47. SIDE ## SortAscendingAction->Enabled = true; Handled = true; \
  48. SIDE ## SortAscendingAction->Checked = COLPROPS(SIDE)->SortAscending; } else
  49. #define EXESORTA(SIDE) EXE(SIDE ## SortAscendingAction, \
  50. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; )
  51. #define UPDSORTC(LPREFIX, LCOL, RPREFIX, RCOL) if (Action == CurrentSortBy ## RCOL ## Action) { \
  52. CurrentSortBy ## RCOL ## Action->Enabled = ScpExplorer->AllowedAction((TAction *)Action, aaShortCut); \
  53. if (CurrentSortBy ## RCOL ## Action->Enabled) { \
  54. if (ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) \
  55. CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == RPREFIX ## RCOL); \
  56. else CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == LPREFIX ## LCOL); \
  57. } else CurrentSortBy ## RCOL ## Action->Checked = false; Handled = true; } else
  58. #define EXESORTC(COL, LCOL, RCOL) \
  59. EXE(CurrentSortBy ## COL ## Action, \
  60. Integer NewSortCol = \
  61. ((ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) ? RCOL : LCOL); \
  62. if (COLPROPS(Current)->SortColumn == NewSortCol) \
  63. COLPROPS(Current)->SortAscending = !COLPROPS(Current)->SortAscending; \
  64. else COLPROPS(Current)->SortColumn = NewSortCol \
  65. )
  66. #define UPDSHCOL(SIDE, PREFIX, COL) \
  67. EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
  68. ShowHide ## SIDE ## COL ## ColumnAction->Checked = COLPROPS(SIDE)->Visible[PREFIX ## COL])
  69. #define EXESHCOL(SIDE, PREFIX, COL) \
  70. EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
  71. COLPROPS(SIDE)->Visible[PREFIX ## COL] = !COLPROPS(SIDE)->Visible[PREFIX ## COL])
  72. //---------------------------------------------------------------------------
  73. __fastcall TNonVisualDataModule::TNonVisualDataModule(TComponent* Owner)
  74. : TDataModule(Owner)
  75. {
  76. FListColumn = NULL;
  77. FSessionIdleTimerExecuting = false;
  78. FIdle = 0;
  79. }
  80. //---------------------------------------------------------------------------
  81. __fastcall TNonVisualDataModule::~TNonVisualDataModule()
  82. {
  83. }
  84. //---------------------------------------------------------------------------
  85. void __fastcall TNonVisualDataModule::LogActionsUpdate(
  86. TBasicAction *Action, bool &Handled)
  87. {
  88. TLogMemo * LogMemo = TTerminalManager::Instance()->LogMemo;
  89. bool ValidLogMemo = LogMemo && LogMemo->Parent;
  90. UPD(LogClearAction, ValidLogMemo && LogMemo->Lines->Count)
  91. // removed potentially CPU intensive check for "all selected already"
  92. UPD(LogSelectAllAction, ValidLogMemo && LogMemo->Lines->Count)
  93. UPD(LogCopyAction, ValidLogMemo && LogMemo->SelLength)
  94. UPD(LogCloseAction, Configuration->Logging && (WinConfiguration->LogView == lvWindow))
  95. UPD(LogPreferencesAction, true)
  96. ;
  97. }
  98. //---------------------------------------------------------------------------
  99. void __fastcall TNonVisualDataModule::LogActionsExecute(
  100. TBasicAction *Action, bool &Handled)
  101. {
  102. FIdle--;
  103. try
  104. {
  105. TLogMemo * LogMemo = TTerminalManager::Instance()->LogMemo;
  106. assert(LogMemo && LogMemo->Parent);
  107. EXE(LogClearAction, LogMemo->SessionLog->Clear())
  108. EXE(LogSelectAllAction, LogMemo->SelectAll())
  109. EXE(LogCopyAction, LogMemo->CopyToClipboard())
  110. EXE(LogCloseAction, WinConfiguration->LogView = lvNone)
  111. EXE(LogPreferencesAction, PreferencesDialog(pmLogging));
  112. ;
  113. }
  114. __finally
  115. {
  116. assert(FIdle < 0);
  117. FIdle++;
  118. }
  119. DoIdle();
  120. }
  121. //---------------------------------------------------------------------------
  122. void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
  123. TBasicAction *Action, bool &Handled)
  124. {
  125. if (!ScpExplorer || !ScpExplorer->AllowedAction((TAction *)Action, aaUpdate))
  126. {
  127. ((TAction *)Action)->Enabled = false;
  128. Handled = true;
  129. return;
  130. }
  131. // CURRENT DIRVIEW
  132. bool EnableSelectedOperation = ScpExplorer->EnableSelectedOperation[osCurrent];
  133. bool EnableFocusedOperation = ScpExplorer->EnableFocusedOperation[osCurrent];
  134. bool EnableSelectedFileOperation = ScpExplorer->EnableSelectedFileOperation[osCurrent];
  135. bool EnableFocusedFileOperation = ScpExplorer->EnableFocusedFileOperation[osCurrent];
  136. // focused operation
  137. UPD(CurrentCopyFocusedAction, EnableFocusedOperation)
  138. UPD(CurrentMoveFocusedAction, EnableFocusedOperation)
  139. UPD(CurrentDeleteFocusedAction, EnableFocusedOperation)
  140. UPD(CurrentPropertiesFocusedAction, EnableFocusedOperation)
  141. UPD(RemoteMoveToFocusedAction, EnableFocusedOperation &&
  142. (DirView(osRemote) == DirView(osCurrent)) &&
  143. ScpExplorer->Terminal->IsCapable[fcRemoteMove])
  144. UPD(RemoteCopyToFocusedAction, EnableFocusedOperation && (DirView(osRemote) == DirView(osCurrent)))
  145. UPD(CurrentEditFocusedAction, EnableFocusedFileOperation &&
  146. !WinConfiguration->DisableOpenEdit)
  147. // file operation
  148. UPD(CurrentRenameAction, EnableFocusedOperation &&
  149. ((ScpExplorer->HasDirView[osLocal] && DirView(osLocal) == DirView(osCurrent)) ||
  150. ScpExplorer->Terminal->IsCapable[fcRename]))
  151. UPD(CurrentEditAction, EnableSelectedFileOperation &&
  152. !WinConfiguration->DisableOpenEdit)
  153. UPD(CurrentEditAlternativeAction, EnableSelectedFileOperation &&
  154. !WinConfiguration->DisableOpenEdit)
  155. UPD(CurrentOpenAction, EnableFocusedOperation &&
  156. !WinConfiguration->DisableOpenEdit &&
  157. !DirView(osCurrent)->ItemIsDirectory(DirView(osCurrent)->ItemFocused))
  158. UPD(AddEditLinkAction, ScpExplorer->Terminal &&
  159. (DirView(osCurrent) != DirView(osRemote) ||
  160. (ScpExplorer->Terminal->ResolvingSymlinks &&
  161. ScpExplorer->Terminal->IsCapable[fcSymbolicLink])))
  162. UPD(NewLinkAction, ScpExplorer->Terminal &&
  163. (DirView(osCurrent) != DirView(osRemote) ||
  164. (ScpExplorer->Terminal->ResolvingSymlinks &&
  165. ScpExplorer->Terminal->IsCapable[fcSymbolicLink])))
  166. // selected operaton
  167. UPD(CurrentCopyAction, EnableSelectedOperation)
  168. UPD(RemoteCopyAction, ScpExplorer->EnableSelectedOperation[osRemote])
  169. UPD(LocalCopyAction, ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableSelectedOperation[osLocal])
  170. UPD(CurrentMoveAction, EnableSelectedOperation)
  171. UPD(CurrentDeleteAction, EnableSelectedOperation)
  172. UPD(CurrentPropertiesAction, EnableSelectedOperation)
  173. UPD(RemoteMoveToAction, EnableSelectedOperation &&
  174. (DirView(osRemote) == DirView(osCurrent)) &&
  175. ScpExplorer->Terminal->IsCapable[fcRemoteMove])
  176. UPD(RemoteCopyToAction, EnableSelectedOperation && (DirView(osRemote) == DirView(osCurrent)))
  177. UPD(FileListToCommandLineAction, EnableSelectedOperation)
  178. UPD(FileListToClipboardAction, EnableSelectedOperation)
  179. UPD(FullFileListToClipboardAction, EnableSelectedOperation)
  180. UPD(UrlToClipboardAction, EnableSelectedOperation && (DirView(osRemote) == DirView(osCurrent)))
  181. UPD(FileListFromClipboardAction, IsFormatInClipboard(CF_TEXT));
  182. // directory
  183. UPD(CurrentCreateDirAction, true)
  184. UPD(NewDirAction, true)
  185. // selection
  186. UPD(SelectOneAction, DirView(osCurrent)->FilesCount)
  187. UPD(SelectAction, DirView(osCurrent)->FilesCount)
  188. UPD(UnselectAction, DirView(osCurrent)->SelCount)
  189. UPD(SelectAllAction, DirView(osCurrent)->FilesCount)
  190. UPD(InvertSelectionAction, DirView(osCurrent)->FilesCount)
  191. UPD(ClearSelectionAction, DirView(osCurrent)->SelCount)
  192. UPD(RestoreSelectionAction, DirView(osCurrent)->SelectedNamesSaved)
  193. UPD(PasteAction, ScpExplorer->CanPasteFromClipBoard())
  194. //style
  195. UPDACT(CurrentCycleStyleAction,
  196. CurrentCycleStyleAction->ImageIndex = 8 + (DirView(osCurrent)->ViewStyle + 1) % 4)
  197. #define STYLEACTION(Style) UPDACT(Current ## Style ## Action, \
  198. Current ## Style ## Action->Checked = (DirView(osCurrent)->ViewStyle == vs ## Style))
  199. STYLEACTION(Icon)
  200. STYLEACTION(SmallIcon)
  201. STYLEACTION(List)
  202. STYLEACTION(Report)
  203. #undef STYLEACTION
  204. // REMOTE+LOCAL
  205. // back/forward
  206. #define HISTORYACTION(SIDE, DIRECTION, HINTFMT, DELTA) \
  207. UPDEX(SIDE ## DIRECTION ## Action, (DirView(os ## SIDE)->DIRECTION ## Count > 0), \
  208. SIDE ## DIRECTION ## Action->Hint = FMTLOAD(HINTFMT, (DirView(os ## SIDE)->HistoryPath[DELTA])), \
  209. SIDE ## DIRECTION ## Action->Hint = "")
  210. HISTORYACTION(Local, Back, EXPLORER_BACK_HINT, -1)
  211. HISTORYACTION(Local, Forward, EXPLORER_FORWARD_HINT, 1)
  212. HISTORYACTION(Remote, Back, EXPLORER_BACK_HINT, -1)
  213. HISTORYACTION(Remote, Forward, EXPLORER_FORWARD_HINT, 1)
  214. #undef HISTORYACTION
  215. #define PANEL_ACTIONS(SIDE) \
  216. UPD(SIDE ## ParentDirAction, !DirView(os ## SIDE)->IsRoot) \
  217. UPD(SIDE ## RootDirAction, !DirView(os ## SIDE)->IsRoot) \
  218. UPD(SIDE ## HomeDirAction, true) \
  219. UPD(SIDE ## RefreshAction, DirView(os ## SIDE)->DirOK) \
  220. UPD(SIDE ## OpenDirAction, true) \
  221. UPD(SIDE ## ChangePathAction, true) \
  222. UPD(SIDE ## AddBookmarkAction, true) \
  223. UPD(SIDE ## PathToClipboardAction, true)
  224. PANEL_ACTIONS(Local)
  225. PANEL_ACTIONS(Remote)
  226. #undef PANEL_ACTIONS
  227. UPD(LocalExploreDirectoryAction, true)
  228. // HELP
  229. UPD(AboutAction, true)
  230. UPD(HomepageAction, true)
  231. UPD(HistoryPageAction, true)
  232. UPD(TableOfContentsAction, true)
  233. UPD(ForumPageAction, true)
  234. UPD(CheckForUpdatesAction, true)
  235. UPDACT(ShowUpdatesAction, ShowUpdatesUpdate())
  236. UPD(UpdatesPreferencesAction, true)
  237. UPD(DonatePageAction, true)
  238. UPD(DownloadPageAction, true)
  239. // VIEW
  240. UPDCOMP(StatusBar)
  241. UPDCOMP(ToolBar)
  242. UPDCOMP(LocalStatusBar)
  243. UPDCOMP(RemoteStatusBar)
  244. UPDCOMP(CommandLinePanel)
  245. UPDCOMP(RemoteTree)
  246. UPDCOMP(LocalTree)
  247. UPDCOMP(ExplorerMenuBand)
  248. UPDCOMP(ExplorerAddressBand)
  249. UPDCOMP(ExplorerToolbarBand)
  250. UPDCOMP(ExplorerSelectionBand)
  251. UPDCOMP(ExplorerSessionBand)
  252. UPDCOMP(ExplorerPreferencesBand)
  253. UPDCOMP(ExplorerSortBand)
  254. UPDCOMP(ExplorerUpdatesBand)
  255. UPDCOMP(ExplorerTransferBand)
  256. UPDCOMP(ExplorerCustomCommandsBand)
  257. UPDCOMP(CommanderMenuBand)
  258. UPDCOMP(CommanderSessionBand)
  259. UPDCOMP(CommanderPreferencesBand)
  260. UPDCOMP(CommanderSelectionBand)
  261. UPDCOMP(CommanderToolbarBand)
  262. UPDCOMP(CommanderSortBand)
  263. UPDCOMP(CommanderCommandsBand)
  264. UPDCOMP(CommanderUpdatesBand)
  265. UPDCOMP(CommanderTransferBand)
  266. UPDCOMP(CommanderUploadDownloadBand)
  267. UPDCOMP(CommanderCustomCommandsBand)
  268. UPDCOMP(CommanderLocalHistoryBand)
  269. UPDCOMP(CommanderLocalNavigationBand)
  270. UPDCOMP(CommanderRemoteHistoryBand)
  271. UPDCOMP(CommanderRemoteNavigationBand)
  272. UPD(GoToCommandLineAction, true)
  273. UPD(GoToTreeAction, true)
  274. UPDEX(ViewLogAction, Configuration->Logging,
  275. ViewLogAction->Checked = (WinConfiguration->LogView == lvWindow),
  276. ViewLogAction->Checked = false )
  277. UPDEX(ShowHiddenFilesAction, true,
  278. ShowHiddenFilesAction->Checked = WinConfiguration->ShowHiddenFiles, )
  279. UPDEX(AutoReadDirectoryAfterOpAction, true,
  280. AutoReadDirectoryAfterOpAction->Checked = Configuration->AutoReadDirectoryAfterOp, )
  281. UPD(PreferencesAction, true)
  282. UPD(PresetsPreferencesAction, true)
  283. UPDEX(LockToolbarsAction, true,
  284. LockToolbarsAction->Checked = WinConfiguration->LockToolbars, )
  285. UPDCOMP(CustomCommandsBand)
  286. UPD(ColorMenuAction, true)
  287. UPDACT(ColorDefaultAction,
  288. ColorDefaultAction->Checked = (ScpExplorer->SessionColor == 0));
  289. UPD(ColorPickAction, true);
  290. // SORT
  291. UPDSORTA(Local)
  292. UPDSORT(Local, dv, Name)
  293. UPDSORT(Local, dv, Ext)
  294. UPDSORT(Local, dv, Size)
  295. UPDSORT(Local, dv, Type)
  296. UPDSORT(Local, dv, Changed)
  297. UPDSORT(Local, dv, Attr)
  298. UPDSORTA(Remote)
  299. UPDSORT(Remote, uv, Name)
  300. UPDSORT(Remote, uv, Ext)
  301. UPDSORT(Remote, uv, Size)
  302. UPDSORT(Remote, uv, Changed)
  303. UPDSORT(Remote, uv, Rights)
  304. UPDSORT(Remote, uv, Owner)
  305. UPDSORT(Remote, uv, Group)
  306. UPDSORT(Remote, uv, Type)
  307. UPDSORTA(Current)
  308. UPDSORTC(dv, Name, uv, Name)
  309. UPDSORTC(dv, Ext, uv, Ext)
  310. UPDSORTC(dv, Size, uv, Size)
  311. UPDSORTC(dv, Type, uv, Type)
  312. UPDSORTC(dv, Changed, uv, Changed)
  313. UPDSORTC(dv, Attr, uv, Rights)
  314. UPDSORTC(dv, Name, uv, Owner)
  315. UPDSORTC(dv, Name, uv, Group)
  316. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  317. UPDEX(SortColumnAscendingAction, (ListColumn != NULL), SortColumnAscendingAction->Checked =
  318. (COLVIEWPROPS->SortColumn == ListColumn->Index) && COLVIEWPROPS->SortAscending, /*assert(false)*/ )
  319. UPDEX(SortColumnDescendingAction, (ListColumn != NULL), SortColumnDescendingAction->Checked =
  320. (COLVIEWPROPS->SortColumn == ListColumn->Index) && !COLVIEWPROPS->SortAscending, /*assert(false)*/ )
  321. #undef COLVIEWPROPS
  322. // SHOW/HIDE COLUMN
  323. UPDSHCOL(Local, dv, Name)
  324. UPDSHCOL(Local, dv, Ext)
  325. UPDSHCOL(Local, dv, Size)
  326. UPDSHCOL(Local, dv, Type)
  327. UPDSHCOL(Local, dv, Changed)
  328. UPDSHCOL(Local, dv, Attr)
  329. UPDSHCOL(Remote, uv, Name)
  330. UPDSHCOL(Remote, uv, Ext)
  331. UPDSHCOL(Remote, uv, Size)
  332. UPDSHCOL(Remote, uv, Changed)
  333. UPDSHCOL(Remote, uv, Rights)
  334. UPDSHCOL(Remote, uv, Owner)
  335. UPDSHCOL(Remote, uv, Group)
  336. UPDSHCOL(Remote, uv, LinkTarget)
  337. UPDSHCOL(Remote, uv, Type)
  338. UPD(HideColumnAction, (ListColumn != NULL))
  339. UPD(BestFitColumnAction, (ListColumn != NULL))
  340. // SESSION
  341. UPD(NewSessionAction, true)
  342. UPD(CloseSessionAction, true)
  343. UPD(SavedSessionsAction, (StoredSessions->Count > 0))
  344. UPD(OpenedSessionsAction, true)
  345. UPD(SaveCurrentSessionAction, true)
  346. // COMMAND
  347. UPD(CompareDirectoriesAction, true)
  348. UPD(SynchronizeAction, true)
  349. UPD(FullSynchronizeAction, true)
  350. UPD(ConsoleAction, true)
  351. UPD(PuttyAction, TTerminalManager::Instance()->CanOpenInPutty())
  352. UPD(SynchronizeBrowsingAction, true)
  353. UPD(CloseApplicationAction, true)
  354. UPD(FileSystemInfoAction, true)
  355. UPD(ClearCachesAction, (ScpExplorer->Terminal != NULL) && !ScpExplorer->Terminal->AreCachesEmpty)
  356. UPD(NewFileAction, !WinConfiguration->DisableOpenEdit)
  357. UPD(EditorListCustomizeAction, true)
  358. // CUSTOM COMMANDS
  359. UPD(CustomCommandsAction, true)
  360. UPD(CustomCommandsEnterAction, true)
  361. UPD(CustomCommandsCustomizeAction, true)
  362. // QUEUE
  363. #define UPDQUEUE(OPERATION) UPD(Queue ## OPERATION ## Action, \
  364. ScpExplorer->AllowQueueOperation(qo ## OPERATION))
  365. UPDQUEUE(GoTo)
  366. UPDQUEUE(Preferences)
  367. UPDEX(QueueItemQueryAction, ScpExplorer->AllowQueueOperation(qoItemQuery),
  368. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  369. UPDEX(QueueItemErrorAction, ScpExplorer->AllowQueueOperation(qoItemError),
  370. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  371. UPDEX(QueueItemPromptAction, ScpExplorer->AllowQueueOperation(qoItemPrompt),
  372. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  373. UPDQUEUE(ItemDelete)
  374. UPDEX(QueueItemExecuteAction, ScpExplorer->AllowQueueOperation(qoItemExecute),
  375. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible =
  376. !ScpExplorer->AllowQueueOperation(qoItemPause) &&
  377. !ScpExplorer->AllowQueueOperation(qoItemResume))
  378. UPDEX(QueueItemPauseAction, ScpExplorer->AllowQueueOperation(qoItemPause),
  379. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  380. UPDEX(QueueItemResumeAction, ScpExplorer->AllowQueueOperation(qoItemResume),
  381. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  382. UPDQUEUE(ItemUp)
  383. UPDQUEUE(ItemDown)
  384. UPDQUEUE(PauseAll)
  385. UPDQUEUE(ResumeAll)
  386. #undef UPDQUEUE
  387. UPDACT(QueueToggleShowAction,
  388. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueView])
  389. #define QUEUEACTION(SHOW) UPDACT(Queue ## SHOW ## Action, \
  390. ((TAction *)Action)->Checked = WinConfiguration->QueueView.Show == qv ## SHOW)
  391. QUEUEACTION(Show)
  392. QUEUEACTION(HideWhenEmpty)
  393. QUEUEACTION(Hide)
  394. #undef QUEUEACTION
  395. UPD(QueueDisconnectOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoDisconnectOnceEmpty))
  396. UPDCOMP(CommanderPreferencesBand)
  397. UPDACT(QueueToolbarAction,
  398. ((TAction *)Action)->Enabled = ScpExplorer->ComponentVisible[fcQueueView];
  399. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueToolbar]);
  400. ;
  401. }
  402. //---------------------------------------------------------------------------
  403. void __fastcall TNonVisualDataModule::ExplorerActionsExecute(
  404. TBasicAction *Action, bool &Handled)
  405. {
  406. assert(ScpExplorer);
  407. if (!ScpExplorer->AllowedAction((TAction *)Action, aaExecute))
  408. {
  409. Handled = true;
  410. return;
  411. }
  412. ScpExplorer->BeforeAction();
  413. FIdle--;
  414. try
  415. {
  416. // focused operation
  417. EXE(CurrentCopyFocusedAction, ScpExplorer->ExecuteFileOperation(foCopy, osCurrent, true))
  418. EXE(CurrentMoveFocusedAction, ScpExplorer->ExecuteFileOperation(foMove, osCurrent, true))
  419. EXE(CurrentDeleteFocusedAction, ScpExplorer->ExecuteFileOperation(foDelete, osCurrent, true))
  420. EXE(CurrentPropertiesFocusedAction, ScpExplorer->ExecuteFileOperation(foSetProperties, osCurrent, true))
  421. EXE(RemoteMoveToFocusedAction, ScpExplorer->ExecuteFileOperation(foRemoteMove, osCurrent, true))
  422. EXE(RemoteCopyToFocusedAction, ScpExplorer->ExecuteFileOperation(foRemoteCopy, osCurrent, true))
  423. EXE(CurrentEditFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, true))
  424. // operation
  425. EXE(CurrentCopyAction, ScpExplorer->ExecuteFileOperation(foCopy, osCurrent, false))
  426. EXE(RemoteCopyAction, ScpExplorer->ExecuteFileOperation(foCopy, osRemote, false))
  427. EXE(LocalCopyAction, ScpExplorer->ExecuteFileOperation(foCopy, osLocal, false))
  428. EXE(CurrentMoveAction, ScpExplorer->ExecuteFileOperation(foMove, osCurrent, false))
  429. EXE(CurrentEditAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, false))
  430. EXE(CurrentEditAlternativeAction, CreateEditorListMenu(CurrentEditAlternativeAction))
  431. EXE(CurrentOpenAction, ScpExplorer->ExecuteCurrentFile())
  432. EXE(AddEditLinkAction, ScpExplorer->AddEditLink(false))
  433. EXE(NewLinkAction, ScpExplorer->AddEditLink(true))
  434. EXE(CurrentRenameAction, ScpExplorer->ExecuteFileOperation(foRename, osCurrent, false))
  435. EXE(CurrentDeleteAction, ScpExplorer->ExecuteFileOperation(foDelete, osCurrent, false))
  436. EXE(CurrentPropertiesAction, ScpExplorer->ExecuteFileOperation(foSetProperties, osCurrent, false))
  437. EXE(RemoteMoveToAction, ScpExplorer->ExecuteFileOperation(foRemoteMove, osCurrent, false))
  438. EXE(RemoteCopyToAction, ScpExplorer->ExecuteFileOperation(foRemoteCopy, osCurrent, false))
  439. EXE(FileListToCommandLineAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedCommandLine))
  440. EXE(FileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedClipboard))
  441. EXE(FullFileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFullFileList, pedClipboard))
  442. EXE(UrlToClipboardAction, ScpExplorer->PanelExport(osCurrent, peUrl, pedClipboard))
  443. EXE(FileListFromClipboardAction, ScpExplorer->FileListFromClipboard())
  444. // directory
  445. EXE(CurrentCreateDirAction, ScpExplorer->CreateDirectory(osCurrent))
  446. EXE(NewDirAction, ScpExplorer->CreateDirectory(osCurrent))
  447. //selection
  448. EXE(SelectOneAction, DirView(osCurrent)->SelectCurrentItem(DirView(osCurrent)->NortonLike))
  449. EXE(SelectAction, DirView(osCurrent)->DoSelectByMask(true))
  450. EXE(UnselectAction, DirView(osCurrent)->DoSelectByMask(false))
  451. EXE(SelectAllAction, DirView(osCurrent)->SelectAll(smAll))
  452. EXE(InvertSelectionAction, DirView(osCurrent)->SelectAll(smInvert))
  453. EXE(ClearSelectionAction, DirView(osCurrent)->SelectAll(smNone))
  454. EXE(RestoreSelectionAction, DirView(osCurrent)->RestoreSelectedNames())
  455. EXE(PasteAction, ScpExplorer->PasteFromClipBoard())
  456. // style
  457. EXE(CurrentCycleStyleAction,
  458. if (DirView(osCurrent)->ViewStyle == vsReport) DirView(osCurrent)->ViewStyle = vsIcon;
  459. else DirView(osCurrent)->ViewStyle = (TViewStyle)(DirView(osCurrent)->ViewStyle + 1);
  460. )
  461. #define STYLEACTION(Style) EXE(Current ## Style ## Action, \
  462. DirView(osCurrent)->ViewStyle = vs ## Style)
  463. STYLEACTION(Icon)
  464. STYLEACTION(SmallIcon)
  465. STYLEACTION(List)
  466. STYLEACTION(Report)
  467. #undef STYLEACTION
  468. #define PANEL_ACTIONS(SIDE) \
  469. EXE(SIDE ## BackAction, DirView(os ## SIDE)->HistoryGo(-1)) \
  470. EXE(SIDE ## ForwardAction, DirView(os ## SIDE)->HistoryGo(1)) \
  471. EXE(SIDE ## ParentDirAction, DirView(os ## SIDE)->ExecuteParentDirectory()) \
  472. EXE(SIDE ## RootDirAction, DirView(os ## SIDE)->ExecuteRootDirectory()) \
  473. EXE(SIDE ## HomeDirAction, DirView(os ## SIDE)->ExecuteHomeDirectory()) \
  474. EXE(SIDE ## RefreshAction, DirView(os ## SIDE)->ReloadDirectory()) \
  475. EXE(SIDE ## OpenDirAction, ScpExplorer->OpenDirectory(os ## SIDE)) \
  476. EXE(SIDE ## ChangePathAction, ScpExplorer->ChangePath(os ## SIDE)) \
  477. EXE(SIDE ## AddBookmarkAction, ScpExplorer->AddBookmark(os ## SIDE)) \
  478. EXE(SIDE ## PathToClipboardAction, ScpExplorer->PanelExport(os ## SIDE, pePath, pedClipboard))
  479. PANEL_ACTIONS(Local)
  480. PANEL_ACTIONS(Remote)
  481. #undef PANEL_ACTIONS
  482. EXE(LocalExploreDirectoryAction, ScpExplorer->ExploreLocalDirectory())
  483. //HELP
  484. EXE(AboutAction, DoAboutDialog(Configuration))
  485. EXE(HomepageAction, OpenBrowser(LoadStr(HOMEPAGE_URL)))
  486. EXE(HistoryPageAction, OpenBrowser(LoadStr(HISTORY_URL)))
  487. EXE(TableOfContentsAction, Application->HelpSystem->ShowTableOfContents())
  488. EXE(ForumPageAction, OpenBrowser(LoadStr(FORUM_URL)))
  489. EXE(CheckForUpdatesAction, CheckForUpdates(false))
  490. EXE(ShowUpdatesAction, CheckForUpdates(true))
  491. EXE(UpdatesPreferencesAction, PreferencesDialog(pmUpdates))
  492. EXE(DonatePageAction, OpenBrowser(LoadStr(DONATE_URL)))
  493. EXE(DownloadPageAction, OpenBrowser(LoadStr(DOWNLOAD_URL)))
  494. // VIEW
  495. EXECOMP(StatusBar)
  496. EXECOMP(ToolBar)
  497. EXECOMP(LocalStatusBar)
  498. EXECOMP(RemoteStatusBar)
  499. EXECOMP(ExplorerMenuBand)
  500. EXECOMP(ExplorerAddressBand)
  501. EXECOMP(ExplorerToolbarBand)
  502. EXECOMP(ExplorerSelectionBand)
  503. EXECOMP(ExplorerSessionBand)
  504. EXECOMP(ExplorerPreferencesBand)
  505. EXECOMP(ExplorerSortBand)
  506. EXECOMP(ExplorerUpdatesBand)
  507. EXECOMP(ExplorerTransferBand)
  508. EXECOMP(ExplorerCustomCommandsBand)
  509. EXECOMP(CommanderMenuBand)
  510. EXECOMP(CommanderSessionBand)
  511. EXECOMP(CommanderPreferencesBand)
  512. EXECOMP(CommanderSelectionBand)
  513. EXECOMP(CommanderToolbarBand)
  514. EXECOMP(CommanderSortBand)
  515. EXECOMP(CommanderCommandsBand)
  516. EXECOMP(CommanderUpdatesBand)
  517. EXECOMP(CommanderTransferBand)
  518. EXECOMP(CommanderUploadDownloadBand)
  519. EXECOMP(CommanderCustomCommandsBand)
  520. EXECOMP(CommanderLocalHistoryBand)
  521. EXECOMP(CommanderLocalNavigationBand)
  522. EXECOMP(CommanderRemoteHistoryBand)
  523. EXECOMP(CommanderRemoteNavigationBand)
  524. EXECOMP(CommandLinePanel)
  525. EXECOMP(RemoteTree)
  526. EXECOMP(LocalTree)
  527. EXE(GoToCommandLineAction, ScpExplorer->GoToCommandLine())
  528. EXE(GoToTreeAction, ScpExplorer->GoToTree())
  529. EXE(ViewLogAction, WinConfiguration->LogView =
  530. (WinConfiguration->LogView == lvNone ? lvWindow : lvNone) )
  531. EXE(ShowHiddenFilesAction, ScpExplorer->ToggleShowHiddenFiles())
  532. EXE(AutoReadDirectoryAfterOpAction, ScpExplorer->ToggleAutoReadDirectoryAfterOp())
  533. EXE(PreferencesAction, PreferencesDialog(pmDefault) )
  534. EXE(PresetsPreferencesAction, PreferencesDialog(pmPresets) )
  535. EXE(LockToolbarsAction, WinConfiguration->LockToolbars = !WinConfiguration->LockToolbars)
  536. EXECOMP(CustomCommandsBand)
  537. EXE(ColorMenuAction, );
  538. EXE(ColorDefaultAction, ScpExplorer->SessionColor = (TColor)0);
  539. EXE(ColorPickAction, ScpExplorer->SessionColorPick());
  540. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  541. // SORT
  542. EXESORTA(Local)
  543. EXESORT(Local, dv, Name)
  544. EXESORT(Local, dv, Ext)
  545. EXESORT(Local, dv, Size)
  546. EXESORT(Local, dv, Type)
  547. EXESORT(Local, dv, Changed)
  548. EXESORT(Local, dv, Attr)
  549. EXESORTA(Remote)
  550. EXESORT(Remote, uv, Name)
  551. EXESORT(Remote, uv, Ext)
  552. EXESORT(Remote, uv, Size)
  553. EXESORT(Remote, uv, Changed)
  554. EXESORT(Remote, uv, Rights)
  555. EXESORT(Remote, uv, Owner)
  556. EXESORT(Remote, uv, Group)
  557. EXESORT(Remote, uv, Type)
  558. EXESORTA(Current)
  559. EXESORTC(Name, dvName, uvName)
  560. EXESORTC(Ext, dvExt, uvExt)
  561. EXESORTC(Size, dvSize, uvSize)
  562. EXESORTC(Type, dvType, uvType)
  563. EXESORTC(Changed, dvChanged, uvChanged)
  564. EXESORTC(Rights, dvAttr, uvRights)
  565. EXESORTC(Owner, dvName, uvOwner)
  566. EXESORTC(Group, dvName, uvGroup)
  567. EXE(SortColumnAscendingAction, assert(ListColumn);
  568. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = true; ListColumn = NULL )
  569. EXE(SortColumnDescendingAction, assert(ListColumn);
  570. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = false; ListColumn = NULL )
  571. // SHOW/HIDE COLUMN
  572. EXESHCOL(Local, dv, Name)
  573. EXESHCOL(Local, dv, Ext)
  574. EXESHCOL(Local, dv, Size)
  575. EXESHCOL(Local, dv, Type)
  576. EXESHCOL(Local, dv, Changed)
  577. EXESHCOL(Local, dv, Attr)
  578. EXESHCOL(Remote, uv, Name)
  579. EXESHCOL(Remote, uv, Ext)
  580. EXESHCOL(Remote, uv, Size)
  581. EXESHCOL(Remote, uv, Changed)
  582. EXESHCOL(Remote, uv, Rights)
  583. EXESHCOL(Remote, uv, Owner)
  584. EXESHCOL(Remote, uv, Group)
  585. EXESHCOL(Remote, uv, LinkTarget)
  586. EXESHCOL(Remote, uv, Type)
  587. EXE(HideColumnAction, assert(ListColumn);
  588. COLVIEWPROPS->Visible[ListColumn->Index] = false; ListColumn = NULL )
  589. EXE(BestFitColumnAction, assert(ListColumn); ListColumn = NULL ) // TODO
  590. #undef COLVIEWPROPS
  591. // SESSION
  592. EXE(NewSessionAction, ScpExplorer->NewSession())
  593. EXE(CloseSessionAction, ScpExplorer->CloseSession())
  594. EXE(SavedSessionsAction, CreateSessionListMenu(SavedSessionsAction))
  595. EXE(OpenedSessionsAction, CreateOpenedSessionListMenu(OpenedSessionsAction))
  596. EXE(SaveCurrentSessionAction, ScpExplorer->SaveCurrentSession())
  597. // COMMAND
  598. EXE(CompareDirectoriesAction, ScpExplorer->CompareDirectories())
  599. EXE(SynchronizeAction, ScpExplorer->SynchronizeDirectories())
  600. EXE(FullSynchronizeAction, ScpExplorer->FullSynchronizeDirectories())
  601. EXE(ConsoleAction, ScpExplorer->OpenConsole())
  602. EXE(PuttyAction, TTerminalManager::Instance()->OpenInPutty())
  603. EXE(SynchronizeBrowsingAction, ScpExplorer->SynchronizeBrowsingChanged())
  604. EXE(CloseApplicationAction, ScpExplorer->Close())
  605. EXE(FileSystemInfoAction, ScpExplorer->FileSystemInfo())
  606. EXE(ClearCachesAction, ScpExplorer->Terminal->ClearCaches())
  607. EXE(NewFileAction, ScpExplorer->EditNew(osCurrent))
  608. EXE(EditorListCustomizeAction, PreferencesDialog(pmEditor))
  609. // CUSTOM COMMANDS
  610. EXE(CustomCommandsAction, CreateCustomCommandsMenu(CustomCommandsAction))
  611. EXE(CustomCommandsEnterAction, ScpExplorer->AdHocCustomCommand(
  612. Action->ActionComponent == RemoteDirViewCustomCommandsMenu))
  613. EXE(CustomCommandsCustomizeAction, PreferencesDialog(pmCustomCommands))
  614. // QUEUE
  615. #define EXEQUEUE(OPERATION) EXE(Queue ## OPERATION ## Action, \
  616. ScpExplorer->ExecuteQueueOperation(qo ## OPERATION))
  617. EXEQUEUE(GoTo)
  618. EXEQUEUE(Preferences)
  619. EXEQUEUE(ItemQuery)
  620. EXEQUEUE(ItemError)
  621. EXEQUEUE(ItemPrompt)
  622. EXEQUEUE(ItemDelete)
  623. EXEQUEUE(ItemExecute)
  624. EXEQUEUE(ItemPause)
  625. EXEQUEUE(ItemResume)
  626. EXEQUEUE(ItemUp)
  627. EXEQUEUE(ItemDown)
  628. EXEQUEUE(PauseAll)
  629. EXEQUEUE(ResumeAll)
  630. #undef EXEQUEUE
  631. EXE(QueueToggleShowAction, ScpExplorer->ToggleQueueVisibility())
  632. #define QUEUEACTION(SHOW) EXE(Queue ## SHOW ## Action, \
  633. TQueueViewConfiguration Config = WinConfiguration->QueueView; \
  634. if (Config.Show != qvShow) Config.LastHideShow = Config.Show; \
  635. Config.Show = qv ## SHOW; \
  636. WinConfiguration->QueueView = Config)
  637. QUEUEACTION(Show)
  638. QUEUEACTION(HideWhenEmpty)
  639. QUEUEACTION(Hide)
  640. #undef QUEUEACTION
  641. EXE(QueueDisconnectOnceEmptyAction, )
  642. EXECOMP(QueueToolbar);
  643. ;
  644. }
  645. __finally
  646. {
  647. assert(FIdle < 0);
  648. FIdle++;
  649. }
  650. DoIdle();
  651. }
  652. //---------------------------------------------------------------------------
  653. void __fastcall TNonVisualDataModule::UpdateNonVisibleActions()
  654. {
  655. // following actions needs to be updated even when all clients
  656. // are invisible, so the queue list toolbar button can be shown
  657. NonVisualDataModule->QueueItemQueryAction->Update();
  658. NonVisualDataModule->QueueItemErrorAction->Update();
  659. NonVisualDataModule->QueueItemPromptAction->Update();
  660. }
  661. //---------------------------------------------------------------------------
  662. #define CTRL TShiftState() << ssCtrl
  663. #define ALT TShiftState() << ssAlt
  664. #define SHIFT TShiftState() << ssShift
  665. #define CTRLSHIFT TShiftState() << ssCtrl << ssShift
  666. #define CTRLALT TShiftState() << ssCtrl << ssAlt
  667. #define NONE TShiftState()
  668. void __fastcall TNonVisualDataModule::ExplorerShortcuts()
  669. {
  670. // Directory
  671. CurrentCreateDirAction->ShortCut = ShortCut('D', CTRL);
  672. NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
  673. // File operation
  674. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  675. CurrentEditAction->ShortCut = ShortCut('E', CTRL);
  676. AddEditLinkAction->ShortCut = ShortCut('L', CTRLALT);
  677. NewLinkAction->ShortCut = AddEditLinkAction->ShortCut;
  678. // Focused operation
  679. CurrentCopyFocusedAction->ShortCut = ShortCut('C', CTRL);
  680. CurrentMoveFocusedAction->ShortCut = ShortCut('M', CTRL);
  681. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_DELETE, NONE);
  682. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_RETURN, ALT);
  683. RemoteMoveToFocusedAction->ShortCut = ShortCut('M', CTRLALT);
  684. // remote directory
  685. RemoteOpenDirAction->ShortCut = ShortCut('O', CTRL);
  686. RemoteRefreshAction->ShortCut = ShortCut(VK_F5, NONE);
  687. RemoteHomeDirAction->ShortCut = ShortCut('H', CTRL);
  688. RemotePathToClipboardAction->ShortCut = ShortCut('P', CTRLSHIFT);
  689. // selected operation
  690. CurrentCopyAction->ShortCut = CurrentCopyFocusedAction->ShortCut;
  691. CurrentMoveAction->ShortCut = CurrentMoveFocusedAction->ShortCut;
  692. CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
  693. CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
  694. RemoteMoveToAction->ShortCut = ShortCut('M', CTRLALT);
  695. // selection
  696. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  697. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  698. SelectAllAction->ShortCut = ShortCut('A', CTRL);
  699. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  700. ClearSelectionAction->ShortCut = ShortCut('L', CTRL);
  701. RestoreSelectionAction->ShortCut = ShortCut('R', CTRLALT);
  702. // commands
  703. NewFileAction->ShortCut = ShortCut('E', CTRLSHIFT);
  704. CloseApplicationAction->ShortCut = ShortCut(VK_F4, ALT);
  705. }
  706. //---------------------------------------------------------------------------
  707. void __fastcall TNonVisualDataModule::CommanderShortcuts()
  708. {
  709. // Directory
  710. CurrentCreateDirAction->ShortCut = ShortCut(VK_F7, NONE);
  711. NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
  712. // File operation
  713. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  714. CurrentEditAction->ShortCut = ShortCut(VK_F4, NONE);
  715. AddEditLinkAction->ShortCut = ShortCut(VK_F6, ALT);
  716. NewLinkAction->ShortCut = AddEditLinkAction->ShortCut;
  717. // Focused operation
  718. CurrentCopyFocusedAction->ShortCut = ShortCut(VK_F5, NONE);
  719. CurrentMoveFocusedAction->ShortCut = ShortCut(VK_F6, NONE);
  720. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_F8, NONE);
  721. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_F9, NONE);
  722. RemoteMoveToFocusedAction->ShortCut = ShortCut(VK_F6, SHIFT);
  723. RemoteCopyToFocusedAction->ShortCut = ShortCut(VK_F5, SHIFT);
  724. // remote directory
  725. RemoteOpenDirAction->ShortCut = ShortCut('O', CTRL);
  726. RemoteRefreshAction->ShortCut = ShortCut('R', CTRL);
  727. RemoteHomeDirAction->ShortCut = ShortCut('H', CTRL);
  728. RemotePathToClipboardAction->ShortCut = ShortCut(VK_OEM_6 /* ] */, CTRL);
  729. // local directory
  730. LocalOpenDirAction->ShortCut = RemoteOpenDirAction->ShortCut;
  731. LocalRefreshAction->ShortCut = RemoteRefreshAction->ShortCut;
  732. LocalHomeDirAction->ShortCut = RemoteHomeDirAction->ShortCut;
  733. LocalPathToClipboardAction->ShortCut = ShortCut(VK_OEM_4 /* [ */, CTRL);
  734. // selected operation
  735. CurrentCopyAction->ShortCut = CurrentCopyFocusedAction->ShortCut;
  736. CurrentMoveAction->ShortCut = CurrentMoveFocusedAction->ShortCut;
  737. CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
  738. CurrentDeleteAction->SecondaryShortCuts->Clear();
  739. CurrentDeleteAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, NONE)));
  740. CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
  741. RemoteMoveToAction->ShortCut = ShortCut(VK_F6, SHIFT);
  742. RemoteCopyToAction->ShortCut = ShortCut(VK_F5, SHIFT);
  743. // selection
  744. SelectOneAction->ShortCut = VK_INSERT;
  745. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  746. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  747. SelectAllAction->ShortCut = ShortCut('A', CTRL);
  748. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  749. ClearSelectionAction->ShortCut = ShortCut('L', CTRL);
  750. RestoreSelectionAction->ShortCut = ShortCut('R', CTRLALT);
  751. // commands
  752. NewFileAction->ShortCut = ShortCut(VK_F4, SHIFT);
  753. // legacy shortcut (can be removed when necessary)
  754. NewFileAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_F4, CTRLSHIFT)));
  755. CloseApplicationAction->ShortCut = ShortCut(VK_F10, NONE);
  756. }
  757. #undef CTRL
  758. #undef ALT
  759. #undef NONE
  760. //---------------------------------------------------------------------------
  761. void __fastcall TNonVisualDataModule::SetScpExplorer(TCustomScpExplorerForm * value)
  762. {
  763. FScpExplorer = value;
  764. SessionIdleTimer->Enabled = (FScpExplorer != NULL);
  765. }
  766. //---------------------------------------------------------------------------
  767. void __fastcall TNonVisualDataModule::SessionIdleTimerTimer(
  768. TObject */*Sender*/)
  769. {
  770. DoIdle();
  771. }
  772. //---------------------------------------------------------------------------
  773. void __fastcall TNonVisualDataModule::DoIdle()
  774. {
  775. if (!FSessionIdleTimerExecuting)
  776. {
  777. FSessionIdleTimerExecuting = true;
  778. try
  779. {
  780. assert(ScpExplorer);
  781. ScpExplorer->Idle(FIdle >= 0);
  782. }
  783. __finally
  784. {
  785. FSessionIdleTimerExecuting = false;
  786. }
  787. }
  788. }
  789. //---------------------------------------------------------------------------
  790. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
  791. TTBCustomItem * Menu, bool OnFocused, bool Toolbar)
  792. {
  793. for (int Index = 0; Index < WinConfiguration->CustomCommands->Count; Index++)
  794. {
  795. AnsiString Description = WinConfiguration->CustomCommands->Names[Index];
  796. int State = ScpExplorer->CustomCommandState(Description, OnFocused);
  797. if (State >= 0)
  798. {
  799. TTBCustomItem * Item = new TTBXItem(Owner);
  800. Item->Caption = Description;
  801. if (Toolbar)
  802. {
  803. Item->Caption = StripHotkey(Item->Caption);
  804. }
  805. Item->Tag = Index;
  806. Item->Enabled = (State > 0);
  807. if (OnFocused)
  808. {
  809. Item->Tag = Item->Tag | 0x0100;
  810. }
  811. Item->Hint = FMTLOAD(CUSTOM_COMMAND_HINT, (StripHotkey(Description)));
  812. Item->OnClick = CustomCommandClick;
  813. Menu->Add(Item);
  814. }
  815. }
  816. TTBCustomItem * Item;
  817. Item = new TTBXItem(Menu);
  818. Item->Action = CustomCommandsEnterAction;
  819. Menu->Add(Item);
  820. AddMenuSeparator(Menu);
  821. if (!Toolbar)
  822. {
  823. Item = new TTBXItem(Menu);
  824. Item->Action = CustomCommandsBandAction;
  825. Menu->Add(Item);
  826. }
  827. Item = new TTBXItem(Menu);
  828. Item->Action = CustomCommandsCustomizeAction;
  829. Menu->Add(Item);
  830. }
  831. //---------------------------------------------------------------------------
  832. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(TAction * Action)
  833. {
  834. assert(Action);
  835. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  836. if (Menu)
  837. {
  838. int PrevCount = Menu->Count;
  839. bool OnFocused = (Menu == RemoteDirViewCustomCommandsMenu);
  840. CreateCustomCommandsMenu(Menu, OnFocused, false);
  841. for (int Index = 0; Index < PrevCount; Index++)
  842. {
  843. Menu->Delete(0);
  844. }
  845. }
  846. }
  847. //---------------------------------------------------------------------------
  848. void __fastcall TNonVisualDataModule::UpdateCustomCommandsToolbar(TTBXToolbar * Toolbar)
  849. {
  850. // can be called while explorer is being created
  851. if (ScpExplorer == NULL)
  852. {
  853. return;
  854. }
  855. int AdditionalCommands = 3;
  856. TCustomCommands * CustomCommands = WinConfiguration->CustomCommands;
  857. bool Changed = (CustomCommands->Count != (Toolbar->Items->Count - AdditionalCommands));
  858. if (!Changed)
  859. {
  860. int Index = 0;
  861. while (!Changed && (Index < CustomCommands->Count))
  862. {
  863. Changed =
  864. (Toolbar->Items->Items[Index]->Caption !=
  865. StripHotkey(CustomCommands->Names[Index]));
  866. Index++;
  867. }
  868. }
  869. if (Changed)
  870. {
  871. Toolbar->BeginUpdate();
  872. try
  873. {
  874. Toolbar->Items->Clear();
  875. CreateCustomCommandsMenu(Toolbar->Items, false, true);
  876. assert(CustomCommands->Count == (Toolbar->Items->Count - AdditionalCommands));
  877. }
  878. __finally
  879. {
  880. Toolbar->EndUpdate();
  881. }
  882. }
  883. else
  884. {
  885. for (int Index = 0; Index < Toolbar->Items->Count - AdditionalCommands; Index++)
  886. {
  887. TTBCustomItem * Item = Toolbar->Items->Items[Index];
  888. int CommandIndex = (Item->Tag & 0x00FF);
  889. assert(CommandIndex == Index);
  890. AnsiString Description = WinConfiguration->CustomCommands->Names[CommandIndex];
  891. int State = ScpExplorer->CustomCommandState(Description, false);
  892. assert(State >= 0);
  893. Item->Enabled = (State > 0);
  894. }
  895. }
  896. }
  897. //---------------------------------------------------------------------------
  898. void __fastcall TNonVisualDataModule::CustomCommandClick(TObject * Sender)
  899. {
  900. TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
  901. assert(Item);
  902. TCustomCommandParam Param;
  903. Param.Name = WinConfiguration->CustomCommands->Names[Item->Tag & 0x00FF];
  904. Param.Command = WinConfiguration->CustomCommands->Values[Param.Name];
  905. Param.Params = WinConfiguration->CustomCommands->Params[Param.Name];
  906. ScpExplorer->ExecuteFileOperation(foCustomCommand, osRemote,
  907. (Item->Tag & 0xFF00) != 0, false, &Param);
  908. }
  909. //---------------------------------------------------------------------------
  910. void __fastcall TNonVisualDataModule::CreateSessionListMenu(TAction * Action)
  911. {
  912. TTBCustomItem * SavedSessionsMenu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  913. int PrevCount = SavedSessionsMenu->Count;
  914. StoredSessions->Load();
  915. for (int Index = 0; Index < StoredSessions->Count; Index++)
  916. {
  917. TSessionData * Data = StoredSessions->Sessions[Index];
  918. TTBCustomItem * Item = new TTBXItem(SavedSessionsMenu);
  919. Item->Caption = Data->Name;
  920. Item->Tag = Index;
  921. Item->Hint = FMTLOAD(SAVEDSESSION_HINT, (Data->Name));
  922. Item->OnClick = SessionItemClick;
  923. SavedSessionsMenu->Add(Item);
  924. }
  925. for (int Index = 0; Index < PrevCount; Index++)
  926. {
  927. SavedSessionsMenu->Delete(0);
  928. }
  929. }
  930. //---------------------------------------------------------------------------
  931. void __fastcall TNonVisualDataModule::SessionItemClick(TObject * Sender)
  932. {
  933. assert(StoredSessions && (((TMenuItem *)Sender)->Tag < StoredSessions->Count));
  934. ScpExplorer->OpenStoredSession(StoredSessions->Sessions[((TMenuItem *)Sender)->Tag]);
  935. }
  936. //---------------------------------------------------------------------------
  937. TShortCut __fastcall TNonVisualDataModule::OpenSessionShortCut(int Index)
  938. {
  939. if (Index >= 0 && Index < 10)
  940. {
  941. return ShortCut((Word)(Index < 9 ? '0' + 1 + Index : '0'),
  942. TShiftState() << ssAlt);
  943. }
  944. else
  945. {
  946. return scNone;
  947. }
  948. }
  949. //---------------------------------------------------------------------------
  950. void __fastcall TNonVisualDataModule::CreateOpenedSessionListMenu(TAction * Action)
  951. {
  952. TTBCustomItem * OpenedSessionsMenu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  953. assert(OpenedSessionsMenu != NULL);
  954. TTerminalManager * Manager = TTerminalManager::Instance();
  955. TStrings * TerminalList = Manager->TerminalList;
  956. int PrevCount = OpenedSessionsMenu->Count;
  957. for (int Index = 0; Index < TerminalList->Count; Index++)
  958. {
  959. TTerminal * Terminal = dynamic_cast<TTerminal *>(TerminalList->Objects[Index]);
  960. assert(Terminal);
  961. TTBCustomItem * Item = new TTBXItem(OpenedSessionsMenu);
  962. Item->Caption = TerminalList->Strings[Index];
  963. Item->Tag = int(Terminal);
  964. Item->Hint = FMTLOAD(OPENEDSESSION_HINT, (Item->Caption));
  965. Item->Checked = (Manager->ActiveTerminal == Terminal);
  966. Item->ShortCut = OpenSessionShortCut(Index);
  967. Item->OnClick = OpenedSessionItemClick;
  968. Item->RadioItem = true;
  969. OpenedSessionsMenu->Add(Item);
  970. }
  971. for (int Index = 0; Index < PrevCount; Index++)
  972. {
  973. OpenedSessionsMenu->Delete(0);
  974. }
  975. }
  976. //---------------------------------------------------------------------------
  977. void __fastcall TNonVisualDataModule::OpenedSessionItemClick(TObject * Sender)
  978. {
  979. TTerminalManager::Instance()->ActiveTerminal = (TTerminal*)(((TMenuItem *)Sender)->Tag);
  980. }
  981. //---------------------------------------------------------------------------
  982. void __fastcall TNonVisualDataModule::CreateEditorListMenu(TAction * Action)
  983. {
  984. assert(Action != NULL);
  985. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  986. if (Menu != NULL)
  987. {
  988. int PrevCount = Menu->Count;
  989. TTBCustomItem * Item = new TTBXItem(Menu);
  990. Item->Caption = LoadStr(INTERNAL_EDITOR_NAME);
  991. Item->Tag = -1;
  992. Item->Hint = LoadStr(INTERNAL_EDITOR_HINT);
  993. Item->OnClick = EditorItemClick;
  994. Menu->Add(Item);
  995. AddMenuSeparator(Menu);
  996. TStringList * UsedEditors = new TStringList();
  997. try
  998. {
  999. UsedEditors->CaseSensitive = false;
  1000. UsedEditors->Sorted = true;
  1001. bool AnyExternal = false;
  1002. const TEditorList * EditorList = WinConfiguration->EditorList;
  1003. for (int Index = 0; Index < EditorList->Count; Index++)
  1004. {
  1005. const TEditorPreferences * Editor = EditorList->Editors[Index];
  1006. if ((Editor->Data.Editor == edExternal) &&
  1007. (UsedEditors->IndexOf(Editor->Data.ExternalEditor) < 0))
  1008. {
  1009. UsedEditors->Add(Editor->Data.ExternalEditor);
  1010. TTBCustomItem * Item = new TTBXItem(Menu);
  1011. Item->Caption = Editor->Name;
  1012. Item->Tag = Index;
  1013. Item->Hint = FMTLOAD(EXTERNAL_EDITOR_HINT, (Editor->Name));
  1014. Item->OnClick = EditorItemClick;
  1015. Menu->Add(Item);
  1016. AnyExternal = true;
  1017. }
  1018. }
  1019. if (AnyExternal)
  1020. {
  1021. AddMenuSeparator(Menu);
  1022. }
  1023. Item = new TTBXItem(Menu);
  1024. Item->Action = EditorListCustomizeAction;
  1025. Menu->Add(Item);
  1026. for (int Index = 0; Index < PrevCount; Index++)
  1027. {
  1028. Menu->Delete(0);
  1029. }
  1030. }
  1031. __finally
  1032. {
  1033. delete UsedEditors;
  1034. }
  1035. }
  1036. }
  1037. //---------------------------------------------------------------------------
  1038. void __fastcall TNonVisualDataModule::EditorItemClick(TObject * Sender)
  1039. {
  1040. int Tag = dynamic_cast<TTBXItem*>(Sender)->Tag;
  1041. if (Tag < 0)
  1042. {
  1043. ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, false);
  1044. }
  1045. else
  1046. {
  1047. const TEditorList * EditorList = WinConfiguration->EditorList;
  1048. // sanity check
  1049. if (Tag < EditorList->Count)
  1050. {
  1051. ScpExplorer->ExecuteFile(osCurrent, efExternalEditor, EditorList->Editors[Tag],
  1052. true, false);
  1053. }
  1054. }
  1055. }
  1056. //---------------------------------------------------------------------------
  1057. void __fastcall TNonVisualDataModule::QueuePopupPopup(TObject * /*Sender*/)
  1058. {
  1059. TAction * Action = NULL;
  1060. switch (ScpExplorer->DefaultQueueOperation())
  1061. {
  1062. case qoItemQuery:
  1063. Action = QueueItemQueryAction;
  1064. break;
  1065. case qoItemError:
  1066. Action = QueueItemErrorAction;
  1067. break;
  1068. case qoItemPrompt:
  1069. Action = QueueItemPromptAction;
  1070. break;
  1071. case qoItemExecute:
  1072. Action = QueueItemExecuteAction;
  1073. break;
  1074. case qoItemPause:
  1075. Action = QueueItemPauseAction;
  1076. break;
  1077. case qoItemResume:
  1078. Action = QueueItemResumeAction;
  1079. break;
  1080. }
  1081. TTBCustomItem * Item;
  1082. for (int Index = 0; Index < QueuePopup->Items->Count; Index++)
  1083. {
  1084. Item = QueuePopup->Items->Items[Index];
  1085. TTBItemOptions O = Item->Options;
  1086. if ((Action != NULL) && (Item->Action == Action))
  1087. {
  1088. O << tboDefault;
  1089. }
  1090. else
  1091. {
  1092. O >> tboDefault;
  1093. }
  1094. Item->Options = O;
  1095. }
  1096. }
  1097. //---------------------------------------------------------------------------
  1098. void __fastcall TNonVisualDataModule::ShowUpdatesUpdate()
  1099. {
  1100. TUpdatesConfiguration Updates = WinConfiguration->Updates;
  1101. unsigned short H, M, S, MS;
  1102. DecodeTime(Now(), H, M, S, MS);
  1103. int CurrentCompoundVer = CurrentCompoundVersion();
  1104. ShowUpdatesAction->ImageIndex =
  1105. ((Updates.HaveResults && (Updates.Results.ForVersion == CurrentCompoundVer) &&
  1106. ((Updates.Results.Critical && !Updates.ShownResults && (MS >= 500)) ||
  1107. ((!Updates.Results.Critical || Updates.ShownResults) &&
  1108. ((Updates.Results.Version > CurrentCompoundVer) ||
  1109. !Updates.Results.Message.IsEmpty())))) ? 80 :
  1110. ((int(Updates.Period) <= 0) ? 81 : 63));
  1111. }
  1112. //---------------------------------------------------------------------------
  1113. void __fastcall TNonVisualDataModule::PreferencesDialog(TPreferencesMode APreferencesMode)
  1114. {
  1115. if (ScpExplorer != NULL)
  1116. {
  1117. ScpExplorer->PreferencesDialog(APreferencesMode);
  1118. }
  1119. else
  1120. {
  1121. DoPreferencesDialog(APreferencesMode);
  1122. }
  1123. }