NonVisual.cpp.bak 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  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 <Log.h>
  9. #include <Interface.h>
  10. #include "WinConfiguration.h"
  11. #include "TerminalManager.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma resource "*.dfm"
  15. TNonVisualDataModule *NonVisualDataModule;
  16. //---------------------------------------------------------------------------
  17. #define SCPCOMMANDER ((TScpCommanderForm *)ScpExplorer)
  18. #define UPDEX(HandleAction, Condition, OtherEnabled, OtherDisabled) if (Action == HandleAction) { \
  19. ((TCustomAction *)Action)->Enabled = (Condition); \
  20. if (((TCustomAction *)Action)->Enabled) { OtherEnabled; } else { OtherDisabled; }; \
  21. Handled = true; } else
  22. #define UPD(HandleAction, Condition) if (Action == HandleAction) { \
  23. ((TCustomAction *)Action)->Enabled = (Condition); Handled = true; } else
  24. #define EXE(HandleAction, Command) if (Action == HandleAction) { \
  25. Command; Handled = true; } else
  26. #define UPDACT(HandleAction, Command) EXE(HandleAction, Command)
  27. #define UPDCOMP(COMP) if (Action == COMP ## Action) { COMP ## Action->Enabled = true; \
  28. COMP ## Action->Checked = ScpExplorer->ComponentVisible[fc ## COMP]; Handled = true; } else
  29. #define EXECOMP(COMP) EXE(COMP ## Action, \
  30. ScpExplorer->ComponentVisible[fc ## COMP] = !ScpExplorer->ComponentVisible[fc ## COMP] )
  31. #define COLPROPS(SIDE) \
  32. ((TCustomDirViewColProperties*)ScpExplorer->DirView(os ## SIDE)->ColProperties)
  33. #define UPDSORT(SIDE, PREFIX, COL) if (Action == SIDE ## SortBy ## COL ## Action) { \
  34. SIDE ## SortBy ## COL ## Action->Enabled = true; Handled = true; \
  35. SIDE ## SortBy ## COL ## Action->Checked = (COLPROPS(SIDE)->SortColumn == PREFIX ## COL); } else
  36. #define EXESORT(SIDE, PREFIX, COL) EXE(SIDE ## SortBy ## COL ## Action, \
  37. if (COLPROPS(SIDE)->SortColumn == PREFIX ## COL) \
  38. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; \
  39. else COLPROPS(SIDE)->SortColumn = PREFIX ## COL )
  40. #define UPDSORTA(SIDE) if (Action == SIDE ## SortAscendingAction) { \
  41. SIDE ## SortAscendingAction->Enabled = true; Handled = true; \
  42. SIDE ## SortAscendingAction->Checked = COLPROPS(SIDE)->SortAscending; } else
  43. #define EXESORTA(SIDE) EXE(SIDE ## SortAscendingAction, \
  44. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; )
  45. #define UPDSORTC(LPREFIX, LCOL, RPREFIX, RCOL) if (Action == CurrentSortBy ## RCOL ## Action) { \
  46. CurrentSortBy ## RCOL ## Action->Enabled = ScpExplorer->AllowedAction((TAction *)Action, aaShortCut); \
  47. if (CurrentSortBy ## RCOL ## Action->Enabled) { \
  48. if (ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) \
  49. CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == RPREFIX ## RCOL); \
  50. else CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == LPREFIX ## LCOL); \
  51. } else CurrentSortBy ## RCOL ## Action->Checked = false; Handled = true; } else
  52. #define EXESORTC(COL, LCOL, RCOL) \
  53. EXE(CurrentSortBy ## COL ## Action, \
  54. Integer NewSortCol = \
  55. ((ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) ? RCOL : LCOL); \
  56. if (COLPROPS(Current)->SortColumn == NewSortCol) \
  57. COLPROPS(Current)->SortAscending = !COLPROPS(Current)->SortAscending; \
  58. else COLPROPS(Current)->SortColumn = NewSortCol \
  59. )
  60. #define UPDSHCOL(SIDE, PREFIX, COL) \
  61. EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
  62. ShowHide ## SIDE ## COL ## ColumnAction->Checked = COLPROPS(SIDE)->Visible[PREFIX ## COL])
  63. #define EXESHCOL(SIDE, PREFIX, COL) \
  64. EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
  65. COLPROPS(SIDE)->Visible[PREFIX ## COL] = !COLPROPS(SIDE)->Visible[PREFIX ## COL])
  66. //---------------------------------------------------------------------------
  67. __fastcall TNonVisualDataModule::TNonVisualDataModule(TComponent* Owner)
  68. : TDataModule(Owner)
  69. {
  70. FListColumn = NULL;
  71. FSessionIdleTimerExecuting = false;
  72. FIdle = true;
  73. }
  74. //---------------------------------------------------------------------------
  75. void __fastcall TNonVisualDataModule::LogActionsUpdate(
  76. TBasicAction *Action, bool &Handled)
  77. {
  78. TLogMemo * LogMemo = TTerminalManager::Instance()->LogMemo;
  79. bool ValidLogMemo = LogMemo && LogMemo->Parent;
  80. UPD(LogClearAction, ValidLogMemo && LogMemo->Lines->Count)
  81. UPD(LogSelectAllAction, ValidLogMemo && LogMemo->Lines->Count &&
  82. LogMemo->SelLength != LogMemo->Lines->Text.Length())
  83. UPD(LogCopyAction, ValidLogMemo && LogMemo->SelLength)
  84. UPD(LogCloseAction, Configuration->Logging && (WinConfiguration->LogView == lvWindow))
  85. ;
  86. }
  87. //---------------------------------------------------------------------------
  88. void __fastcall TNonVisualDataModule::LogActionsExecute(
  89. TBasicAction *Action, bool &Handled)
  90. {
  91. assert(FIdle);
  92. FIdle = false;
  93. try
  94. {
  95. TLogMemo * LogMemo = TTerminalManager::Instance()->LogMemo;
  96. assert(LogMemo && LogMemo->Parent);
  97. EXE(LogClearAction, LogMemo->SessionLog->Clear())
  98. EXE(LogSelectAllAction, LogMemo->SelectAll())
  99. EXE(LogCopyAction, LogMemo->CopyToClipboard())
  100. EXE(LogCloseAction, WinConfiguration->LogView = lvNone)
  101. ;
  102. }
  103. __finally
  104. {
  105. FIdle = true;
  106. }
  107. DoIdle();
  108. }
  109. //---------------------------------------------------------------------------
  110. void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
  111. TBasicAction *Action, bool &Handled)
  112. {
  113. if (!ScpExplorer || !ScpExplorer->AllowedAction((TAction *)Action, aaUpdate))
  114. {
  115. ((TAction *)Action)->Enabled = false;
  116. Handled = true;
  117. return;
  118. }
  119. // CURRENT DIRVIEW
  120. bool EnableSelectedOperation = ScpExplorer->EnableSelectedOperation[osCurrent];
  121. bool EnableFocusedOperation = ScpExplorer->EnableFocusedOperation[osCurrent];
  122. // focused operation
  123. UPD(CurrentCopyFocusedAction, EnableFocusedOperation)
  124. UPD(CurrentMoveFocusedAction, EnableFocusedOperation)
  125. UPD(CurrentDeleteFocusedAction, EnableFocusedOperation)
  126. UPD(CurrentPropertiesFocusedAction, EnableFocusedOperation)
  127. UPD(RemoteMoveToFocusedAction, EnableFocusedOperation && (DirView(osRemote) == DirView(osCurrent)))
  128. // file operation
  129. UPD(CurrentRenameAction, EnableFocusedOperation &&
  130. ((ScpExplorer->HasDirView[osLocal] && DirView(osLocal) == DirView(osCurrent)) ||
  131. ScpExplorer->Terminal->IsCapable[fcRename]))
  132. UPD(CurrentEditAction, EnableFocusedOperation &&
  133. !WinConfiguration->DisableOpenEdit &&
  134. !DirView(osCurrent)->ItemIsDirectory(DirView(osCurrent)->ItemFocused))
  135. UPD(CurrentEditAlternativeAction, EnableFocusedOperation &&
  136. !WinConfiguration->DisableOpenEdit &&
  137. !DirView(osCurrent)->ItemIsDirectory(DirView(osCurrent)->ItemFocused) &&
  138. (WinConfiguration->Editor.Editor == edExternal || !WinConfiguration->Editor.ExternalEditor.IsEmpty()))
  139. UPD(CurrentOpenAction, EnableFocusedOperation &&
  140. !WinConfiguration->DisableOpenEdit &&
  141. !DirView(osCurrent)->ItemIsDirectory(DirView(osCurrent)->ItemFocused))
  142. UPD(AddEditLinkAction, ScpExplorer->Terminal &&
  143. (DirView(osCurrent) != DirView(osRemote) ||
  144. (ScpExplorer->Terminal->IsCapable[fcResolveSymlink] &&
  145. ScpExplorer->Terminal->IsCapable[fcSymbolicLink])))
  146. // selected operaton
  147. UPD(CurrentCopyAction, EnableSelectedOperation)
  148. UPD(CurrentMoveAction, EnableSelectedOperation)
  149. UPD(CurrentDeleteAction, EnableSelectedOperation)
  150. UPD(CurrentPropertiesAction, EnableSelectedOperation)
  151. UPD(RemoteMoveToAction, EnableSelectedOperation && (DirView(osRemote) == DirView(osCurrent)))
  152. UPD(FileListToCommandLineAction, EnableSelectedOperation &&
  153. ((DirView(osLocal) == DirView(osCurrent)) || ScpExplorer->Terminal->IsCapable[fcAnyCommand]))
  154. UPD(FileListToClipboardAction, EnableSelectedOperation)
  155. UPD(FullFileListToClipboardAction, EnableSelectedOperation)
  156. // directory
  157. UPD(CurrentCreateDirAction, true)
  158. // selection
  159. UPD(SelectOneAction, DirView(osCurrent)->FilesCount)
  160. UPD(SelectAction, DirView(osCurrent)->FilesCount)
  161. UPD(UnselectAction, DirView(osCurrent)->SelCount)
  162. UPD(SelectAllAction, DirView(osCurrent)->FilesCount)
  163. UPD(InvertSelectionAction, DirView(osCurrent)->FilesCount)
  164. UPD(ClearSelectionAction, DirView(osCurrent)->SelCount)
  165. UPD(PasteAction, DirView(osCurrent)->CanPasteFromClipBoard())
  166. //style
  167. UPDACT(CurrentCycleStyleAction,
  168. CurrentCycleStyleAction->ImageIndex = 8 + (DirView(osCurrent)->ViewStyle + 1) % 4)
  169. #define STYLEACTION(Style) UPDACT(Current ## Style ## Action, \
  170. Current ## Style ## Action->Checked = (DirView(osCurrent)->ViewStyle == vs ## Style))
  171. STYLEACTION(Icon)
  172. STYLEACTION(SmallIcon)
  173. STYLEACTION(List)
  174. STYLEACTION(Report)
  175. #undef STYLEACTION
  176. // REMOTE+LOCAL
  177. // back/forward
  178. #define HISTORYACTION(SIDE, DIRECTION, HINTFMT, DELTA) \
  179. UPDEX(SIDE ## DIRECTION ## Action, (DirView(os ## SIDE)->DIRECTION ## Count > 0), \
  180. SIDE ## DIRECTION ## Action->Hint = FMTLOAD(HINTFMT, (DirView(os ## SIDE)->HistoryPath[DELTA])), \
  181. SIDE ## DIRECTION ## Action->Hint = "")
  182. HISTORYACTION(Local, Back, EXPLORER_BACK_HINT, -1)
  183. HISTORYACTION(Local, Forward, EXPLORER_FORWARD_HINT, 1)
  184. HISTORYACTION(Remote, Back, EXPLORER_BACK_HINT, -1)
  185. HISTORYACTION(Remote, Forward, EXPLORER_FORWARD_HINT, 1)
  186. #undef HISTORYACTION
  187. #define PANEL_ACTIONS(SIDE) \
  188. UPD(SIDE ## ParentDirAction, !DirView(os ## SIDE)->IsRoot) \
  189. UPD(SIDE ## RootDirAction, !DirView(os ## SIDE)->IsRoot) \
  190. UPD(SIDE ## HomeDirAction, true) \
  191. UPD(SIDE ## RefreshAction, DirView(os ## SIDE)->DirOK) \
  192. UPD(SIDE ## OpenDirAction, true) \
  193. UPD(SIDE ## ChangePathAction, true) \
  194. UPD(SIDE ## AddBookmarkAction, true) \
  195. UPD(SIDE ## PathToClipboardAction, true)
  196. PANEL_ACTIONS(Local)
  197. PANEL_ACTIONS(Remote)
  198. #undef PANEL_ACTIONS
  199. UPD(LocalExploreDirectoryAction, true)
  200. // HELP
  201. UPD(AboutAction, true)
  202. UPD(HomepageAction, true)
  203. UPD(HistoryPageAction, true)
  204. UPD(RequirementsPageAction, true)
  205. UPD(ForumPageAction, true)
  206. UPD(CheckForUpdatesAction, true)
  207. UPD(DonatePageAction, true)
  208. // VIEW
  209. UPDCOMP(StatusBar)
  210. UPDCOMP(ToolBar)
  211. UPDCOMP(LocalStatusBar)
  212. UPDCOMP(RemoteStatusBar)
  213. UPDCOMP(CommandLinePanel)
  214. UPDCOMP(RemoteTree)
  215. UPDCOMP(LocalTree)
  216. UPDCOMP(ExplorerMenuBand)
  217. UPDCOMP(ExplorerAddressBand)
  218. UPDCOMP(ExplorerToolbarBand)
  219. UPDCOMP(ExplorerSelectionBand)
  220. UPDCOMP(ExplorerSessionBand)
  221. UPDCOMP(ExplorerPreferencesBand)
  222. UPDCOMP(ExplorerSortBand)
  223. UPDCOMP(CommanderMenuBand)
  224. UPDCOMP(CommanderSessionBand)
  225. UPDCOMP(CommanderPreferencesBand)
  226. UPDCOMP(CommanderSelectionBand)
  227. UPDCOMP(CommanderToolbarBand)
  228. UPDCOMP(CommanderSortBand)
  229. UPDCOMP(CommanderCommandsBand)
  230. UPDCOMP(CommanderLocalHistoryBand)
  231. UPDCOMP(CommanderLocalNavigationBand)
  232. UPDCOMP(CommanderRemoteHistoryBand)
  233. UPDCOMP(CommanderRemoteNavigationBand)
  234. UPD(GoToCommandLineAction, true)
  235. UPD(GoToTreeAction, true)
  236. UPDEX(ViewLogAction, Configuration->Logging,
  237. ViewLogAction->Checked = (WinConfiguration->LogView == lvWindow),
  238. ViewLogAction->Checked = false )
  239. UPDEX(ShowHiddenFilesAction, true,
  240. ShowHiddenFilesAction->Checked = WinConfiguration->ShowHiddenFiles, )
  241. UPD(PreferencesAction, true)
  242. // SORT
  243. UPDSORTA(Local)
  244. UPDSORT(Local, dv, Name)
  245. UPDSORT(Local, dv, Ext)
  246. UPDSORT(Local, dv, Size)
  247. UPDSORT(Local, dv, Type)
  248. UPDSORT(Local, dv, Changed)
  249. UPDSORT(Local, dv, Attr)
  250. UPDSORTA(Remote)
  251. UPDSORT(Remote, uv, Name)
  252. UPDSORT(Remote, uv, Ext)
  253. UPDSORT(Remote, uv, Size)
  254. UPDSORT(Remote, uv, Changed)
  255. UPDSORT(Remote, uv, Rights)
  256. UPDSORT(Remote, uv, Owner)
  257. UPDSORT(Remote, uv, Group)
  258. UPDSORTA(Current)
  259. UPDSORTC(dv, Name, uv, Name)
  260. UPDSORTC(dv, Ext, uv, Ext)
  261. UPDSORTC(dv, Size, uv, Size)
  262. #define uvType uvName /* no type columns on remote panel */
  263. UPDSORTC(dv, Type, uv, Type)
  264. #undef uvType
  265. UPDSORTC(dv, Changed, uv, Changed)
  266. UPDSORTC(dv, Attr, uv, Rights)
  267. UPDSORTC(dv, Name, uv, Owner)
  268. UPDSORTC(dv, Name, uv, Group)
  269. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  270. UPDEX(SortColumnAscendingAction, (ListColumn != NULL), SortColumnAscendingAction->Checked =
  271. (COLVIEWPROPS->SortColumn == ListColumn->Index) && COLVIEWPROPS->SortAscending, /*assert(false)*/ )
  272. UPDEX(SortColumnDescendingAction, (ListColumn != NULL), SortColumnDescendingAction->Checked =
  273. (COLVIEWPROPS->SortColumn == ListColumn->Index) && !COLVIEWPROPS->SortAscending, /*assert(false)*/ )
  274. #undef COLVIEWPROPS
  275. // SHOW/HIDE COLUMN
  276. UPDSHCOL(Local, dv, Name)
  277. UPDSHCOL(Local, dv, Ext)
  278. UPDSHCOL(Local, dv, Size)
  279. UPDSHCOL(Local, dv, Type)
  280. UPDSHCOL(Local, dv, Changed)
  281. UPDSHCOL(Local, dv, Attr)
  282. UPDSHCOL(Remote, uv, Name)
  283. UPDSHCOL(Remote, uv, Ext)
  284. UPDSHCOL(Remote, uv, Size)
  285. UPDSHCOL(Remote, uv, Changed)
  286. UPDSHCOL(Remote, uv, Rights)
  287. UPDSHCOL(Remote, uv, Owner)
  288. UPDSHCOL(Remote, uv, Group)
  289. UPD(HideColumnAction, (ListColumn != NULL))
  290. // SESSION
  291. UPD(NewSessionAction, true)
  292. UPD(CloseSessionAction, true)
  293. UPD(SavedSessionsAction, (StoredSessions->Count > 0))
  294. UPD(OpenedSessionsAction, true)
  295. UPD(SaveCurrentSessionAction, true)
  296. // COMMAND
  297. UPD(CompareDirectoriesAction, true)
  298. UPD(SynchronizeAction, true)
  299. UPD(FullSynchronizeAction, true)
  300. UPD(ConsoleAction, ScpExplorer->Terminal && ScpExplorer->Terminal->IsCapable[fcAnyCommand])
  301. UPD(PuttyAction, true)
  302. UPD(SynchronizeBrowsingAction, true)
  303. UPD(CloseApplicationAction, true)
  304. UPD(FileSystemInfoAction, true)
  305. UPD(ClearCachesAction, (ScpExplorer->Terminal != NULL) && !ScpExplorer->Terminal->AreCachesEmpty)
  306. // CUSTOM COMMANDS
  307. UPD(CustomCommandsAction,
  308. (ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) &&
  309. ScpExplorer->Terminal && ScpExplorer->Terminal->IsCapable[fcAnyCommand])
  310. UPD(CustomCommandsCustomizeAction, true)
  311. // QUEUE
  312. #define UPDQUEUE(OPERATION) UPD(Queue ## OPERATION ## Action, \
  313. ScpExplorer->AllowQueueOperation(qo ## OPERATION))
  314. UPDQUEUE(GoTo)
  315. UPDQUEUE(Preferences)
  316. UPDEX(QueueItemQueryAction, ScpExplorer->AllowQueueOperation(qoItemQuery),
  317. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  318. UPDEX(QueueItemErrorAction, ScpExplorer->AllowQueueOperation(qoItemError),
  319. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  320. UPDEX(QueueItemPromptAction, ScpExplorer->AllowQueueOperation(qoItemPrompt),
  321. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  322. UPDQUEUE(ItemDelete)
  323. UPDQUEUE(ItemExecute)
  324. UPDQUEUE(ItemUp)
  325. UPDQUEUE(ItemDown)
  326. #undef UPDQUEUE
  327. UPDACT(QueueToggleShowAction,
  328. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueView])
  329. #define QUEUEACTION(SHOW) UPDACT(Queue ## SHOW ## Action, \
  330. ((TAction *)Action)->Checked = WinConfiguration->QueueView.Show == qv ## SHOW)
  331. QUEUEACTION(Show)
  332. QUEUEACTION(HideWhenEmpty)
  333. QUEUEACTION(Hide)
  334. #undef QUEUEACTION
  335. UPDCOMP(CommanderPreferencesBand)
  336. UPDACT(QueueToolbarAction,
  337. ((TAction *)Action)->Enabled = ScpExplorer->ComponentVisible[fcQueueView];
  338. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueToolbar]);
  339. ;
  340. }
  341. //---------------------------------------------------------------------------
  342. void __fastcall TNonVisualDataModule::ExplorerActionsExecute(
  343. TBasicAction *Action, bool &Handled)
  344. {
  345. assert(ScpExplorer);
  346. if (!ScpExplorer->AllowedAction((TAction *)Action, aaExecute))
  347. {
  348. Handled = true;
  349. return;
  350. }
  351. assert(FIdle);
  352. FIdle = false;
  353. try
  354. {
  355. // focused operation
  356. EXE(CurrentCopyFocusedAction, ScpExplorer->ExecuteFileOperation(foCopy, osCurrent, true))
  357. EXE(CurrentMoveFocusedAction, ScpExplorer->ExecuteFileOperation(foMove, osCurrent, true))
  358. EXE(CurrentDeleteFocusedAction, ScpExplorer->ExecuteFileOperation(foDelete, osCurrent, true))
  359. EXE(CurrentPropertiesFocusedAction, ScpExplorer->ExecuteFileOperation(foSetProperties, osCurrent, true))
  360. EXE(RemoteMoveToFocusedAction, ScpExplorer->ExecuteFileOperation(foRemoteMove, osCurrent, true))
  361. // operation
  362. EXE(CurrentCopyAction, ScpExplorer->ExecuteFileOperation(foCopy, osCurrent, false))
  363. EXE(CurrentMoveAction, ScpExplorer->ExecuteFileOperation(foMove, osCurrent, false))
  364. EXE(CurrentEditAction, ScpExplorer->ExecuteFile(osCurrent, efEditor))
  365. EXE(CurrentEditAlternativeAction, ScpExplorer->ExecuteFile(osCurrent, efAlternativeEditor))
  366. EXE(CurrentOpenAction, ScpExplorer->ExecuteCurrentFile())
  367. EXE(AddEditLinkAction, ScpExplorer->AddEditLink())
  368. EXE(CurrentRenameAction, ScpExplorer->ExecuteFileOperation(foRename, osCurrent, false))
  369. EXE(CurrentDeleteAction, ScpExplorer->ExecuteFileOperation(foDelete, osCurrent, false))
  370. EXE(CurrentPropertiesAction, ScpExplorer->ExecuteFileOperation(foSetProperties, osCurrent, false))
  371. EXE(RemoteMoveToAction, ScpExplorer->ExecuteFileOperation(foRemoteMove, osCurrent, false))
  372. EXE(FileListToCommandLineAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedCommandLine))
  373. EXE(FileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedClipboard))
  374. EXE(FullFileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFullFileList, pedClipboard))
  375. // directory
  376. EXE(CurrentCreateDirAction, ScpExplorer->CreateDirectory(osCurrent))
  377. //selection
  378. EXE(SelectOneAction, DirView(osCurrent)->SelectCurrentItem(DirView(osCurrent)->NortonLike))
  379. EXE(SelectAction, DirView(osCurrent)->DoSelectByMask(true))
  380. EXE(UnselectAction, DirView(osCurrent)->DoSelectByMask(false))
  381. EXE(SelectAllAction, DirView(osCurrent)->SelectAll(smAll))
  382. EXE(InvertSelectionAction, DirView(osCurrent)->SelectAll(smInvert))
  383. EXE(ClearSelectionAction, DirView(osCurrent)->SelectAll(smNone))
  384. EXE(PasteAction, DirView(osCurrent)->PasteFromClipBoard())
  385. // style
  386. EXE(CurrentCycleStyleAction,
  387. if (DirView(osCurrent)->ViewStyle == vsReport) DirView(osCurrent)->ViewStyle = vsIcon;
  388. else DirView(osCurrent)->ViewStyle = (TViewStyle)(DirView(osCurrent)->ViewStyle + 1);
  389. )
  390. #define STYLEACTION(Style) EXE(Current ## Style ## Action, \
  391. DirView(osCurrent)->ViewStyle = vs ## Style)
  392. STYLEACTION(Icon)
  393. STYLEACTION(SmallIcon)
  394. STYLEACTION(List)
  395. STYLEACTION(Report)
  396. #undef STYLEACTION
  397. #define PANEL_ACTIONS(SIDE) \
  398. EXE(SIDE ## BackAction, DirView(os ## SIDE)->HistoryGo(-1)) \
  399. EXE(SIDE ## ForwardAction, DirView(os ## SIDE)->HistoryGo(1)) \
  400. EXE(SIDE ## ParentDirAction, DirView(os ## SIDE)->ExecuteParentDirectory()) \
  401. EXE(SIDE ## RootDirAction, DirView(os ## SIDE)->ExecuteRootDirectory()) \
  402. EXE(SIDE ## HomeDirAction, DirView(os ## SIDE)->ExecuteHomeDirectory()) \
  403. EXE(SIDE ## RefreshAction, DirView(os ## SIDE)->ReloadDirectory()) \
  404. EXE(SIDE ## OpenDirAction, ScpExplorer->OpenDirectory(os ## SIDE)) \
  405. EXE(SIDE ## ChangePathAction, ScpExplorer->ChangePath(os ## SIDE)) \
  406. EXE(SIDE ## AddBookmarkAction, ScpExplorer->AddBookmark(os ## SIDE)) \
  407. EXE(SIDE ## PathToClipboardAction, ScpExplorer->PanelExport(os ## SIDE, pePath, pedClipboard))
  408. PANEL_ACTIONS(Local)
  409. PANEL_ACTIONS(Remote)
  410. #undef PANEL_ACTIONS
  411. EXE(LocalExploreDirectoryAction, ScpExplorer->ExploreLocalDirectory())
  412. //HELP
  413. EXE(AboutAction, DoAboutDialog(Configuration))
  414. EXE(HomepageAction, OpenBrowser(LoadStr(HOMEPAGE_URL)))
  415. EXE(HistoryPageAction, OpenBrowser(LoadStr(HISTORY_URL)))
  416. EXE(RequirementsPageAction, OpenBrowser(LoadStr(REQUIREMENTS_URL)))
  417. EXE(ForumPageAction, OpenBrowser(LoadStr(FORUM_URL)))
  418. EXE(CheckForUpdatesAction, CheckForUpdates())
  419. EXE(DonatePageAction, OpenBrowser(LoadStr(DONATE_URL)))
  420. // VIEW
  421. EXECOMP(StatusBar)
  422. EXECOMP(ToolBar)
  423. EXECOMP(LocalStatusBar)
  424. EXECOMP(RemoteStatusBar)
  425. EXECOMP(ExplorerMenuBand)
  426. EXECOMP(ExplorerAddressBand)
  427. EXECOMP(ExplorerToolbarBand)
  428. EXECOMP(ExplorerSelectionBand)
  429. EXECOMP(ExplorerSessionBand)
  430. EXECOMP(ExplorerPreferencesBand)
  431. EXECOMP(ExplorerSortBand)
  432. EXECOMP(CommanderMenuBand)
  433. EXECOMP(CommanderSessionBand)
  434. EXECOMP(CommanderPreferencesBand)
  435. EXECOMP(CommanderSelectionBand)
  436. EXECOMP(CommanderToolbarBand)
  437. EXECOMP(CommanderSortBand)
  438. EXECOMP(CommanderCommandsBand)
  439. EXECOMP(CommanderLocalHistoryBand)
  440. EXECOMP(CommanderLocalNavigationBand)
  441. EXECOMP(CommanderRemoteHistoryBand)
  442. EXECOMP(CommanderRemoteNavigationBand)
  443. EXECOMP(CommandLinePanel)
  444. EXECOMP(RemoteTree)
  445. EXECOMP(LocalTree)
  446. EXE(GoToCommandLineAction, ScpExplorer->GoToCommandLine())
  447. EXE(GoToTreeAction, ScpExplorer->GoToTree())
  448. EXE(ViewLogAction, WinConfiguration->LogView =
  449. (WinConfiguration->LogView == lvNone ? lvWindow : lvNone) )
  450. EXE(ShowHiddenFilesAction, WinConfiguration->ShowHiddenFiles = !WinConfiguration->ShowHiddenFiles)
  451. EXE(PreferencesAction, DoPreferencesDialog(pmDefault) )
  452. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  453. // SORT
  454. EXESORTA(Local)
  455. EXESORT(Local, dv, Name)
  456. EXESORT(Local, dv, Ext)
  457. EXESORT(Local, dv, Size)
  458. EXESORT(Local, dv, Type)
  459. EXESORT(Local, dv, Changed)
  460. EXESORT(Local, dv, Attr)
  461. EXESORTA(Remote)
  462. EXESORT(Remote, uv, Name)
  463. EXESORT(Remote, uv, Ext)
  464. EXESORT(Remote, uv, Size)
  465. EXESORT(Remote, uv, Changed)
  466. EXESORT(Remote, uv, Rights)
  467. EXESORT(Remote, uv, Owner)
  468. EXESORT(Remote, uv, Group)
  469. EXESORTA(Current)
  470. EXESORTC(Name, dvName, uvName)
  471. EXESORTC(Ext, dvExt, uvExt)
  472. EXESORTC(Size, dvSize, uvSize)
  473. EXESORTC(Type, dvType, uvName)
  474. EXESORTC(Changed, dvChanged, uvChanged)
  475. EXESORTC(Rights, dvAttr, uvRights)
  476. EXESORTC(Owner, dvName, uvOwner)
  477. EXESORTC(Group, dvName, uvGroup)
  478. EXE(SortColumnAscendingAction, assert(ListColumn);
  479. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = true; ListColumn = NULL )
  480. EXE(SortColumnDescendingAction, assert(ListColumn);
  481. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = false; ListColumn = NULL )
  482. // SHOW/HIDE COLUMN
  483. EXESHCOL(Local, dv, Name)
  484. EXESHCOL(Local, dv, Ext)
  485. EXESHCOL(Local, dv, Size)
  486. EXESHCOL(Local, dv, Type)
  487. EXESHCOL(Local, dv, Changed)
  488. EXESHCOL(Local, dv, Attr)
  489. EXESHCOL(Remote, uv, Name)
  490. EXESHCOL(Remote, uv, Ext)
  491. EXESHCOL(Remote, uv, Size)
  492. EXESHCOL(Remote, uv, Changed)
  493. EXESHCOL(Remote, uv, Rights)
  494. EXESHCOL(Remote, uv, Owner)
  495. EXESHCOL(Remote, uv, Group)
  496. EXE(HideColumnAction, assert(ListColumn);
  497. COLVIEWPROPS->Visible[ListColumn->Index] = false; ListColumn = NULL )
  498. #undef COLVIEWPROPS
  499. // SESSION
  500. EXE(NewSessionAction, ScpExplorer->NewSession())
  501. EXE(CloseSessionAction, ScpExplorer->CloseSession())
  502. EXE(SavedSessionsAction, CreateSessionListMenu())
  503. EXE(OpenedSessionsAction, )
  504. EXE(SaveCurrentSessionAction, ScpExplorer->SaveCurrentSession())
  505. // COMMAND
  506. EXE(CompareDirectoriesAction, ScpExplorer->CompareDirectories())
  507. EXE(SynchronizeAction, ScpExplorer->SynchronizeDirectories())
  508. EXE(FullSynchronizeAction, ScpExplorer->FullSynchronizeDirectories())
  509. EXE(ConsoleAction, ScpExplorer->OpenConsole())
  510. EXE(PuttyAction, ScpExplorer->OpenInPutty())
  511. EXE(SynchronizeBrowsingAction, )
  512. EXE(CloseApplicationAction, ScpExplorer->Close())
  513. EXE(FileSystemInfoAction, DoFileSystemInfoDialog(ScpExplorer->Terminal))
  514. EXE(ClearCachesAction, ScpExplorer->Terminal->ClearCaches())
  515. // CUSTOM COMMANDS
  516. EXE(CustomCommandsAction, CreateCustomCommandsMenu(CustomCommandsAction))
  517. EXE(CustomCommandsCustomizeAction, DoPreferencesDialog(pmCustomCommands))
  518. // QUEUE
  519. #define EXEQUEUE(OPERATION) EXE(Queue ## OPERATION ## Action, \
  520. ScpExplorer->ExecuteQueueOperation(qo ## OPERATION))
  521. EXEQUEUE(GoTo)
  522. EXEQUEUE(Preferences)
  523. EXEQUEUE(ItemQuery)
  524. EXEQUEUE(ItemError)
  525. EXEQUEUE(ItemPrompt)
  526. EXEQUEUE(ItemDelete)
  527. EXEQUEUE(ItemExecute)
  528. EXEQUEUE(ItemUp)
  529. EXEQUEUE(ItemDown)
  530. #undef EXEQUEUE
  531. EXE(QueueToggleShowAction,
  532. TQueueViewConfiguration Config = WinConfiguration->QueueView;
  533. Config.Show = ScpExplorer->ComponentVisible[fcQueueView] ? qvHide : qvShow;
  534. WinConfiguration->QueueView = Config)
  535. #define QUEUEACTION(SHOW) EXE(Queue ## SHOW ## Action, \
  536. TQueueViewConfiguration Config = WinConfiguration->QueueView; \
  537. Config.Show = qv ## SHOW; WinConfiguration->QueueView = Config)
  538. QUEUEACTION(Show)
  539. QUEUEACTION(HideWhenEmpty)
  540. QUEUEACTION(Hide)
  541. #undef QUEUEACTION
  542. EXECOMP(QueueToolbar);
  543. ;
  544. }
  545. __finally
  546. {
  547. FIdle = true;
  548. }
  549. DoIdle();
  550. }
  551. //---------------------------------------------------------------------------
  552. void __fastcall TNonVisualDataModule::UpdateNonVisibleActions()
  553. {
  554. // following actions needs to be updated even when all clients
  555. // are invisible, so the queue list toolbar button can be shown
  556. NonVisualDataModule->QueueItemQueryAction->Update();
  557. NonVisualDataModule->QueueItemErrorAction->Update();
  558. NonVisualDataModule->QueueItemPromptAction->Update();
  559. }
  560. //---------------------------------------------------------------------------
  561. #define CTRL TShiftState() << ssCtrl
  562. #define ALT TShiftState() << ssAlt
  563. #define SHIFT TShiftState() << ssShift
  564. #define CTRLSHIFT TShiftState() << ssCtrl << ssShift
  565. #define CTRLALT TShiftState() << ssCtrl << ssAlt
  566. #define NONE TShiftState()
  567. void __fastcall TNonVisualDataModule::ExplorerShortcuts()
  568. {
  569. // Directory
  570. CurrentCreateDirAction->ShortCut = ShortCut('D', CTRL);
  571. // File operation
  572. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  573. CurrentEditAction->ShortCut = ShortCut('E', CTRL);
  574. CurrentEditAlternativeAction->ShortCut = ShortCut('E', CTRLSHIFT);
  575. AddEditLinkAction->ShortCut = ShortCut('L', CTRLALT);
  576. // Focused operation
  577. CurrentCopyFocusedAction->ShortCut = ShortCut('C', CTRL);
  578. CurrentMoveFocusedAction->ShortCut = ShortCut('M', CTRL);
  579. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_DELETE, NONE);
  580. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_RETURN, ALT);
  581. RemoteMoveToFocusedAction->ShortCut = ShortCut('M', CTRLALT);
  582. // remote directory
  583. RemoteOpenDirAction->ShortCut = ShortCut('O', CTRL);
  584. RemoteRefreshAction->ShortCut = ShortCut(VK_F5, NONE);
  585. RemoteHomeDirAction->ShortCut = ShortCut('H', CTRL);
  586. // selected operation
  587. CurrentCopyAction->ShortCut = CurrentCopyFocusedAction->ShortCut;
  588. CurrentMoveAction->ShortCut = CurrentMoveFocusedAction->ShortCut;
  589. CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
  590. CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
  591. RemoteMoveToAction->ShortCut = ShortCut('M', CTRLALT);
  592. // selection
  593. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  594. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  595. SelectAllAction->ShortCut = ShortCut('A', CTRL);
  596. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  597. ClearSelectionAction->ShortCut = ShortCut('L', CTRL);
  598. CloseApplicationAction->ShortCut = ShortCut(VK_F4, ALT);
  599. }
  600. //---------------------------------------------------------------------------
  601. void __fastcall TNonVisualDataModule::CommanderShortcuts()
  602. {
  603. // Directory
  604. CurrentCreateDirAction->ShortCut = ShortCut(VK_F7, NONE);
  605. // File operation
  606. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  607. CurrentEditAction->ShortCut = ShortCut(VK_F4, NONE);
  608. CurrentEditAlternativeAction->ShortCut = ShortCut(VK_F4, SHIFT);
  609. AddEditLinkAction->ShortCut = ShortCut(VK_F6, ALT);
  610. // Focused operation
  611. CurrentCopyFocusedAction->ShortCut = ShortCut(VK_F5, NONE);
  612. CurrentMoveFocusedAction->ShortCut = ShortCut(VK_F6, NONE);
  613. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_F8, NONE);
  614. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_F9, NONE);
  615. RemoteMoveToFocusedAction->ShortCut = ShortCut(VK_F6, SHIFT);
  616. // remote directory
  617. RemoteOpenDirAction->ShortCut = ShortCut('O', CTRL);
  618. RemoteRefreshAction->ShortCut = ShortCut('R', CTRL);
  619. RemoteHomeDirAction->ShortCut = ShortCut('H', CTRL);
  620. RemotePathToClipboardAction->ShortCut = ShortCut(VK_OEM_6 /* ] */, CTRL);
  621. // local directory
  622. LocalOpenDirAction->ShortCut = RemoteOpenDirAction->ShortCut;
  623. LocalRefreshAction->ShortCut = RemoteRefreshAction->ShortCut;
  624. LocalHomeDirAction->ShortCut = RemoteHomeDirAction->ShortCut;
  625. LocalPathToClipboardAction->ShortCut = ShortCut(VK_OEM_4 /* [ */, CTRL);
  626. // selected operation
  627. CurrentCopyAction->ShortCut = CurrentCopyFocusedAction->ShortCut;
  628. CurrentMoveAction->ShortCut = CurrentMoveFocusedAction->ShortCut;
  629. CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
  630. CurrentDeleteAction->SecondaryShortCuts->Clear();
  631. CurrentDeleteAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, NONE)));
  632. CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
  633. RemoteMoveToAction->ShortCut = ShortCut(VK_F6, SHIFT);
  634. // selection
  635. SelectOneAction->ShortCut = VK_INSERT;
  636. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  637. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  638. SelectAllAction->ShortCut = ShortCut('A', CTRL);
  639. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  640. ClearSelectionAction->ShortCut = ShortCut('L', CTRL);
  641. CloseApplicationAction->ShortCut = ShortCut(VK_F10, NONE);
  642. }
  643. #undef CTRL
  644. #undef ALT
  645. #undef NONE
  646. //---------------------------------------------------------------------------
  647. void __fastcall TNonVisualDataModule::SetScpExplorer(TCustomScpExplorerForm * value)
  648. {
  649. FScpExplorer = value;
  650. SessionIdleTimer->Enabled = (FScpExplorer != NULL);
  651. }
  652. //---------------------------------------------------------------------------
  653. void __fastcall TNonVisualDataModule::SessionIdleTimerTimer(
  654. TObject */*Sender*/)
  655. {
  656. DoIdle();
  657. }
  658. //---------------------------------------------------------------------------
  659. void __fastcall TNonVisualDataModule::DoIdle()
  660. {
  661. if (!FSessionIdleTimerExecuting)
  662. {
  663. FSessionIdleTimerExecuting = true;
  664. try
  665. {
  666. assert(ScpExplorer);
  667. ScpExplorer->Idle(FIdle);
  668. }
  669. __finally
  670. {
  671. FSessionIdleTimerExecuting = false;
  672. }
  673. }
  674. }
  675. //---------------------------------------------------------------------------
  676. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(TAction * Action)
  677. {
  678. assert(Action);
  679. TMenuItem * Menu = dynamic_cast<TMenuItem *>(Action->ActionComponent);
  680. if (Menu)
  681. {
  682. int PrevCount = Menu->Count;
  683. for (int Index = 0; Index < WinConfiguration->CustomCommands->Count; Index++)
  684. {
  685. AnsiString Description = WinConfiguration->CustomCommands->Names[Index];
  686. AnsiString Command = WinConfiguration->CustomCommands->Values[Description];
  687. TMenuItem * Item = new TMenuItem(Menu);
  688. Item->Caption = Description;
  689. Item->Tag = Index;
  690. if (Menu == RemoteDirViewCustomCommandsMenu)
  691. {
  692. Item->Tag = Item->Tag | 0x0100;
  693. }
  694. Item->Hint = FMTLOAD(CUSTOM_COMMAND_HINT,
  695. (StringReplace(Description, "&", "", TReplaceFlags() << rfReplaceAll)));
  696. Item->OnClick = CustomCommandClick;
  697. Menu->Add(Item);
  698. }
  699. TMenuItem * Item;
  700. if (WinConfiguration->CustomCommands->Count)
  701. {
  702. Item = new TMenuItem(Menu);
  703. Item->Caption = "-";
  704. Item->Hint = "E";
  705. Menu->Add(Item);
  706. }
  707. Item = new TMenuItem(Menu);
  708. Item->Action = CustomCommandsCustomizeAction;
  709. Menu->Add(Item);
  710. for (int Index = 0; Index < PrevCount; Index++)
  711. {
  712. Menu->Delete(0);
  713. }
  714. }
  715. }
  716. //---------------------------------------------------------------------------
  717. void __fastcall TNonVisualDataModule::CustomCommandClick(TObject * Sender)
  718. {
  719. TMenuItem * Item = dynamic_cast<TMenuItem *>(Sender);
  720. assert(Item);
  721. AnsiString CommandName;
  722. CommandName = WinConfiguration->CustomCommands->Names[Item->Tag & 0x00FF];
  723. ScpExplorer->ExecuteFileOperation(foCustomCommand, osRemote,
  724. (Item->Tag & 0xFF00) != 0, false, &CommandName);
  725. }
  726. //---------------------------------------------------------------------------
  727. void __fastcall TNonVisualDataModule::CreateSessionListMenu()
  728. {
  729. int PrevCount = SavedSessionsMenu->Count;
  730. StoredSessions->Load();
  731. for (int Index = 0; Index < StoredSessions->Count; Index++)
  732. {
  733. TSessionData * Data = StoredSessions->Sessions[Index];
  734. TMenuItem * Item = new TMenuItem(SavedSessionsMenu);
  735. Item->Caption = Data->Name;
  736. Item->Tag = Index;
  737. Item->Hint = FMTLOAD(SAVEDSESSION_HINT, (Data->Name));
  738. Item->OnClick = SessionItemClick;
  739. SavedSessionsMenu->Add(Item);
  740. }
  741. for (int Index = 0; Index < PrevCount; Index++)
  742. {
  743. SavedSessionsMenu->Delete(0);
  744. }
  745. }
  746. //---------------------------------------------------------------------------
  747. void __fastcall TNonVisualDataModule::SessionItemClick(TObject * Sender)
  748. {
  749. assert(StoredSessions && (((TMenuItem *)Sender)->Tag < StoredSessions->Count));
  750. ScpExplorer->OpenStoredSession(StoredSessions->Sessions[((TMenuItem *)Sender)->Tag]);
  751. }
  752. //---------------------------------------------------------------------------
  753. TShortCut __fastcall TNonVisualDataModule::OpenSessionShortCut(int Index)
  754. {
  755. if (Index >= 0 && Index < 10)
  756. {
  757. return ShortCut((Word)(Index < 9 ? '0' + 1 + Index : '0'),
  758. TShiftState() << ssAlt);
  759. }
  760. else
  761. {
  762. return scNone;
  763. }
  764. }
  765. //---------------------------------------------------------------------------
  766. void __fastcall TNonVisualDataModule::CreateOpenedSessionListMenu()
  767. {
  768. TTerminalManager * Manager = TTerminalManager::Instance();
  769. TStrings * TerminalList = Manager->TerminalList;
  770. int PrevCount = OpenedSessionsMenu->Count;
  771. for (int Index = 0; Index < TerminalList->Count; Index++)
  772. {
  773. TTerminal * Terminal = dynamic_cast<TTerminal *>(TerminalList->Objects[Index]);
  774. assert(Terminal);
  775. TMenuItem * Item = new TMenuItem(this);
  776. Item->Caption = TerminalList->Strings[Index];
  777. Item->Tag = int(Terminal);
  778. Item->Hint = FMTLOAD(OPENEDSESSION_HINT, (Item->Caption));
  779. Item->Checked = (Manager->ActiveTerminal == Terminal);
  780. Item->ShortCut = OpenSessionShortCut(Index);
  781. Item->OnClick = OpenedSessionItemClick;
  782. OpenedSessionsMenu->Add(Item);
  783. }
  784. for (int Index = 0; Index < PrevCount; Index++)
  785. {
  786. OpenedSessionsMenu->Delete(0);
  787. }
  788. }
  789. //---------------------------------------------------------------------------
  790. void __fastcall TNonVisualDataModule::OpenedSessionItemClick(TObject * Sender)
  791. {
  792. TTerminalManager::Instance()->ActiveTerminal = (TTerminal*)(((TMenuItem *)Sender)->Tag);
  793. }
  794. //---------------------------------------------------------------------------
  795. void __fastcall TNonVisualDataModule::OpenBrowser(AnsiString URL)
  796. {
  797. ShellExecute(Application->Handle, "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL);
  798. }
  799. //---------------------------------------------------------------------------
  800. void __fastcall TNonVisualDataModule::QueuePopupPopup(TObject * /*Sender*/)
  801. {
  802. TAction * Action = NULL;
  803. bool HideFirstLine = true;
  804. switch (ScpExplorer->DefaultQueueOperation())
  805. {
  806. case qoItemQuery:
  807. Action = QueueItemQueryAction;
  808. HideFirstLine = false;
  809. break;
  810. case qoItemError:
  811. Action = QueueItemErrorAction;
  812. HideFirstLine = false;
  813. break;
  814. case qoItemPrompt:
  815. Action = QueueItemPromptAction;
  816. HideFirstLine = false;
  817. break;
  818. case qoItemExecute:
  819. Action = QueueItemExecuteAction;
  820. break;
  821. }
  822. TMenuItem * Item;
  823. for (int Index = 0; Index < QueuePopup->Items->Count; Index++)
  824. {
  825. Item = QueuePopup->Items->Items[Index];
  826. Item->Default = (Action != NULL) && (Item->Action == Action);
  827. if (Item->Caption == "-")
  828. {
  829. Item->Visible = !HideFirstLine;
  830. HideFirstLine = false;
  831. }
  832. }
  833. }
  834. //---------------------------------------------------------------------------