NonVisual.cpp 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  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. UPD(PreferencesAction, true)
  280. UPD(PresetsPreferencesAction, true)
  281. UPDEX(LockToolbarsAction, true,
  282. LockToolbarsAction->Checked = WinConfiguration->LockToolbars, )
  283. UPDCOMP(CustomCommandsBand)
  284. UPD(ColorMenuAction, true)
  285. UPDACT(ColorDefaultAction,
  286. ColorDefaultAction->Checked = (ScpExplorer->SessionColor == 0));
  287. UPD(ColorPickAction, true);
  288. // SORT
  289. UPDSORTA(Local)
  290. UPDSORT(Local, dv, Name)
  291. UPDSORT(Local, dv, Ext)
  292. UPDSORT(Local, dv, Size)
  293. UPDSORT(Local, dv, Type)
  294. UPDSORT(Local, dv, Changed)
  295. UPDSORT(Local, dv, Attr)
  296. UPDSORTA(Remote)
  297. UPDSORT(Remote, uv, Name)
  298. UPDSORT(Remote, uv, Ext)
  299. UPDSORT(Remote, uv, Size)
  300. UPDSORT(Remote, uv, Changed)
  301. UPDSORT(Remote, uv, Rights)
  302. UPDSORT(Remote, uv, Owner)
  303. UPDSORT(Remote, uv, Group)
  304. UPDSORT(Remote, uv, Type)
  305. UPDSORTA(Current)
  306. UPDSORTC(dv, Name, uv, Name)
  307. UPDSORTC(dv, Ext, uv, Ext)
  308. UPDSORTC(dv, Size, uv, Size)
  309. UPDSORTC(dv, Type, uv, Type)
  310. UPDSORTC(dv, Changed, uv, Changed)
  311. UPDSORTC(dv, Attr, uv, Rights)
  312. UPDSORTC(dv, Name, uv, Owner)
  313. UPDSORTC(dv, Name, uv, Group)
  314. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  315. UPDEX(SortColumnAscendingAction, (ListColumn != NULL), SortColumnAscendingAction->Checked =
  316. (COLVIEWPROPS->SortColumn == ListColumn->Index) && COLVIEWPROPS->SortAscending, /*assert(false)*/ )
  317. UPDEX(SortColumnDescendingAction, (ListColumn != NULL), SortColumnDescendingAction->Checked =
  318. (COLVIEWPROPS->SortColumn == ListColumn->Index) && !COLVIEWPROPS->SortAscending, /*assert(false)*/ )
  319. #undef COLVIEWPROPS
  320. // SHOW/HIDE COLUMN
  321. UPDSHCOL(Local, dv, Name)
  322. UPDSHCOL(Local, dv, Ext)
  323. UPDSHCOL(Local, dv, Size)
  324. UPDSHCOL(Local, dv, Type)
  325. UPDSHCOL(Local, dv, Changed)
  326. UPDSHCOL(Local, dv, Attr)
  327. UPDSHCOL(Remote, uv, Name)
  328. UPDSHCOL(Remote, uv, Ext)
  329. UPDSHCOL(Remote, uv, Size)
  330. UPDSHCOL(Remote, uv, Changed)
  331. UPDSHCOL(Remote, uv, Rights)
  332. UPDSHCOL(Remote, uv, Owner)
  333. UPDSHCOL(Remote, uv, Group)
  334. UPDSHCOL(Remote, uv, LinkTarget)
  335. UPDSHCOL(Remote, uv, Type)
  336. UPD(HideColumnAction, (ListColumn != NULL))
  337. UPD(BestFitColumnAction, (ListColumn != NULL))
  338. // SESSION
  339. UPD(NewSessionAction, true)
  340. UPD(CloseSessionAction, true)
  341. UPD(SavedSessionsAction, (StoredSessions->Count > 0))
  342. UPD(OpenedSessionsAction, true)
  343. UPD(SaveCurrentSessionAction, true)
  344. // COMMAND
  345. UPD(CompareDirectoriesAction, true)
  346. UPD(SynchronizeAction, true)
  347. UPD(FullSynchronizeAction, true)
  348. UPD(ConsoleAction, true)
  349. UPD(PuttyAction, TTerminalManager::Instance()->CanOpenInPutty())
  350. UPD(SynchronizeBrowsingAction, true)
  351. UPD(CloseApplicationAction, true)
  352. UPD(FileSystemInfoAction, true)
  353. UPD(ClearCachesAction, (ScpExplorer->Terminal != NULL) && !ScpExplorer->Terminal->AreCachesEmpty)
  354. UPD(NewFileAction, !WinConfiguration->DisableOpenEdit)
  355. UPD(EditorListCustomizeAction, true)
  356. // CUSTOM COMMANDS
  357. UPD(CustomCommandsAction, true)
  358. UPD(CustomCommandsEnterAction, true)
  359. UPD(CustomCommandsCustomizeAction, true)
  360. // QUEUE
  361. #define UPDQUEUE(OPERATION) UPD(Queue ## OPERATION ## Action, \
  362. ScpExplorer->AllowQueueOperation(qo ## OPERATION))
  363. UPDQUEUE(GoTo)
  364. UPDQUEUE(Preferences)
  365. UPDEX(QueueItemQueryAction, ScpExplorer->AllowQueueOperation(qoItemQuery),
  366. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  367. UPDEX(QueueItemErrorAction, ScpExplorer->AllowQueueOperation(qoItemError),
  368. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  369. UPDEX(QueueItemPromptAction, ScpExplorer->AllowQueueOperation(qoItemPrompt),
  370. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  371. UPDQUEUE(ItemDelete)
  372. UPDEX(QueueItemExecuteAction, ScpExplorer->AllowQueueOperation(qoItemExecute),
  373. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible =
  374. !ScpExplorer->AllowQueueOperation(qoItemPause) &&
  375. !ScpExplorer->AllowQueueOperation(qoItemResume))
  376. UPDEX(QueueItemPauseAction, ScpExplorer->AllowQueueOperation(qoItemPause),
  377. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  378. UPDEX(QueueItemResumeAction, ScpExplorer->AllowQueueOperation(qoItemResume),
  379. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  380. UPDQUEUE(ItemUp)
  381. UPDQUEUE(ItemDown)
  382. UPDQUEUE(PauseAll)
  383. UPDQUEUE(ResumeAll)
  384. #undef UPDQUEUE
  385. UPDACT(QueueToggleShowAction,
  386. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueView])
  387. #define QUEUEACTION(SHOW) UPDACT(Queue ## SHOW ## Action, \
  388. ((TAction *)Action)->Checked = WinConfiguration->QueueView.Show == qv ## SHOW)
  389. QUEUEACTION(Show)
  390. QUEUEACTION(HideWhenEmpty)
  391. QUEUEACTION(Hide)
  392. #undef QUEUEACTION
  393. UPD(QueueDisconnectOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoDisconnectOnceEmpty))
  394. UPDCOMP(CommanderPreferencesBand)
  395. UPDACT(QueueToolbarAction,
  396. ((TAction *)Action)->Enabled = ScpExplorer->ComponentVisible[fcQueueView];
  397. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueToolbar]);
  398. ;
  399. }
  400. //---------------------------------------------------------------------------
  401. void __fastcall TNonVisualDataModule::ExplorerActionsExecute(
  402. TBasicAction *Action, bool &Handled)
  403. {
  404. assert(ScpExplorer);
  405. if (!ScpExplorer->AllowedAction((TAction *)Action, aaExecute))
  406. {
  407. Handled = true;
  408. return;
  409. }
  410. ScpExplorer->BeforeAction();
  411. FIdle--;
  412. try
  413. {
  414. // focused operation
  415. EXE(CurrentCopyFocusedAction, ScpExplorer->ExecuteFileOperation(foCopy, osCurrent, true))
  416. EXE(CurrentMoveFocusedAction, ScpExplorer->ExecuteFileOperation(foMove, osCurrent, true))
  417. EXE(CurrentDeleteFocusedAction, ScpExplorer->ExecuteFileOperation(foDelete, osCurrent, true))
  418. EXE(CurrentPropertiesFocusedAction, ScpExplorer->ExecuteFileOperation(foSetProperties, osCurrent, true))
  419. EXE(RemoteMoveToFocusedAction, ScpExplorer->ExecuteFileOperation(foRemoteMove, osCurrent, true))
  420. EXE(RemoteCopyToFocusedAction, ScpExplorer->ExecuteFileOperation(foRemoteCopy, osCurrent, true))
  421. EXE(CurrentEditFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, true))
  422. // operation
  423. EXE(CurrentCopyAction, ScpExplorer->ExecuteFileOperation(foCopy, osCurrent, false))
  424. EXE(RemoteCopyAction, ScpExplorer->ExecuteFileOperation(foCopy, osRemote, false))
  425. EXE(LocalCopyAction, ScpExplorer->ExecuteFileOperation(foCopy, osLocal, false))
  426. EXE(CurrentMoveAction, ScpExplorer->ExecuteFileOperation(foMove, osCurrent, false))
  427. EXE(CurrentEditAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, false))
  428. EXE(CurrentEditAlternativeAction, CreateEditorListMenu(CurrentEditAlternativeAction))
  429. EXE(CurrentOpenAction, ScpExplorer->ExecuteCurrentFile())
  430. EXE(AddEditLinkAction, ScpExplorer->AddEditLink(false))
  431. EXE(NewLinkAction, ScpExplorer->AddEditLink(true))
  432. EXE(CurrentRenameAction, ScpExplorer->ExecuteFileOperation(foRename, osCurrent, false))
  433. EXE(CurrentDeleteAction, ScpExplorer->ExecuteFileOperation(foDelete, osCurrent, false))
  434. EXE(CurrentPropertiesAction, ScpExplorer->ExecuteFileOperation(foSetProperties, osCurrent, false))
  435. EXE(RemoteMoveToAction, ScpExplorer->ExecuteFileOperation(foRemoteMove, osCurrent, false))
  436. EXE(RemoteCopyToAction, ScpExplorer->ExecuteFileOperation(foRemoteCopy, osCurrent, false))
  437. EXE(FileListToCommandLineAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedCommandLine))
  438. EXE(FileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedClipboard))
  439. EXE(FullFileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFullFileList, pedClipboard))
  440. EXE(UrlToClipboardAction, ScpExplorer->PanelExport(osCurrent, peUrl, pedClipboard))
  441. EXE(FileListFromClipboardAction, ScpExplorer->FileListFromClipboard())
  442. // directory
  443. EXE(CurrentCreateDirAction, ScpExplorer->CreateDirectory(osCurrent))
  444. EXE(NewDirAction, ScpExplorer->CreateDirectory(osCurrent))
  445. //selection
  446. EXE(SelectOneAction, DirView(osCurrent)->SelectCurrentItem(DirView(osCurrent)->NortonLike))
  447. EXE(SelectAction, DirView(osCurrent)->DoSelectByMask(true))
  448. EXE(UnselectAction, DirView(osCurrent)->DoSelectByMask(false))
  449. EXE(SelectAllAction, DirView(osCurrent)->SelectAll(smAll))
  450. EXE(InvertSelectionAction, DirView(osCurrent)->SelectAll(smInvert))
  451. EXE(ClearSelectionAction, DirView(osCurrent)->SelectAll(smNone))
  452. EXE(RestoreSelectionAction, DirView(osCurrent)->RestoreSelectedNames())
  453. EXE(PasteAction, ScpExplorer->PasteFromClipBoard())
  454. // style
  455. EXE(CurrentCycleStyleAction,
  456. if (DirView(osCurrent)->ViewStyle == vsReport) DirView(osCurrent)->ViewStyle = vsIcon;
  457. else DirView(osCurrent)->ViewStyle = (TViewStyle)(DirView(osCurrent)->ViewStyle + 1);
  458. )
  459. #define STYLEACTION(Style) EXE(Current ## Style ## Action, \
  460. DirView(osCurrent)->ViewStyle = vs ## Style)
  461. STYLEACTION(Icon)
  462. STYLEACTION(SmallIcon)
  463. STYLEACTION(List)
  464. STYLEACTION(Report)
  465. #undef STYLEACTION
  466. #define PANEL_ACTIONS(SIDE) \
  467. EXE(SIDE ## BackAction, DirView(os ## SIDE)->HistoryGo(-1)) \
  468. EXE(SIDE ## ForwardAction, DirView(os ## SIDE)->HistoryGo(1)) \
  469. EXE(SIDE ## ParentDirAction, DirView(os ## SIDE)->ExecuteParentDirectory()) \
  470. EXE(SIDE ## RootDirAction, DirView(os ## SIDE)->ExecuteRootDirectory()) \
  471. EXE(SIDE ## HomeDirAction, DirView(os ## SIDE)->ExecuteHomeDirectory()) \
  472. EXE(SIDE ## RefreshAction, DirView(os ## SIDE)->ReloadDirectory()) \
  473. EXE(SIDE ## OpenDirAction, ScpExplorer->OpenDirectory(os ## SIDE)) \
  474. EXE(SIDE ## ChangePathAction, ScpExplorer->ChangePath(os ## SIDE)) \
  475. EXE(SIDE ## AddBookmarkAction, ScpExplorer->AddBookmark(os ## SIDE)) \
  476. EXE(SIDE ## PathToClipboardAction, ScpExplorer->PanelExport(os ## SIDE, pePath, pedClipboard))
  477. PANEL_ACTIONS(Local)
  478. PANEL_ACTIONS(Remote)
  479. #undef PANEL_ACTIONS
  480. EXE(LocalExploreDirectoryAction, ScpExplorer->ExploreLocalDirectory())
  481. //HELP
  482. EXE(AboutAction, DoAboutDialog(Configuration))
  483. EXE(HomepageAction, OpenBrowser(LoadStr(HOMEPAGE_URL)))
  484. EXE(HistoryPageAction, OpenBrowser(LoadStr(HISTORY_URL)))
  485. EXE(TableOfContentsAction, Application->HelpSystem->ShowTableOfContents())
  486. EXE(ForumPageAction, OpenBrowser(LoadStr(FORUM_URL)))
  487. EXE(CheckForUpdatesAction, CheckForUpdates(false))
  488. EXE(ShowUpdatesAction, CheckForUpdates(true))
  489. EXE(UpdatesPreferencesAction, PreferencesDialog(pmUpdates))
  490. EXE(DonatePageAction, OpenBrowser(LoadStr(DONATE_URL)))
  491. EXE(DownloadPageAction, OpenBrowser(LoadStr(DOWNLOAD_URL)))
  492. // VIEW
  493. EXECOMP(StatusBar)
  494. EXECOMP(ToolBar)
  495. EXECOMP(LocalStatusBar)
  496. EXECOMP(RemoteStatusBar)
  497. EXECOMP(ExplorerMenuBand)
  498. EXECOMP(ExplorerAddressBand)
  499. EXECOMP(ExplorerToolbarBand)
  500. EXECOMP(ExplorerSelectionBand)
  501. EXECOMP(ExplorerSessionBand)
  502. EXECOMP(ExplorerPreferencesBand)
  503. EXECOMP(ExplorerSortBand)
  504. EXECOMP(ExplorerUpdatesBand)
  505. EXECOMP(ExplorerTransferBand)
  506. EXECOMP(ExplorerCustomCommandsBand)
  507. EXECOMP(CommanderMenuBand)
  508. EXECOMP(CommanderSessionBand)
  509. EXECOMP(CommanderPreferencesBand)
  510. EXECOMP(CommanderSelectionBand)
  511. EXECOMP(CommanderToolbarBand)
  512. EXECOMP(CommanderSortBand)
  513. EXECOMP(CommanderCommandsBand)
  514. EXECOMP(CommanderUpdatesBand)
  515. EXECOMP(CommanderTransferBand)
  516. EXECOMP(CommanderUploadDownloadBand)
  517. EXECOMP(CommanderCustomCommandsBand)
  518. EXECOMP(CommanderLocalHistoryBand)
  519. EXECOMP(CommanderLocalNavigationBand)
  520. EXECOMP(CommanderRemoteHistoryBand)
  521. EXECOMP(CommanderRemoteNavigationBand)
  522. EXECOMP(CommandLinePanel)
  523. EXECOMP(RemoteTree)
  524. EXECOMP(LocalTree)
  525. EXE(GoToCommandLineAction, ScpExplorer->GoToCommandLine())
  526. EXE(GoToTreeAction, ScpExplorer->GoToTree())
  527. EXE(ViewLogAction, WinConfiguration->LogView =
  528. (WinConfiguration->LogView == lvNone ? lvWindow : lvNone) )
  529. EXE(ShowHiddenFilesAction, WinConfiguration->ShowHiddenFiles = !WinConfiguration->ShowHiddenFiles)
  530. EXE(PreferencesAction, PreferencesDialog(pmDefault) )
  531. EXE(PresetsPreferencesAction, PreferencesDialog(pmPresets) )
  532. EXE(LockToolbarsAction, WinConfiguration->LockToolbars = !WinConfiguration->LockToolbars)
  533. EXECOMP(CustomCommandsBand)
  534. EXE(ColorMenuAction, );
  535. EXE(ColorDefaultAction, ScpExplorer->SessionColor = (TColor)0);
  536. EXE(ColorPickAction, ScpExplorer->SessionColorPick());
  537. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  538. // SORT
  539. EXESORTA(Local)
  540. EXESORT(Local, dv, Name)
  541. EXESORT(Local, dv, Ext)
  542. EXESORT(Local, dv, Size)
  543. EXESORT(Local, dv, Type)
  544. EXESORT(Local, dv, Changed)
  545. EXESORT(Local, dv, Attr)
  546. EXESORTA(Remote)
  547. EXESORT(Remote, uv, Name)
  548. EXESORT(Remote, uv, Ext)
  549. EXESORT(Remote, uv, Size)
  550. EXESORT(Remote, uv, Changed)
  551. EXESORT(Remote, uv, Rights)
  552. EXESORT(Remote, uv, Owner)
  553. EXESORT(Remote, uv, Group)
  554. EXESORT(Remote, uv, Type)
  555. EXESORTA(Current)
  556. EXESORTC(Name, dvName, uvName)
  557. EXESORTC(Ext, dvExt, uvExt)
  558. EXESORTC(Size, dvSize, uvSize)
  559. EXESORTC(Type, dvType, uvType)
  560. EXESORTC(Changed, dvChanged, uvChanged)
  561. EXESORTC(Rights, dvAttr, uvRights)
  562. EXESORTC(Owner, dvName, uvOwner)
  563. EXESORTC(Group, dvName, uvGroup)
  564. EXE(SortColumnAscendingAction, assert(ListColumn);
  565. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = true; ListColumn = NULL )
  566. EXE(SortColumnDescendingAction, assert(ListColumn);
  567. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = false; ListColumn = NULL )
  568. // SHOW/HIDE COLUMN
  569. EXESHCOL(Local, dv, Name)
  570. EXESHCOL(Local, dv, Ext)
  571. EXESHCOL(Local, dv, Size)
  572. EXESHCOL(Local, dv, Type)
  573. EXESHCOL(Local, dv, Changed)
  574. EXESHCOL(Local, dv, Attr)
  575. EXESHCOL(Remote, uv, Name)
  576. EXESHCOL(Remote, uv, Ext)
  577. EXESHCOL(Remote, uv, Size)
  578. EXESHCOL(Remote, uv, Changed)
  579. EXESHCOL(Remote, uv, Rights)
  580. EXESHCOL(Remote, uv, Owner)
  581. EXESHCOL(Remote, uv, Group)
  582. EXESHCOL(Remote, uv, LinkTarget)
  583. EXESHCOL(Remote, uv, Type)
  584. EXE(HideColumnAction, assert(ListColumn);
  585. COLVIEWPROPS->Visible[ListColumn->Index] = false; ListColumn = NULL )
  586. EXE(BestFitColumnAction, assert(ListColumn); ListColumn = NULL ) // TODO
  587. #undef COLVIEWPROPS
  588. // SESSION
  589. EXE(NewSessionAction, ScpExplorer->NewSession())
  590. EXE(CloseSessionAction, ScpExplorer->CloseSession())
  591. EXE(SavedSessionsAction, CreateSessionListMenu(SavedSessionsAction))
  592. EXE(OpenedSessionsAction, CreateOpenedSessionListMenu(OpenedSessionsAction))
  593. EXE(SaveCurrentSessionAction, ScpExplorer->SaveCurrentSession())
  594. // COMMAND
  595. EXE(CompareDirectoriesAction, ScpExplorer->CompareDirectories())
  596. EXE(SynchronizeAction, ScpExplorer->SynchronizeDirectories())
  597. EXE(FullSynchronizeAction, ScpExplorer->FullSynchronizeDirectories())
  598. EXE(ConsoleAction, ScpExplorer->OpenConsole())
  599. EXE(PuttyAction, TTerminalManager::Instance()->OpenInPutty())
  600. EXE(SynchronizeBrowsingAction, )
  601. EXE(CloseApplicationAction, ScpExplorer->Close())
  602. EXE(FileSystemInfoAction, ScpExplorer->FileSystemInfo())
  603. EXE(ClearCachesAction, ScpExplorer->Terminal->ClearCaches())
  604. EXE(NewFileAction, ScpExplorer->EditNew(osCurrent))
  605. EXE(EditorListCustomizeAction, PreferencesDialog(pmEditor))
  606. // CUSTOM COMMANDS
  607. EXE(CustomCommandsAction, CreateCustomCommandsMenu(CustomCommandsAction))
  608. EXE(CustomCommandsEnterAction, ScpExplorer->AdHocCustomCommand(
  609. Action->ActionComponent == RemoteDirViewCustomCommandsMenu))
  610. EXE(CustomCommandsCustomizeAction, PreferencesDialog(pmCustomCommands))
  611. // QUEUE
  612. #define EXEQUEUE(OPERATION) EXE(Queue ## OPERATION ## Action, \
  613. ScpExplorer->ExecuteQueueOperation(qo ## OPERATION))
  614. EXEQUEUE(GoTo)
  615. EXEQUEUE(Preferences)
  616. EXEQUEUE(ItemQuery)
  617. EXEQUEUE(ItemError)
  618. EXEQUEUE(ItemPrompt)
  619. EXEQUEUE(ItemDelete)
  620. EXEQUEUE(ItemExecute)
  621. EXEQUEUE(ItemPause)
  622. EXEQUEUE(ItemResume)
  623. EXEQUEUE(ItemUp)
  624. EXEQUEUE(ItemDown)
  625. EXEQUEUE(PauseAll)
  626. EXEQUEUE(ResumeAll)
  627. #undef EXEQUEUE
  628. EXE(QueueToggleShowAction, ScpExplorer->ToggleQueueVisibility())
  629. #define QUEUEACTION(SHOW) EXE(Queue ## SHOW ## Action, \
  630. TQueueViewConfiguration Config = WinConfiguration->QueueView; \
  631. if (Config.Show != qvShow) Config.LastHideShow = Config.Show; \
  632. Config.Show = qv ## SHOW; \
  633. WinConfiguration->QueueView = Config)
  634. QUEUEACTION(Show)
  635. QUEUEACTION(HideWhenEmpty)
  636. QUEUEACTION(Hide)
  637. #undef QUEUEACTION
  638. EXE(QueueDisconnectOnceEmptyAction, )
  639. EXECOMP(QueueToolbar);
  640. ;
  641. }
  642. __finally
  643. {
  644. assert(FIdle < 0);
  645. FIdle++;
  646. }
  647. DoIdle();
  648. }
  649. //---------------------------------------------------------------------------
  650. void __fastcall TNonVisualDataModule::UpdateNonVisibleActions()
  651. {
  652. // following actions needs to be updated even when all clients
  653. // are invisible, so the queue list toolbar button can be shown
  654. NonVisualDataModule->QueueItemQueryAction->Update();
  655. NonVisualDataModule->QueueItemErrorAction->Update();
  656. NonVisualDataModule->QueueItemPromptAction->Update();
  657. }
  658. //---------------------------------------------------------------------------
  659. #define CTRL TShiftState() << ssCtrl
  660. #define ALT TShiftState() << ssAlt
  661. #define SHIFT TShiftState() << ssShift
  662. #define CTRLSHIFT TShiftState() << ssCtrl << ssShift
  663. #define CTRLALT TShiftState() << ssCtrl << ssAlt
  664. #define NONE TShiftState()
  665. void __fastcall TNonVisualDataModule::ExplorerShortcuts()
  666. {
  667. // Directory
  668. CurrentCreateDirAction->ShortCut = ShortCut('D', CTRL);
  669. NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
  670. // File operation
  671. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  672. CurrentEditAction->ShortCut = ShortCut('E', CTRL);
  673. AddEditLinkAction->ShortCut = ShortCut('L', CTRLALT);
  674. NewLinkAction->ShortCut = AddEditLinkAction->ShortCut;
  675. // Focused operation
  676. CurrentCopyFocusedAction->ShortCut = ShortCut('C', CTRL);
  677. CurrentMoveFocusedAction->ShortCut = ShortCut('M', CTRL);
  678. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_DELETE, NONE);
  679. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_RETURN, ALT);
  680. RemoteMoveToFocusedAction->ShortCut = ShortCut('M', CTRLALT);
  681. // remote directory
  682. RemoteOpenDirAction->ShortCut = ShortCut('O', CTRL);
  683. RemoteRefreshAction->ShortCut = ShortCut(VK_F5, NONE);
  684. RemoteHomeDirAction->ShortCut = ShortCut('H', CTRL);
  685. // selected operation
  686. CurrentCopyAction->ShortCut = CurrentCopyFocusedAction->ShortCut;
  687. CurrentMoveAction->ShortCut = CurrentMoveFocusedAction->ShortCut;
  688. CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
  689. CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
  690. RemoteMoveToAction->ShortCut = ShortCut('M', CTRLALT);
  691. // selection
  692. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  693. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  694. SelectAllAction->ShortCut = ShortCut('A', CTRL);
  695. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  696. ClearSelectionAction->ShortCut = ShortCut('L', CTRL);
  697. RestoreSelectionAction->ShortCut = ShortCut('R', CTRLALT);
  698. // commands
  699. NewFileAction->ShortCut = ShortCut('E', CTRLSHIFT);
  700. CloseApplicationAction->ShortCut = ShortCut(VK_F4, ALT);
  701. }
  702. //---------------------------------------------------------------------------
  703. void __fastcall TNonVisualDataModule::CommanderShortcuts()
  704. {
  705. // Directory
  706. CurrentCreateDirAction->ShortCut = ShortCut(VK_F7, NONE);
  707. NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
  708. // File operation
  709. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  710. CurrentEditAction->ShortCut = ShortCut(VK_F4, NONE);
  711. AddEditLinkAction->ShortCut = ShortCut(VK_F6, ALT);
  712. NewLinkAction->ShortCut = AddEditLinkAction->ShortCut;
  713. // Focused operation
  714. CurrentCopyFocusedAction->ShortCut = ShortCut(VK_F5, NONE);
  715. CurrentMoveFocusedAction->ShortCut = ShortCut(VK_F6, NONE);
  716. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_F8, NONE);
  717. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_F9, NONE);
  718. RemoteMoveToFocusedAction->ShortCut = ShortCut(VK_F6, SHIFT);
  719. RemoteCopyToFocusedAction->ShortCut = ShortCut(VK_F5, SHIFT);
  720. // remote directory
  721. RemoteOpenDirAction->ShortCut = ShortCut('O', CTRL);
  722. RemoteRefreshAction->ShortCut = ShortCut('R', CTRL);
  723. RemoteHomeDirAction->ShortCut = ShortCut('H', CTRL);
  724. RemotePathToClipboardAction->ShortCut = ShortCut(VK_OEM_6 /* ] */, CTRL);
  725. // local directory
  726. LocalOpenDirAction->ShortCut = RemoteOpenDirAction->ShortCut;
  727. LocalRefreshAction->ShortCut = RemoteRefreshAction->ShortCut;
  728. LocalHomeDirAction->ShortCut = RemoteHomeDirAction->ShortCut;
  729. LocalPathToClipboardAction->ShortCut = ShortCut(VK_OEM_4 /* [ */, CTRL);
  730. // selected operation
  731. CurrentCopyAction->ShortCut = CurrentCopyFocusedAction->ShortCut;
  732. CurrentMoveAction->ShortCut = CurrentMoveFocusedAction->ShortCut;
  733. CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
  734. CurrentDeleteAction->SecondaryShortCuts->Clear();
  735. CurrentDeleteAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, NONE)));
  736. CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
  737. RemoteMoveToAction->ShortCut = ShortCut(VK_F6, SHIFT);
  738. RemoteCopyToAction->ShortCut = ShortCut(VK_F5, SHIFT);
  739. // selection
  740. SelectOneAction->ShortCut = VK_INSERT;
  741. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  742. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  743. SelectAllAction->ShortCut = ShortCut('A', CTRL);
  744. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  745. ClearSelectionAction->ShortCut = ShortCut('L', CTRL);
  746. RestoreSelectionAction->ShortCut = ShortCut('R', CTRLALT);
  747. // commands
  748. NewFileAction->ShortCut = ShortCut(VK_F4, SHIFT);
  749. // legacy shortcut (can be removed when necessary)
  750. NewFileAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_F4, CTRLSHIFT)));
  751. CloseApplicationAction->ShortCut = ShortCut(VK_F10, NONE);
  752. }
  753. #undef CTRL
  754. #undef ALT
  755. #undef NONE
  756. //---------------------------------------------------------------------------
  757. void __fastcall TNonVisualDataModule::SetScpExplorer(TCustomScpExplorerForm * value)
  758. {
  759. FScpExplorer = value;
  760. SessionIdleTimer->Enabled = (FScpExplorer != NULL);
  761. }
  762. //---------------------------------------------------------------------------
  763. void __fastcall TNonVisualDataModule::SessionIdleTimerTimer(
  764. TObject */*Sender*/)
  765. {
  766. DoIdle();
  767. }
  768. //---------------------------------------------------------------------------
  769. void __fastcall TNonVisualDataModule::DoIdle()
  770. {
  771. if (!FSessionIdleTimerExecuting)
  772. {
  773. FSessionIdleTimerExecuting = true;
  774. try
  775. {
  776. assert(ScpExplorer);
  777. ScpExplorer->Idle(FIdle >= 0);
  778. }
  779. __finally
  780. {
  781. FSessionIdleTimerExecuting = false;
  782. }
  783. }
  784. }
  785. //---------------------------------------------------------------------------
  786. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
  787. TTBCustomItem * Menu, bool OnFocused, bool Toolbar)
  788. {
  789. for (int Index = 0; Index < WinConfiguration->CustomCommands->Count; Index++)
  790. {
  791. AnsiString Description = WinConfiguration->CustomCommands->Names[Index];
  792. int State = ScpExplorer->CustomCommandState(Description, OnFocused);
  793. if (State >= 0)
  794. {
  795. TTBCustomItem * Item = new TTBXItem(Owner);
  796. Item->Caption = Description;
  797. if (Toolbar)
  798. {
  799. Item->Caption = StripHotkey(Item->Caption);
  800. }
  801. Item->Tag = Index;
  802. Item->Enabled = (State > 0);
  803. if (OnFocused)
  804. {
  805. Item->Tag = Item->Tag | 0x0100;
  806. }
  807. Item->Hint = FMTLOAD(CUSTOM_COMMAND_HINT, (StripHotkey(Description)));
  808. Item->OnClick = CustomCommandClick;
  809. Menu->Add(Item);
  810. }
  811. }
  812. TTBCustomItem * Item;
  813. Item = new TTBXItem(Menu);
  814. Item->Action = CustomCommandsEnterAction;
  815. Menu->Add(Item);
  816. AddMenuSeparator(Menu);
  817. if (!Toolbar)
  818. {
  819. Item = new TTBXItem(Menu);
  820. Item->Action = CustomCommandsBandAction;
  821. Menu->Add(Item);
  822. }
  823. Item = new TTBXItem(Menu);
  824. Item->Action = CustomCommandsCustomizeAction;
  825. Menu->Add(Item);
  826. }
  827. //---------------------------------------------------------------------------
  828. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(TAction * Action)
  829. {
  830. assert(Action);
  831. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  832. if (Menu)
  833. {
  834. int PrevCount = Menu->Count;
  835. bool OnFocused = (Menu == RemoteDirViewCustomCommandsMenu);
  836. CreateCustomCommandsMenu(Menu, OnFocused, false);
  837. for (int Index = 0; Index < PrevCount; Index++)
  838. {
  839. Menu->Delete(0);
  840. }
  841. }
  842. }
  843. //---------------------------------------------------------------------------
  844. void __fastcall TNonVisualDataModule::UpdateCustomCommandsToolbar(TTBXToolbar * Toolbar)
  845. {
  846. // can be called while explorer is being created
  847. if (ScpExplorer == NULL)
  848. {
  849. return;
  850. }
  851. int AdditionalCommands = 3;
  852. TCustomCommands * CustomCommands = WinConfiguration->CustomCommands;
  853. bool Changed = (CustomCommands->Count != (Toolbar->Items->Count - AdditionalCommands));
  854. if (!Changed)
  855. {
  856. int Index = 0;
  857. while (!Changed && (Index < CustomCommands->Count))
  858. {
  859. Changed =
  860. (Toolbar->Items->Items[Index]->Caption !=
  861. StripHotkey(CustomCommands->Names[Index]));
  862. Index++;
  863. }
  864. }
  865. if (Changed)
  866. {
  867. Toolbar->BeginUpdate();
  868. try
  869. {
  870. Toolbar->Items->Clear();
  871. CreateCustomCommandsMenu(Toolbar->Items, false, true);
  872. assert(CustomCommands->Count == (Toolbar->Items->Count - AdditionalCommands));
  873. }
  874. __finally
  875. {
  876. Toolbar->EndUpdate();
  877. }
  878. }
  879. else
  880. {
  881. for (int Index = 0; Index < Toolbar->Items->Count - AdditionalCommands; Index++)
  882. {
  883. TTBCustomItem * Item = Toolbar->Items->Items[Index];
  884. int CommandIndex = (Item->Tag & 0x00FF);
  885. assert(CommandIndex == Index);
  886. AnsiString Description = WinConfiguration->CustomCommands->Names[CommandIndex];
  887. int State = ScpExplorer->CustomCommandState(Description, false);
  888. assert(State >= 0);
  889. Item->Enabled = (State > 0);
  890. }
  891. }
  892. }
  893. //---------------------------------------------------------------------------
  894. void __fastcall TNonVisualDataModule::CustomCommandClick(TObject * Sender)
  895. {
  896. TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
  897. assert(Item);
  898. TCustomCommandParam Param;
  899. Param.Name = WinConfiguration->CustomCommands->Names[Item->Tag & 0x00FF];
  900. Param.Command = WinConfiguration->CustomCommands->Values[Param.Name];
  901. Param.Params = WinConfiguration->CustomCommands->Params[Param.Name];
  902. ScpExplorer->ExecuteFileOperation(foCustomCommand, osRemote,
  903. (Item->Tag & 0xFF00) != 0, false, &Param);
  904. }
  905. //---------------------------------------------------------------------------
  906. void __fastcall TNonVisualDataModule::CreateSessionListMenu(TAction * Action)
  907. {
  908. TTBCustomItem * SavedSessionsMenu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  909. int PrevCount = SavedSessionsMenu->Count;
  910. StoredSessions->Load();
  911. for (int Index = 0; Index < StoredSessions->Count; Index++)
  912. {
  913. TSessionData * Data = StoredSessions->Sessions[Index];
  914. TTBCustomItem * Item = new TTBXItem(SavedSessionsMenu);
  915. Item->Caption = Data->Name;
  916. Item->Tag = Index;
  917. Item->Hint = FMTLOAD(SAVEDSESSION_HINT, (Data->Name));
  918. Item->OnClick = SessionItemClick;
  919. SavedSessionsMenu->Add(Item);
  920. }
  921. for (int Index = 0; Index < PrevCount; Index++)
  922. {
  923. SavedSessionsMenu->Delete(0);
  924. }
  925. }
  926. //---------------------------------------------------------------------------
  927. void __fastcall TNonVisualDataModule::SessionItemClick(TObject * Sender)
  928. {
  929. assert(StoredSessions && (((TMenuItem *)Sender)->Tag < StoredSessions->Count));
  930. ScpExplorer->OpenStoredSession(StoredSessions->Sessions[((TMenuItem *)Sender)->Tag]);
  931. }
  932. //---------------------------------------------------------------------------
  933. TShortCut __fastcall TNonVisualDataModule::OpenSessionShortCut(int Index)
  934. {
  935. if (Index >= 0 && Index < 10)
  936. {
  937. return ShortCut((Word)(Index < 9 ? '0' + 1 + Index : '0'),
  938. TShiftState() << ssAlt);
  939. }
  940. else
  941. {
  942. return scNone;
  943. }
  944. }
  945. //---------------------------------------------------------------------------
  946. void __fastcall TNonVisualDataModule::CreateOpenedSessionListMenu(TAction * Action)
  947. {
  948. TTBCustomItem * OpenedSessionsMenu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  949. assert(OpenedSessionsMenu != NULL);
  950. TTerminalManager * Manager = TTerminalManager::Instance();
  951. TStrings * TerminalList = Manager->TerminalList;
  952. int PrevCount = OpenedSessionsMenu->Count;
  953. for (int Index = 0; Index < TerminalList->Count; Index++)
  954. {
  955. TTerminal * Terminal = dynamic_cast<TTerminal *>(TerminalList->Objects[Index]);
  956. assert(Terminal);
  957. TTBCustomItem * Item = new TTBXItem(OpenedSessionsMenu);
  958. Item->Caption = TerminalList->Strings[Index];
  959. Item->Tag = int(Terminal);
  960. Item->Hint = FMTLOAD(OPENEDSESSION_HINT, (Item->Caption));
  961. Item->Checked = (Manager->ActiveTerminal == Terminal);
  962. Item->ShortCut = OpenSessionShortCut(Index);
  963. Item->OnClick = OpenedSessionItemClick;
  964. Item->RadioItem = true;
  965. OpenedSessionsMenu->Add(Item);
  966. }
  967. for (int Index = 0; Index < PrevCount; Index++)
  968. {
  969. OpenedSessionsMenu->Delete(0);
  970. }
  971. }
  972. //---------------------------------------------------------------------------
  973. void __fastcall TNonVisualDataModule::OpenedSessionItemClick(TObject * Sender)
  974. {
  975. TTerminalManager::Instance()->ActiveTerminal = (TTerminal*)(((TMenuItem *)Sender)->Tag);
  976. }
  977. //---------------------------------------------------------------------------
  978. void __fastcall TNonVisualDataModule::CreateEditorListMenu(TAction * Action)
  979. {
  980. assert(Action != NULL);
  981. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  982. if (Menu != NULL)
  983. {
  984. int PrevCount = Menu->Count;
  985. TTBCustomItem * Item = new TTBXItem(Menu);
  986. Item->Caption = LoadStr(INTERNAL_EDITOR_NAME);
  987. Item->Tag = -1;
  988. Item->Hint = LoadStr(INTERNAL_EDITOR_HINT);
  989. Item->OnClick = EditorItemClick;
  990. Menu->Add(Item);
  991. AddMenuSeparator(Menu);
  992. TStringList * UsedEditors = new TStringList();
  993. try
  994. {
  995. UsedEditors->CaseSensitive = false;
  996. UsedEditors->Sorted = true;
  997. bool AnyExternal = false;
  998. const TEditorList * EditorList = WinConfiguration->EditorList;
  999. for (int Index = 0; Index < EditorList->Count; Index++)
  1000. {
  1001. const TEditorPreferences * Editor = EditorList->Editors[Index];
  1002. if ((Editor->Data.Editor == edExternal) &&
  1003. (UsedEditors->IndexOf(Editor->Data.ExternalEditor) < 0))
  1004. {
  1005. UsedEditors->Add(Editor->Data.ExternalEditor);
  1006. TTBCustomItem * Item = new TTBXItem(Menu);
  1007. Item->Caption = Editor->Name;
  1008. Item->Tag = Index;
  1009. Item->Hint = FMTLOAD(EXTERNAL_EDITOR_HINT, (Editor->Name));
  1010. Item->OnClick = EditorItemClick;
  1011. Menu->Add(Item);
  1012. AnyExternal = true;
  1013. }
  1014. }
  1015. if (AnyExternal)
  1016. {
  1017. AddMenuSeparator(Menu);
  1018. }
  1019. Item = new TTBXItem(Menu);
  1020. Item->Action = EditorListCustomizeAction;
  1021. Menu->Add(Item);
  1022. for (int Index = 0; Index < PrevCount; Index++)
  1023. {
  1024. Menu->Delete(0);
  1025. }
  1026. }
  1027. __finally
  1028. {
  1029. delete UsedEditors;
  1030. }
  1031. }
  1032. }
  1033. //---------------------------------------------------------------------------
  1034. void __fastcall TNonVisualDataModule::EditorItemClick(TObject * Sender)
  1035. {
  1036. int Tag = dynamic_cast<TTBXItem*>(Sender)->Tag;
  1037. if (Tag < 0)
  1038. {
  1039. ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, false);
  1040. }
  1041. else
  1042. {
  1043. const TEditorList * EditorList = WinConfiguration->EditorList;
  1044. // sanity check
  1045. if (Tag < EditorList->Count)
  1046. {
  1047. ScpExplorer->ExecuteFile(osCurrent, efExternalEditor, EditorList->Editors[Tag],
  1048. true, false);
  1049. }
  1050. }
  1051. }
  1052. //---------------------------------------------------------------------------
  1053. void __fastcall TNonVisualDataModule::QueuePopupPopup(TObject * /*Sender*/)
  1054. {
  1055. TAction * Action = NULL;
  1056. switch (ScpExplorer->DefaultQueueOperation())
  1057. {
  1058. case qoItemQuery:
  1059. Action = QueueItemQueryAction;
  1060. break;
  1061. case qoItemError:
  1062. Action = QueueItemErrorAction;
  1063. break;
  1064. case qoItemPrompt:
  1065. Action = QueueItemPromptAction;
  1066. break;
  1067. case qoItemExecute:
  1068. Action = QueueItemExecuteAction;
  1069. break;
  1070. case qoItemPause:
  1071. Action = QueueItemPauseAction;
  1072. break;
  1073. case qoItemResume:
  1074. Action = QueueItemResumeAction;
  1075. break;
  1076. }
  1077. TTBCustomItem * Item;
  1078. for (int Index = 0; Index < QueuePopup->Items->Count; Index++)
  1079. {
  1080. Item = QueuePopup->Items->Items[Index];
  1081. TTBItemOptions O = Item->Options;
  1082. if ((Action != NULL) && (Item->Action == Action))
  1083. {
  1084. O << tboDefault;
  1085. }
  1086. else
  1087. {
  1088. O >> tboDefault;
  1089. }
  1090. Item->Options = O;
  1091. }
  1092. }
  1093. //---------------------------------------------------------------------------
  1094. void __fastcall TNonVisualDataModule::ShowUpdatesUpdate()
  1095. {
  1096. TUpdatesConfiguration Updates = WinConfiguration->Updates;
  1097. unsigned short H, M, S, MS;
  1098. DecodeTime(Now(), H, M, S, MS);
  1099. TVSFixedFileInfo * FileInfo = Configuration->FixedApplicationInfo;
  1100. int CurrentCompoundVer = CalculateCompoundVersion(
  1101. HIWORD(FileInfo->dwFileVersionMS), LOWORD(FileInfo->dwFileVersionMS),
  1102. HIWORD(FileInfo->dwFileVersionLS), LOWORD(FileInfo->dwFileVersionLS));
  1103. ShowUpdatesAction->ImageIndex =
  1104. ((Updates.HaveResults && (Updates.Results.ForVersion == CurrentCompoundVer) &&
  1105. ((Updates.Results.Critical && !Updates.ShownResults && (MS >= 500)) ||
  1106. ((!Updates.Results.Critical || Updates.ShownResults) &&
  1107. ((Updates.Results.Version > CurrentCompoundVer) ||
  1108. !Updates.Results.Message.IsEmpty())))) ? 80 :
  1109. ((int(Updates.Period) <= 0) ? 81 : 63));
  1110. }
  1111. //---------------------------------------------------------------------------
  1112. void __fastcall TNonVisualDataModule::PreferencesDialog(TPreferencesMode APreferencesMode)
  1113. {
  1114. if (ScpExplorer != NULL)
  1115. {
  1116. ScpExplorer->PreferencesDialog(APreferencesMode);
  1117. }
  1118. else
  1119. {
  1120. DoPreferencesDialog(APreferencesMode);
  1121. }
  1122. }