NonVisual.cpp 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <Common.h>
  5. #include "NonVisual.h"
  6. #include <CoreMain.h>
  7. #include <TextsWin.h>
  8. #include <Tools.h>
  9. #include <Setup.h>
  10. #include <Interface.h>
  11. #include "WinConfiguration.h"
  12. #include "TerminalManager.h"
  13. #include "TBX.hpp"
  14. #include "VCLCommon.h"
  15. #include <HistoryComboBox.hpp>
  16. //---------------------------------------------------------------------------
  17. #pragma package(smart_init)
  18. #pragma link "TB2Item"
  19. #pragma link "TBX"
  20. #pragma link "TB2ExtItems"
  21. #pragma link "TBXExtItems"
  22. #pragma link "TBXToolPals"
  23. #ifndef NO_RESOURCES
  24. #pragma resource "*.dfm"
  25. #endif
  26. TNonVisualDataModule *NonVisualDataModule;
  27. //---------------------------------------------------------------------------
  28. #define SCPCOMMANDER ((TScpCommanderForm *)ScpExplorer)
  29. #define UPDEX(HandleAction, Condition, OtherEnabled, OtherDisabled) if (Action == HandleAction) { \
  30. ((TCustomAction *)Action)->Enabled = (Condition); \
  31. if (((TCustomAction *)Action)->Enabled) { OtherEnabled; } else { OtherDisabled; }; \
  32. Handled = true; } else
  33. #define UPDEX1(HandleAction, Condition, Other) UPDEX(HandleAction, Condition, Other, Other)
  34. #define UPD(HandleAction, Condition) if (Action == HandleAction) { \
  35. ((TCustomAction *)Action)->Enabled = (Condition); Handled = true; } else
  36. #define UPDFUNC(HandleAction, Function) if (Action == HandleAction) { Function; Handled = true; } else
  37. #define EXE(HandleAction, Command) if (Action == HandleAction) { \
  38. Command; Handled = true; } else
  39. #define UPDACT(HandleAction, Command) \
  40. EXE(HandleAction, ((TCustomAction *)Action)->Enabled = true; Command)
  41. #define UPDCOMP(COMP) if (Action == COMP ## Action) { COMP ## Action->Enabled = true; \
  42. COMP ## Action->Visible = ScpExplorer->IsComponentPossible(fc ## COMP); \
  43. COMP ## Action->Checked = ScpExplorer->ComponentVisible[fc ## COMP]; Handled = true; } else
  44. #define EXECOMP(COMP) EXE(COMP ## Action, \
  45. ScpExplorer->ComponentVisible[fc ## COMP] = !ScpExplorer->ComponentVisible[fc ## COMP] )
  46. #define COLPROPS(SIDE) \
  47. ((TCustomDirViewColProperties*)ScpExplorer->DirView(os ## SIDE)->ColProperties)
  48. #define UPDSORT(SIDE, PREFIX, COL) if (Action == SIDE ## SortBy ## COL ## Action) { \
  49. SIDE ## SortBy ## COL ## Action->Enabled = true; Handled = true; \
  50. SIDE ## SortBy ## COL ## Action->Checked = (COLPROPS(SIDE)->SortColumn == PREFIX ## COL); } else
  51. #define EXESORT(SIDE, PREFIX, COL) EXE(SIDE ## SortBy ## COL ## Action, \
  52. if (COLPROPS(SIDE)->SortColumn == PREFIX ## COL) \
  53. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; \
  54. else COLPROPS(SIDE)->SortColumn = PREFIX ## COL )
  55. #define UPDSORTA(SIDE) if (Action == SIDE ## SortAscendingAction) { \
  56. SIDE ## SortAscendingAction->Enabled = true; Handled = true; \
  57. SIDE ## SortAscendingAction->Checked = COLPROPS(SIDE)->SortAscending; } else
  58. #define EXESORTA(SIDE) EXE(SIDE ## SortAscendingAction, \
  59. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; )
  60. #define UPDSORTC(LPREFIX, LCOL, RPREFIX, RCOL) if (Action == CurrentSortBy ## RCOL ## Action) { \
  61. CurrentSortBy ## RCOL ## Action->Enabled = ScpExplorer->AllowedAction((TAction *)Action, aaShortCut); \
  62. if (CurrentSortBy ## RCOL ## Action->Enabled) { \
  63. if (ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) \
  64. CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == RPREFIX ## RCOL); \
  65. else CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == LPREFIX ## LCOL); \
  66. } else CurrentSortBy ## RCOL ## Action->Checked = false; Handled = true; } else
  67. #define EXESORTC(COL, LCOL, RCOL) \
  68. EXE(CurrentSortBy ## COL ## Action, \
  69. Integer NewSortCol = \
  70. ((ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) ? RCOL : LCOL); \
  71. if (COLPROPS(Current)->SortColumn == NewSortCol) \
  72. COLPROPS(Current)->SortAscending = !COLPROPS(Current)->SortAscending; \
  73. else COLPROPS(Current)->SortColumn = NewSortCol \
  74. )
  75. #define UPDSHCOL(SIDE, PREFIX, COL) \
  76. EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
  77. ShowHide ## SIDE ## COL ## ColumnAction->Checked = COLPROPS(SIDE)->Visible[PREFIX ## COL])
  78. #define EXESHCOL(SIDE, PREFIX, COL) \
  79. EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
  80. COLPROPS(SIDE)->Visible[PREFIX ## COL] = !COLPROPS(SIDE)->Visible[PREFIX ## COL])
  81. #define BAND_COMPONENTS \
  82. EMIT_BAND_COMPONENT(ExplorerMenuBand) \
  83. EMIT_BAND_COMPONENT(ExplorerAddressBand) \
  84. EMIT_BAND_COMPONENT(ExplorerToolbarBand) \
  85. EMIT_BAND_COMPONENT(ExplorerSelectionBand) \
  86. EMIT_BAND_COMPONENT(ExplorerSessionBand) \
  87. EMIT_BAND_COMPONENT(ExplorerPreferencesBand) \
  88. EMIT_BAND_COMPONENT(ExplorerSortBand) \
  89. EMIT_BAND_COMPONENT(ExplorerUpdatesBand) \
  90. EMIT_BAND_COMPONENT(ExplorerTransferBand) \
  91. EMIT_BAND_COMPONENT(ExplorerCustomCommandsBand) \
  92. EMIT_BAND_COMPONENT(CommanderMenuBand) \
  93. EMIT_BAND_COMPONENT(CommanderSessionBand) \
  94. EMIT_BAND_COMPONENT(CommanderPreferencesBand) \
  95. EMIT_BAND_COMPONENT(CommanderSortBand) \
  96. EMIT_BAND_COMPONENT(CommanderCommandsBand) \
  97. EMIT_BAND_COMPONENT(CommanderUpdatesBand) \
  98. EMIT_BAND_COMPONENT(CommanderTransferBand) \
  99. EMIT_BAND_COMPONENT(CommanderCustomCommandsBand) \
  100. EMIT_BAND_COMPONENT(CommanderLocalHistoryBand) \
  101. EMIT_BAND_COMPONENT(CommanderLocalNavigationBand) \
  102. EMIT_BAND_COMPONENT(CommanderLocalFileBand) \
  103. EMIT_BAND_COMPONENT(CommanderLocalSelectionBand) \
  104. EMIT_BAND_COMPONENT(CommanderRemoteHistoryBand) \
  105. EMIT_BAND_COMPONENT(CommanderRemoteNavigationBand) \
  106. EMIT_BAND_COMPONENT(CommanderRemoteFileBand) \
  107. EMIT_BAND_COMPONENT(CommanderRemoteSelectionBand)
  108. //---------------------------------------------------------------------------
  109. __fastcall TNonVisualDataModule::TNonVisualDataModule(TComponent* Owner)
  110. : TDataModule(Owner)
  111. {
  112. FListColumn = NULL;
  113. FSessionIdleTimerExecuting = false;
  114. FCustomizedToolbar = NULL;
  115. FBusy = 0;
  116. QueueSpeedComboBoxItem(QueuePopupSpeedComboBoxItem);
  117. }
  118. //---------------------------------------------------------------------------
  119. __fastcall TNonVisualDataModule::~TNonVisualDataModule()
  120. {
  121. }
  122. //---------------------------------------------------------------------------
  123. void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
  124. TBasicAction *Action, bool &Handled)
  125. {
  126. if (!ScpExplorer || !ScpExplorer->AllowedAction((TAction *)Action, aaUpdate))
  127. {
  128. ((TAction *)Action)->Enabled = false;
  129. Handled = true;
  130. return;
  131. }
  132. void * Param;
  133. #define HasTerminal (ScpExplorer->Terminal != NULL) && ScpExplorer->Terminal->Active
  134. // CURRENT DIRVIEW
  135. #define EnabledSelectedOperation (ScpExplorer->EnableSelectedOperation[osCurrent])
  136. #define EnabledFocusedOperation (ScpExplorer->EnableFocusedOperation[osCurrent])
  137. #define EnabledSelectedFileOperation (ScpExplorer->EnableSelectedFileOperation[osCurrent])
  138. #define EnabledFocusedFileOperation (ScpExplorer->EnableFocusedFileOperation[osCurrent])
  139. #define EnabledLocalSelectedOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableSelectedOperation[osLocal])
  140. #define EnabledLocalFocusedOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableFocusedOperation[osLocal])
  141. #define EnabledLocalSelectedFileOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableSelectedFileOperation[osLocal])
  142. #define EnabledRemoteSelectedOperation (ScpExplorer->EnableSelectedOperation[osRemote])
  143. #define EnabledRemoteFocusedOperation (ScpExplorer->EnableFocusedOperation[osRemote])
  144. #define EnabledRemoteSelectedFileOperation (ScpExplorer->EnableSelectedFileOperation[osRemote])
  145. // focused operation
  146. UPD(CurrentDeleteFocusedAction, EnabledFocusedOperation)
  147. UPD(CurrentPropertiesFocusedAction, EnabledFocusedOperation)
  148. UPD(CurrentEditFocusedAction, EnabledFocusedFileOperation &&
  149. !WinConfiguration->DisableOpenEdit)
  150. UPD(CurrentSystemMenuFocusedAction, EnabledFocusedOperation)
  151. UPD(CurrentEditWithFocusedAction, EnabledFocusedFileOperation &&
  152. !WinConfiguration->DisableOpenEdit)
  153. UPD(CurrentEditInternalFocusedAction, EnabledFocusedFileOperation &&
  154. !WinConfiguration->DisableOpenEdit)
  155. UPD(CurrentCopyToClipboardFocusedAction, EnabledFocusedOperation)
  156. // file operation
  157. UPD(CurrentRenameAction, EnabledFocusedOperation &&
  158. ((ScpExplorer->HasDirView[osLocal] && DirView(osLocal) == DirView(osCurrent)) ||
  159. ScpExplorer->Terminal->IsCapable[fcRename]))
  160. UPD(CurrentEditAction, EnabledSelectedFileOperation &&
  161. !WinConfiguration->DisableOpenEdit)
  162. UPD(CurrentEditInternalAction, EnabledSelectedFileOperation &&
  163. !WinConfiguration->DisableOpenEdit)
  164. UPD(CurrentEditWithAction, EnabledSelectedFileOperation &&
  165. !WinConfiguration->DisableOpenEdit)
  166. UPD(CurrentOpenAction, EnabledFocusedOperation &&
  167. !WinConfiguration->DisableOpenEdit)
  168. UPDEX1(CurrentAddEditLinkContextAction, ScpExplorer->CanAddEditLink(osCurrent),
  169. ((TAction *)Action)->Visible = ScpExplorer->LinkFocused())
  170. UPD(NewLinkAction, ScpExplorer->CanAddEditLink(osCurrent))
  171. // selected operation
  172. UPD(CurrentDeleteAction, EnabledSelectedOperation)
  173. UPD(CurrentDeleteAlternativeAction, EnabledSelectedOperation)
  174. UPD(CurrentPropertiesAction, EnabledSelectedOperation)
  175. UPD(CurrentCopyToClipboardAction, EnabledSelectedOperation)
  176. UPD(RemoteMoveToAction, EnabledSelectedOperation &&
  177. (DirView(osRemote) == DirView(osCurrent)) &&
  178. ScpExplorer->Terminal->IsCapable[fcRemoteMove])
  179. UPD(RemoteCopyToAction, EnabledSelectedOperation &&
  180. (DirView(osRemote) == DirView(osCurrent)))
  181. UPD(FileListToCommandLineAction, EnabledSelectedOperation)
  182. UPD(FileListToClipboardAction, EnabledSelectedOperation)
  183. UPD(FullFileListToClipboardAction, EnabledSelectedOperation)
  184. UPD(FileGenerateUrlAction2, EnabledSelectedOperation && (DirView(osRemote) == DirView(osCurrent)))
  185. UPD(FileListFromClipboardAction, IsFormatInClipboard(CF_TEXT))
  186. UPD(CurrentAddEditLinkAction, ScpExplorer->CanAddEditLink(osCurrent))
  187. UPD(LockAction,
  188. EnabledSelectedOperation && (DirView(osRemote) == DirView(osCurrent)) &&
  189. ScpExplorer->Terminal->IsCapable[fcLocking])
  190. UPD(UnlockAction,
  191. EnabledSelectedOperation && (DirView(osRemote) == DirView(osCurrent)) &&
  192. ScpExplorer->Terminal->IsCapable[fcLocking])
  193. // local selected operation
  194. UPD(LocalCopyAction, HasTerminal && EnabledLocalSelectedOperation)
  195. UPD(LocalCopyQueueAction, HasTerminal && EnabledLocalSelectedOperation && ScpExplorer->Terminal->IsCapable[fsBackgroundTransfers])
  196. UPD(LocalCopyNonQueueAction, HasTerminal && EnabledLocalSelectedOperation)
  197. UPD(LocalRenameAction, EnabledLocalSelectedOperation)
  198. UPD(LocalEditAction, EnabledLocalSelectedFileOperation && !WinConfiguration->DisableOpenEdit)
  199. UPD(LocalMoveAction, HasTerminal && EnabledLocalSelectedOperation)
  200. UPD(LocalCreateDirAction2, true)
  201. UPD(LocalDeleteAction, EnabledLocalSelectedOperation)
  202. UPD(LocalPropertiesAction, EnabledLocalSelectedOperation)
  203. UPD(LocalAddEditLinkAction2, ScpExplorer->CanAddEditLink(osLocal))
  204. UPD(LocalNewFileAction, !WinConfiguration->DisableOpenEdit)
  205. // local focused operation
  206. UPD(LocalCopyFocusedAction, HasTerminal && EnabledLocalFocusedOperation)
  207. UPD(LocalCopyFocusedQueueAction, HasTerminal && EnabledLocalFocusedOperation && ScpExplorer->Terminal->IsCapable[fsBackgroundTransfers])
  208. UPD(LocalCopyFocusedNonQueueAction, HasTerminal && EnabledLocalFocusedOperation)
  209. UPD(LocalMoveFocusedAction, HasTerminal && EnabledLocalFocusedOperation)
  210. // remote selected operation
  211. UPD(RemoteCopyAction, EnabledRemoteSelectedOperation)
  212. UPD(RemoteCopyQueueAction, EnabledRemoteSelectedOperation && ScpExplorer->Terminal->IsCapable[fsBackgroundTransfers])
  213. UPD(RemoteCopyNonQueueAction, EnabledRemoteSelectedOperation)
  214. UPD(RemoteRenameAction, EnabledRemoteSelectedOperation &&
  215. ScpExplorer->Terminal->IsCapable[fcRename])
  216. UPD(RemoteEditAction, EnabledRemoteSelectedFileOperation && !WinConfiguration->DisableOpenEdit)
  217. UPD(RemoteMoveAction, EnabledRemoteSelectedOperation)
  218. UPD(RemoteCreateDirAction2, DirViewEnabled(osRemote))
  219. UPD(RemoteNewFileAction, DirViewEnabled(osRemote) && !WinConfiguration->DisableOpenEdit)
  220. UPD(RemoteDeleteAction, EnabledRemoteSelectedOperation)
  221. UPD(RemotePropertiesAction, EnabledRemoteSelectedOperation)
  222. UPD(RemoteAddEditLinkAction2, ScpExplorer->CanAddEditLink(osRemote))
  223. // remote focused operation
  224. UPD(RemoteCopyFocusedAction, EnabledRemoteFocusedOperation)
  225. UPD(RemoteCopyFocusedQueueAction, EnabledRemoteFocusedOperation && ScpExplorer->Terminal->IsCapable[fsBackgroundTransfers])
  226. UPD(RemoteCopyFocusedNonQueueAction, EnabledRemoteFocusedOperation)
  227. UPD(RemoteMoveFocusedAction, EnabledRemoteFocusedOperation)
  228. UPD(RemoteMoveToFocusedAction, EnabledFocusedOperation &&
  229. (DirView(osRemote) == DirView(osCurrent)) &&
  230. ScpExplorer->Terminal->IsCapable[fcRemoteMove])
  231. UPD(RemoteCopyToFocusedAction, EnabledFocusedOperation &&
  232. DirView(osRemote) == DirView(osCurrent))
  233. // directory
  234. UPD(CurrentCreateDirAction, DirViewEnabled(osCurrent))
  235. UPD(NewDirAction, DirViewEnabled(osCurrent))
  236. UPD(RemoteFindFilesAction, DirViewEnabled(osRemote))
  237. // selection
  238. UPD(SelectOneAction, DirView(osCurrent)->FilesCount)
  239. UPD(SelectAction, DirView(osCurrent)->FilesCount)
  240. UPD(UnselectAction, DirView(osCurrent)->SelCount)
  241. UPD(SelectAllAction, DirView(osCurrent)->FilesCount)
  242. UPD(InvertSelectionAction, DirView(osCurrent)->FilesCount)
  243. UPD(ClearSelectionAction, DirView(osCurrent)->SelCount)
  244. UPD(RestoreSelectionAction, DirView(osCurrent)->SelectedNamesSaved)
  245. UPD(SelectSameExtAction, EnabledFocusedFileOperation)
  246. UPD(UnselectSameExtAction, EnabledFocusedFileOperation)
  247. UPD(PasteAction2, ScpExplorer->CanPasteFromClipBoard())
  248. UPD(LocalSelectAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->FilesCount)
  249. UPD(LocalUnselectAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->SelCount)
  250. UPD(LocalSelectAllAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->FilesCount)
  251. UPD(RemoteSelectAction, DirView(osRemote)->FilesCount)
  252. UPD(RemoteUnselectAction, DirView(osRemote)->SelCount)
  253. UPD(RemoteSelectAllAction, DirView(osRemote)->FilesCount)
  254. //style
  255. UPDACT(CurrentCycleStyleAction,
  256. CurrentCycleStyleAction->ImageIndex = 8 + (DirView(osCurrent)->ViewStyle + 1) % 4)
  257. #define STYLEACTION(Style) UPDACT(Current ## Style ## Action, \
  258. Current ## Style ## Action->Checked = (DirView(osCurrent)->ViewStyle == vs ## Style))
  259. STYLEACTION(Icon)
  260. STYLEACTION(SmallIcon)
  261. STYLEACTION(List)
  262. STYLEACTION(Report)
  263. #undef STYLEACTION
  264. // REMOTE+LOCAL
  265. // back/forward
  266. #define HISTORYACTION(SIDE, DIRECTION, HINTFMT, DELTA) \
  267. UPDEX(SIDE ## DIRECTION ## Action, DirViewEnabled(os ## SIDE) && (DirView(os ## SIDE)->DIRECTION ## Count > 0), \
  268. SIDE ## DIRECTION ## Action->Hint = FMTLOAD(HINTFMT, (DirView(os ## SIDE)->HistoryPath[DELTA])), \
  269. SIDE ## DIRECTION ## Action->Hint = L"")
  270. HISTORYACTION(Local, Back, EXPLORER_BACK_HINT, -1)
  271. HISTORYACTION(Local, Forward, EXPLORER_FORWARD_HINT, 1)
  272. HISTORYACTION(Remote, Back, EXPLORER_BACK_HINT, -1)
  273. HISTORYACTION(Remote, Forward, EXPLORER_FORWARD_HINT, 1)
  274. #undef HISTORYACTION
  275. #define PANEL_ACTIONS(SIDE) \
  276. UPD(SIDE ## ParentDirAction, DirViewEnabled(os ## SIDE) && !DirView(os ## SIDE)->IsRoot) \
  277. UPD(SIDE ## RootDirAction, DirViewEnabled(os ## SIDE) &&!DirView(os ## SIDE)->IsRoot) \
  278. UPD(SIDE ## HomeDirAction, DirViewEnabled(os ## SIDE)) \
  279. UPD(SIDE ## RefreshAction, DirViewEnabled(os ## SIDE) && DirView(os ## SIDE)->DirOK) \
  280. UPD(SIDE ## OpenDirAction, DirViewEnabled(os ## SIDE)) \
  281. UPD(SIDE ## ChangePathAction, DirViewEnabled(os ## SIDE)) \
  282. UPD(SIDE ## AddBookmarkAction, DirViewEnabled(os ## SIDE)) \
  283. UPD(SIDE ## PathToClipboardAction, DirViewEnabled(os ## SIDE)) \
  284. UPDEX1(SIDE ## FilterAction, DirViewEnabled(os ## SIDE), ((TAction *)Action)->Checked = !DirView(os ## SIDE)->Mask.IsEmpty())
  285. PANEL_ACTIONS(Local)
  286. PANEL_ACTIONS(Remote)
  287. #undef PANEL_ACTIONS
  288. UPD(LocalExploreDirectoryAction, true)
  289. // HELP
  290. UPD(AboutAction, true)
  291. UPD(HomepageAction, true)
  292. UPD(HistoryPageAction, true)
  293. UPD(TableOfContentsAction, true)
  294. UPD(ForumPageAction, true)
  295. UPDACT(CheckForUpdatesAction, ShowUpdatesUpdate())
  296. UPD(UpdatesPreferencesAction, true)
  297. UPD(DonatePageAction, true)
  298. UPD(DownloadPageAction, true)
  299. UPD(TipsAction, true)
  300. // VIEW
  301. UPDCOMP(SessionsTabs)
  302. UPDCOMP(StatusBar)
  303. UPDCOMP(ToolBar2)
  304. UPDCOMP(LocalStatusBar)
  305. UPDCOMP(RemoteStatusBar)
  306. UPDCOMP(CommandLinePanel)
  307. UPDCOMP(RemoteTree)
  308. UPDCOMP(LocalTree)
  309. #define EMIT_BAND_COMPONENT(COMP) UPDCOMP(COMP)
  310. BAND_COMPONENTS
  311. #undef EMIT_BAND_COMPONENT
  312. UPD(GoToCommandLineAction, true)
  313. UPD(GoToTreeAction, true)
  314. UPDEX(ShowHiddenFilesAction, true,
  315. ShowHiddenFilesAction->Checked = WinConfiguration->ShowHiddenFiles, )
  316. UPDEX(FormatSizeBytesNoneAction, true,
  317. FormatSizeBytesNoneAction->Checked = (WinConfiguration->FormatSizeBytes == fbNone), )
  318. UPDEX(FormatSizeBytesKilobytesAction, true,
  319. FormatSizeBytesKilobytesAction->Checked = (WinConfiguration->FormatSizeBytes == fbKilobytes), )
  320. UPDEX(FormatSizeBytesShortAction, true,
  321. FormatSizeBytesShortAction->Checked = (WinConfiguration->FormatSizeBytes == fbShort), )
  322. UPDEX(AutoReadDirectoryAfterOpAction, true,
  323. AutoReadDirectoryAfterOpAction->Checked = Configuration->AutoReadDirectoryAfterOp, )
  324. UPD(PreferencesAction, true)
  325. UPD(PresetsPreferencesAction, true)
  326. UPD(FileColorsPreferencesAction, true)
  327. UPDEX(LockToolbarsAction, true,
  328. LockToolbarsAction->Checked = WinConfiguration->LockToolbars, )
  329. UPDEX(SelectiveToolbarTextAction, true,
  330. SelectiveToolbarTextAction->Checked = WinConfiguration->SelectiveToolbarText, )
  331. UPDCOMP(CustomCommandsBand)
  332. UPD(ColorMenuAction, HasTerminal)
  333. UPD(GoToAddressAction, true)
  334. UPD(CustomizeToolbarAction, IsToolbarCustomizable())
  335. // SORT
  336. UPDSORTA(Local)
  337. UPDSORT(Local, dv, Name)
  338. UPDSORT(Local, dv, Ext)
  339. UPDSORT(Local, dv, Size)
  340. UPDSORT(Local, dv, Type)
  341. UPDSORT(Local, dv, Changed)
  342. UPDSORT(Local, dv, Attr)
  343. UPDSORTA(Remote)
  344. UPDSORT(Remote, uv, Name)
  345. UPDSORT(Remote, uv, Ext)
  346. UPDSORT(Remote, uv, Size)
  347. UPDSORT(Remote, uv, Changed)
  348. UPDSORT(Remote, uv, Rights)
  349. UPDSORT(Remote, uv, Owner)
  350. UPDSORT(Remote, uv, Group)
  351. UPDSORT(Remote, uv, Type)
  352. UPDSORTA(Current)
  353. UPDSORTC(dv, Name, uv, Name)
  354. UPDSORTC(dv, Ext, uv, Ext)
  355. UPDSORTC(dv, Size, uv, Size)
  356. UPDSORTC(dv, Type, uv, Type)
  357. UPDSORTC(dv, Changed, uv, Changed)
  358. UPDSORTC(dv, Attr, uv, Rights)
  359. UPDSORTC(dv, Name, uv, Owner)
  360. UPDSORTC(dv, Name, uv, Group)
  361. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  362. UPDEX(SortColumnAscendingAction, (ListColumn != NULL), SortColumnAscendingAction->Checked =
  363. (COLVIEWPROPS->SortColumn == ListColumn->Index) && COLVIEWPROPS->SortAscending, /*DebugFail()*/ )
  364. UPDEX(SortColumnDescendingAction, (ListColumn != NULL), SortColumnDescendingAction->Checked =
  365. (COLVIEWPROPS->SortColumn == ListColumn->Index) && !COLVIEWPROPS->SortAscending, /*DebugFail()*/ )
  366. #undef COLVIEWPROPS
  367. // SHOW/HIDE COLUMN
  368. UPDSHCOL(Local, dv, Name)
  369. UPDSHCOL(Local, dv, Ext)
  370. UPDSHCOL(Local, dv, Size)
  371. UPDSHCOL(Local, dv, Type)
  372. UPDSHCOL(Local, dv, Changed)
  373. UPDSHCOL(Local, dv, Attr)
  374. UPDSHCOL(Remote, uv, Name)
  375. UPDSHCOL(Remote, uv, Ext)
  376. UPDSHCOL(Remote, uv, Size)
  377. UPDSHCOL(Remote, uv, Changed)
  378. UPDSHCOL(Remote, uv, Rights)
  379. UPDSHCOL(Remote, uv, Owner)
  380. UPDSHCOL(Remote, uv, Group)
  381. UPDSHCOL(Remote, uv, LinkTarget)
  382. UPDSHCOL(Remote, uv, Type)
  383. UPD(HideColumnAction, (ListColumn != NULL))
  384. UPD(BestFitColumnAction, (ListColumn != NULL))
  385. // SESSION
  386. UPD(NewSessionAction, true)
  387. UPD(SiteManagerAction, true)
  388. UPD(DuplicateSessionAction, HasTerminal)
  389. UPD(RenameSessionAction, HasTerminal)
  390. UPD(CloseSessionAction2, (ScpExplorer->Terminal != NULL))
  391. UPDEX1(DisconnectSessionAction, HasTerminal, DisconnectSessionAction->Visible = (ScpExplorer->Terminal == NULL) || !ScpExplorer->Terminal->Disconnected)
  392. UPDEX1(ReconnectSessionAction, (ScpExplorer->Terminal != NULL) && ScpExplorer->Terminal->Disconnected, ReconnectSessionAction->Visible = ReconnectSessionAction->Enabled)
  393. UPD(SavedSessionsAction2, true)
  394. UPD(WorkspacesAction, StoredSessions->HasAnyWorkspace())
  395. UPD(OpenedSessionsAction, HasTerminal)
  396. UPD(SaveCurrentSessionAction2, HasTerminal)
  397. UPD(SaveWorkspaceAction, HasTerminal)
  398. // COMMAND
  399. UPD(CompareDirectoriesAction, HasTerminal)
  400. UPD(SynchronizeAction, HasTerminal)
  401. UPD(FullSynchronizeAction, HasTerminal)
  402. UPD(ConsoleAction, ScpExplorer->CanConsole())
  403. UPD(PuttyAction, HasTerminal && TTerminalManager::Instance()->CanOpenInPutty())
  404. UPD(SynchronizeBrowsingAction, HasTerminal)
  405. UPD(CloseApplicationAction, true)
  406. UPD(FileSystemInfoAction, HasTerminal)
  407. UPD(SessionGenerateUrlAction2, HasTerminal)
  408. UPD(ClearCachesAction, HasTerminal && !ScpExplorer->Terminal->AreCachesEmpty)
  409. UPD(NewFileAction, DirViewEnabled(osCurrent) && !WinConfiguration->DisableOpenEdit)
  410. UPD(EditorListCustomizeAction, true)
  411. UPD(ChangePasswordAction, ScpExplorer->CanChangePassword())
  412. UPD(PrivateKeyUploadAction, ScpExplorer->CanPrivateKeyUpload())
  413. // CUSTOM COMMANDS
  414. UPD(CustomCommandsFileAction, true)
  415. UPD(CustomCommandsNonFileAction, true)
  416. UPD(CustomCommandsEnterAction, true)
  417. UPD(CustomCommandsEnterFocusedAction, true)
  418. UPDFUNC(CustomCommandsLastAction, CustomCommandsLastUpdate(CustomCommandsLastAction))
  419. UPDFUNC(CustomCommandsLastFocusedAction, CustomCommandsLastUpdate(CustomCommandsLastFocusedAction))
  420. UPD(CustomCommandsCustomizeAction, true)
  421. // QUEUE
  422. UPDEX(QueueEnableAction, HasTerminal, ((TAction *)Action)->Checked = ScpExplorer->GetQueueEnabled(), )
  423. #define UPDQUEUE(OPERATION) UPD(Queue ## OPERATION ## Action, \
  424. ScpExplorer->AllowQueueOperation(qo ## OPERATION))
  425. UPDQUEUE(GoTo)
  426. UPDQUEUE(Preferences)
  427. UPDEX(QueueItemQueryAction, ScpExplorer->AllowQueueOperation(qoItemQuery),
  428. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  429. UPDEX(QueueItemErrorAction, ScpExplorer->AllowQueueOperation(qoItemError),
  430. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  431. UPDEX(QueueItemPromptAction, ScpExplorer->AllowQueueOperation(qoItemPrompt),
  432. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  433. UPDQUEUE(ItemDelete)
  434. UPDEX(QueueItemExecuteAction, ScpExplorer->AllowQueueOperation(qoItemExecute),
  435. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible =
  436. !ScpExplorer->AllowQueueOperation(qoItemPause) &&
  437. !ScpExplorer->AllowQueueOperation(qoItemResume))
  438. UPDEX(QueueItemPauseAction, ScpExplorer->AllowQueueOperation(qoItemPause),
  439. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  440. UPDEX(QueueItemResumeAction, ScpExplorer->AllowQueueOperation(qoItemResume),
  441. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  442. UPDQUEUE(ItemUp)
  443. UPDQUEUE(ItemDown)
  444. UPDQUEUE(PauseAll)
  445. UPDQUEUE(ResumeAll)
  446. UPDQUEUE(DeleteAll)
  447. UPDQUEUE(DeleteAllDone)
  448. #undef UPDQUEUE
  449. UPDEX(QueueItemSpeedAction, ScpExplorer->AllowQueueOperation(qoItemSpeed, &Param),
  450. QueueItemSpeedAction->Text = SetSpeedLimit(reinterpret_cast<unsigned long>(Param)),
  451. QueueItemSpeedAction->Text = L"")
  452. UPDACT(QueueToggleShowAction,
  453. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueView])
  454. #define QUEUEACTION(SHOW) UPDACT(Queue ## SHOW ## Action, \
  455. ((TAction *)Action)->Checked = WinConfiguration->QueueView.Show == qv ## SHOW)
  456. QUEUEACTION(Show)
  457. QUEUEACTION(HideWhenEmpty)
  458. QUEUEACTION(Hide)
  459. #undef QUEUEACTION
  460. UPDEX1(QueueCycleOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty),
  461. QueueCycleOnceEmptyAction->ImageIndex = CurrentQueueOnceEmptyAction()->ImageIndex;
  462. QueueCycleOnceEmptyAction->Checked = !QueueIdleOnceEmptyAction->Checked)
  463. UPD(QueueIdleOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  464. UPD(QueueDisconnectOnceEmptyAction2, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  465. UPD(QueueSuspendOnceEmptyAction2, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  466. UPD(QueueShutDownOnceEmptyAction2, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  467. UPDCOMP(CommanderPreferencesBand)
  468. UPDACT(QueueToolbarAction,
  469. ((TAction *)Action)->Enabled = ScpExplorer->ComponentVisible[fcQueueView];
  470. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueToolbar])
  471. ;
  472. }
  473. //---------------------------------------------------------------------------
  474. void __fastcall TNonVisualDataModule::ExplorerActionsExecute(
  475. TBasicAction *Action, bool &Handled)
  476. {
  477. DebugAssert(ScpExplorer);
  478. if (!ScpExplorer->AllowedAction((TAction *)Action, aaExecute))
  479. {
  480. Handled = true;
  481. return;
  482. }
  483. ScpExplorer->BeforeAction();
  484. unsigned int ShortCutFlag = FLAGMASK((Action->ActionComponent == NULL), cocShortCutHint);
  485. {
  486. TAutoNestingCounter Counter(FBusy);
  487. // focused operation
  488. EXE(CurrentDeleteFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, true))
  489. EXE(CurrentPropertiesFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, true))
  490. EXE(CurrentEditFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, true))
  491. EXE(CurrentSystemMenuFocusedAction, ScpExplorer->DisplaySystemContextMenu())
  492. EXE(CurrentEditWithFocusedAction, ScpExplorer->ExecuteCurrentFileWith(true))
  493. EXE(CurrentEditInternalFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, true))
  494. EXE(CurrentCopyToClipboardFocusedAction, ScpExplorer->CopyFilesToClipboard(osCurrent, true))
  495. // operation
  496. EXE(CurrentEditAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, false))
  497. EXE(CurrentEditInternalAction, ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, false))
  498. EXE(CurrentEditWithAction, ScpExplorer->ExecuteCurrentFileWith(false))
  499. EXE(CurrentOpenAction, ScpExplorer->ExecuteCurrentFile())
  500. EXE(CurrentAddEditLinkAction, ScpExplorer->AddEditLink(osCurrent, false))
  501. EXE(CurrentAddEditLinkContextAction, ScpExplorer->AddEditLink(osCurrent, false))
  502. EXE(NewLinkAction, ScpExplorer->AddEditLink(osCurrent, true))
  503. EXE(CurrentRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osCurrent, false))
  504. EXE(CurrentDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false))
  505. EXE(CurrentDeleteAlternativeAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false, false, (void*)true))
  506. EXE(CurrentPropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, false))
  507. EXE(CurrentCopyToClipboardAction, ScpExplorer->CopyFilesToClipboard(osCurrent, false))
  508. EXE(FileListToCommandLineAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedCommandLine))
  509. EXE(FileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedClipboard))
  510. EXE(FullFileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFullFileList, pedClipboard))
  511. EXE(FileGenerateUrlAction2, ScpExplorer->FileGenerateUrl())
  512. EXE(FileListFromClipboardAction, ScpExplorer->FileListFromClipboard())
  513. EXE(LockAction, ScpExplorer->ExecuteFileOperationCommand(foLock, osCurrent, false))
  514. EXE(UnlockAction, ScpExplorer->ExecuteFileOperationCommand(foUnlock, osCurrent, false))
  515. // local selected operation
  516. EXE(LocalCopyAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, false, ShortCutFlag))
  517. EXE(LocalCopyQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, false, cocQueue))
  518. EXE(LocalCopyNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, false, cocNonQueue))
  519. EXE(LocalRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osLocal, false))
  520. EXE(LocalEditAction, ScpExplorer->ExecuteFile(osLocal, efDefaultEditor, NULL, true, false))
  521. EXE(LocalMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, false))
  522. EXE(LocalCreateDirAction2, ScpExplorer->CreateDirectory(osLocal))
  523. EXE(LocalDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osLocal, false))
  524. EXE(LocalPropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osLocal, false))
  525. EXE(LocalAddEditLinkAction2, ScpExplorer->AddEditLink(osLocal, false))
  526. EXE(LocalNewFileAction, ScpExplorer->EditNew(osLocal))
  527. // local focused operation
  528. EXE(LocalCopyFocusedAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, true, ShortCutFlag))
  529. EXE(LocalCopyFocusedQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, true, cocQueue))
  530. EXE(LocalCopyFocusedNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, true, cocNonQueue))
  531. EXE(LocalMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, true))
  532. // remote selected operation
  533. EXE(RemoteCopyAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, false, ShortCutFlag))
  534. EXE(RemoteCopyQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, false, cocQueue))
  535. EXE(RemoteCopyNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, false, cocNonQueue))
  536. EXE(RemoteRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osRemote, false))
  537. EXE(RemoteEditAction, ScpExplorer->ExecuteFile(osRemote, efDefaultEditor, NULL, true, false))
  538. EXE(RemoteMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, false))
  539. EXE(RemoteCreateDirAction2, ScpExplorer->CreateDirectory(osRemote))
  540. EXE(RemoteNewFileAction, ScpExplorer->EditNew(osRemote))
  541. EXE(RemoteDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osRemote, false))
  542. EXE(RemotePropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osRemote, false))
  543. EXE(RemoteMoveToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, false))
  544. EXE(RemoteCopyToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, false))
  545. EXE(RemoteAddEditLinkAction2, ScpExplorer->AddEditLink(osRemote, false))
  546. // remote focused operation
  547. EXE(RemoteCopyFocusedAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, true, ShortCutFlag))
  548. EXE(RemoteCopyFocusedQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, true, cocQueue))
  549. EXE(RemoteCopyFocusedNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, true, cocNonQueue))
  550. EXE(RemoteMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, true))
  551. EXE(RemoteMoveToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, true))
  552. EXE(RemoteCopyToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, true))
  553. // directory
  554. EXE(CurrentCreateDirAction, ScpExplorer->CreateDirectory(osCurrent))
  555. EXE(NewDirAction, ScpExplorer->CreateDirectory(osCurrent))
  556. EXE(RemoteFindFilesAction, ScpExplorer->RemoteFindFiles())
  557. //selection
  558. EXE(SelectOneAction, DirView(osCurrent)->SelectCurrentItem(DirView(osCurrent)->NortonLike))
  559. EXE(SelectAction, ScpExplorer->SelectByMask(osCurrent, true))
  560. EXE(UnselectAction, ScpExplorer->SelectByMask(osCurrent, false))
  561. EXE(SelectAllAction, ScpExplorer->SelectAll(osCurrent, smAll))
  562. EXE(InvertSelectionAction, ScpExplorer->SelectAll(osCurrent, smInvert))
  563. EXE(ClearSelectionAction, ScpExplorer->SelectAll(osCurrent, smNone))
  564. EXE(RestoreSelectionAction, ScpExplorer->RestoreSelectedNames(osCurrent))
  565. EXE(SelectSameExtAction, ScpExplorer->SelectSameExt(true))
  566. EXE(UnselectSameExtAction, ScpExplorer->SelectSameExt(false))
  567. EXE(LocalSelectAction, ScpExplorer->SelectByMask(osLocal, true))
  568. EXE(LocalUnselectAction, ScpExplorer->SelectByMask(osLocal, false))
  569. EXE(LocalSelectAllAction, ScpExplorer->SelectAll(osLocal, smAll))
  570. EXE(RemoteSelectAction, ScpExplorer->SelectByMask(osRemote, true))
  571. EXE(RemoteUnselectAction, ScpExplorer->SelectByMask(osRemote, false))
  572. EXE(RemoteSelectAllAction, ScpExplorer->SelectAll(osRemote, smAll))
  573. EXE(PasteAction2, ScpExplorer->PasteFromClipBoard())
  574. // style
  575. EXE(CurrentCycleStyleAction,
  576. if (DirView(osCurrent)->ViewStyle == vsReport) DirView(osCurrent)->ViewStyle = vsIcon;
  577. else DirView(osCurrent)->ViewStyle = (TViewStyle)(DirView(osCurrent)->ViewStyle + 1);
  578. )
  579. #define STYLEACTION(Style) EXE(Current ## Style ## Action, \
  580. DirView(osCurrent)->ViewStyle = vs ## Style)
  581. STYLEACTION(Icon)
  582. STYLEACTION(SmallIcon)
  583. STYLEACTION(List)
  584. STYLEACTION(Report)
  585. #undef STYLEACTION
  586. #define PANEL_ACTIONS(SIDE) \
  587. EXE(SIDE ## BackAction, ScpExplorer->HistoryGo(os ## SIDE, -1)) \
  588. EXE(SIDE ## ForwardAction, ScpExplorer->HistoryGo(os ## SIDE, 1)) \
  589. EXE(SIDE ## ParentDirAction, DirView(os ## SIDE)->ExecuteParentDirectory()) \
  590. EXE(SIDE ## RootDirAction, DirView(os ## SIDE)->ExecuteRootDirectory()) \
  591. EXE(SIDE ## HomeDirAction, ScpExplorer->HomeDirectory(os ## SIDE)) \
  592. EXE(SIDE ## RefreshAction, ScpExplorer->ReloadDirectory(os ## SIDE)) \
  593. EXE(SIDE ## OpenDirAction, ScpExplorer->OpenDirectory(os ## SIDE)) \
  594. EXE(SIDE ## ChangePathAction, ScpExplorer->ChangePath(os ## SIDE)) \
  595. EXE(SIDE ## AddBookmarkAction, ScpExplorer->AddBookmark(os ## SIDE)) \
  596. EXE(SIDE ## PathToClipboardAction, ScpExplorer->PanelExport(os ## SIDE, pePath, pedClipboard)) \
  597. EXE(SIDE ## FilterAction, ScpExplorer->Filter(os ## SIDE))
  598. PANEL_ACTIONS(Local)
  599. PANEL_ACTIONS(Remote)
  600. #undef PANEL_ACTIONS
  601. EXE(LocalExploreDirectoryAction, ScpExplorer->ExploreLocalDirectory())
  602. //HELP
  603. EXE(AboutAction, DoAboutDialog(Configuration))
  604. EXE(HomepageAction, OpenBrowser(LoadStr(HOMEPAGE_URL)))
  605. EXE(HistoryPageAction, OpenBrowser(LoadStr(HISTORY_URL)))
  606. EXE(TableOfContentsAction, Application->HelpSystem->ShowTableOfContents())
  607. EXE(ForumPageAction, OpenBrowser(LoadStr(FORUM_URL)))
  608. EXE(CheckForUpdatesAction, CheckForUpdates(false))
  609. EXE(UpdatesPreferencesAction, PreferencesDialog(pmUpdates))
  610. EXE(DonatePageAction, OpenBrowser(LoadStr(DONATE_URL)))
  611. EXE(DownloadPageAction, OpenBrowser(LoadStr(DOWNLOAD_URL)))
  612. EXE(TipsAction, ShowTips())
  613. // VIEW
  614. EXECOMP(SessionsTabs)
  615. EXECOMP(StatusBar)
  616. EXECOMP(ToolBar2)
  617. EXECOMP(LocalStatusBar)
  618. EXECOMP(RemoteStatusBar)
  619. #define EMIT_BAND_COMPONENT(COMP) EXECOMP(COMP)
  620. BAND_COMPONENTS
  621. #undef EMIT_BAND_COMPONENT
  622. EXECOMP(CommandLinePanel)
  623. EXECOMP(RemoteTree)
  624. EXECOMP(LocalTree)
  625. EXE(GoToCommandLineAction, ScpExplorer->GoToCommandLine())
  626. EXE(GoToTreeAction, ScpExplorer->GoToTree())
  627. EXE(ShowHiddenFilesAction, ScpExplorer->ToggleShowHiddenFiles())
  628. EXE(FormatSizeBytesNoneAction, ScpExplorer->SetFormatSizeBytes(fbNone))
  629. EXE(FormatSizeBytesKilobytesAction, ScpExplorer->SetFormatSizeBytes(fbKilobytes))
  630. EXE(FormatSizeBytesShortAction, ScpExplorer->SetFormatSizeBytes(fbShort))
  631. EXE(AutoReadDirectoryAfterOpAction, ScpExplorer->ToggleAutoReadDirectoryAfterOp())
  632. EXE(PreferencesAction, PreferencesDialog(::pmDefault) )
  633. EXE(PresetsPreferencesAction, PreferencesDialog(pmPresets) )
  634. EXE(FileColorsPreferencesAction, PreferencesDialog(pmFileColors) )
  635. EXE(LockToolbarsAction, WinConfiguration->LockToolbars = !WinConfiguration->LockToolbars)
  636. EXE(SelectiveToolbarTextAction, WinConfiguration->SelectiveToolbarText = !WinConfiguration->SelectiveToolbarText)
  637. EXECOMP(CustomCommandsBand)
  638. EXE(ColorMenuAction, CreateSessionColorMenu(ColorMenuAction))
  639. EXE(GoToAddressAction, ScpExplorer->GoToAddress())
  640. EXE(CustomizeToolbarAction, CreateToolbarButtonsList())
  641. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  642. // SORT
  643. EXESORTA(Local)
  644. EXESORT(Local, dv, Name)
  645. EXESORT(Local, dv, Ext)
  646. EXESORT(Local, dv, Size)
  647. EXESORT(Local, dv, Type)
  648. EXESORT(Local, dv, Changed)
  649. EXESORT(Local, dv, Attr)
  650. EXESORTA(Remote)
  651. EXESORT(Remote, uv, Name)
  652. EXESORT(Remote, uv, Ext)
  653. EXESORT(Remote, uv, Size)
  654. EXESORT(Remote, uv, Changed)
  655. EXESORT(Remote, uv, Rights)
  656. EXESORT(Remote, uv, Owner)
  657. EXESORT(Remote, uv, Group)
  658. EXESORT(Remote, uv, Type)
  659. EXESORTA(Current)
  660. EXESORTC(Name, dvName, uvName)
  661. EXESORTC(Ext, dvExt, uvExt)
  662. EXESORTC(Size, dvSize, uvSize)
  663. EXESORTC(Type, dvType, uvType)
  664. EXESORTC(Changed, dvChanged, uvChanged)
  665. EXESORTC(Rights, dvAttr, uvRights)
  666. EXESORTC(Owner, dvName, uvOwner)
  667. EXESORTC(Group, dvName, uvGroup)
  668. EXE(SortColumnAscendingAction, DebugAssert(ListColumn);
  669. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = true; ListColumn = NULL )
  670. EXE(SortColumnDescendingAction, DebugAssert(ListColumn);
  671. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = false; ListColumn = NULL )
  672. // SHOW/HIDE COLUMN
  673. EXESHCOL(Local, dv, Name)
  674. EXESHCOL(Local, dv, Ext)
  675. EXESHCOL(Local, dv, Size)
  676. EXESHCOL(Local, dv, Type)
  677. EXESHCOL(Local, dv, Changed)
  678. EXESHCOL(Local, dv, Attr)
  679. EXESHCOL(Remote, uv, Name)
  680. EXESHCOL(Remote, uv, Ext)
  681. EXESHCOL(Remote, uv, Size)
  682. EXESHCOL(Remote, uv, Changed)
  683. EXESHCOL(Remote, uv, Rights)
  684. EXESHCOL(Remote, uv, Owner)
  685. EXESHCOL(Remote, uv, Group)
  686. EXESHCOL(Remote, uv, LinkTarget)
  687. EXESHCOL(Remote, uv, Type)
  688. EXE(HideColumnAction, DebugAssert(ListColumn);
  689. COLVIEWPROPS->Visible[ListColumn->Index] = false; ListColumn = NULL )
  690. EXE(BestFitColumnAction, DebugAssert(ListColumn); ListColumn = NULL ) // TODO
  691. #undef COLVIEWPROPS
  692. // SESSION
  693. EXE(NewSessionAction, ScpExplorer->NewSession(false))
  694. EXE(SiteManagerAction, ScpExplorer->NewSession(true))
  695. EXE(DuplicateSessionAction, ScpExplorer->DuplicateSession())
  696. EXE(RenameSessionAction, ScpExplorer->RenameSession())
  697. EXE(CloseSessionAction2, ScpExplorer->CloseSession())
  698. EXE(DisconnectSessionAction, ScpExplorer->DisconnectSession())
  699. EXE(ReconnectSessionAction, ScpExplorer->ReconnectSession())
  700. EXE(SavedSessionsAction2, CreateSessionListMenu(SavedSessionsAction2))
  701. EXE(WorkspacesAction, CreateWorkspacesMenu(WorkspacesAction))
  702. EXE(OpenedSessionsAction, CreateOpenedSessionListMenu(OpenedSessionsAction))
  703. EXE(SaveCurrentSessionAction2, ScpExplorer->SaveCurrentSession())
  704. EXE(SaveWorkspaceAction, ScpExplorer->SaveWorkspace(false))
  705. // COMMAND
  706. EXE(CompareDirectoriesAction, ScpExplorer->CompareDirectories())
  707. EXE(SynchronizeAction, ScpExplorer->SynchronizeDirectories())
  708. EXE(FullSynchronizeAction, ScpExplorer->FullSynchronizeDirectories())
  709. EXE(ConsoleAction, ScpExplorer->OpenConsole())
  710. EXE(PuttyAction, TTerminalManager::Instance()->OpenInPutty())
  711. EXE(SynchronizeBrowsingAction, ScpExplorer->SynchronizeBrowsingChanged())
  712. EXE(CloseApplicationAction, ScpExplorer->Close())
  713. EXE(FileSystemInfoAction, ScpExplorer->FileSystemInfo())
  714. EXE(SessionGenerateUrlAction2, ScpExplorer->SessionGenerateUrl())
  715. EXE(ClearCachesAction, ScpExplorer->Terminal->ClearCaches())
  716. EXE(NewFileAction, ScpExplorer->EditNew(osCurrent))
  717. EXE(EditorListCustomizeAction, PreferencesDialog(pmEditor))
  718. EXE(ChangePasswordAction, ScpExplorer->ChangePassword())
  719. EXE(PrivateKeyUploadAction, ScpExplorer->PrivateKeyUpload())
  720. // CUSTOM COMMANDS
  721. EXE(CustomCommandsFileAction, CreateCustomCommandsMenu(CustomCommandsFileAction, ccltFile))
  722. EXE(CustomCommandsNonFileAction, CreateCustomCommandsMenu(CustomCommandsNonFileAction, ccltNonFile))
  723. EXE(CustomCommandsEnterAction, ScpExplorer->AdHocCustomCommand(false))
  724. EXE(CustomCommandsEnterFocusedAction, ScpExplorer->AdHocCustomCommand(true))
  725. EXE(CustomCommandsLastAction, ScpExplorer->LastCustomCommand(false))
  726. EXE(CustomCommandsLastFocusedAction, ScpExplorer->LastCustomCommand(true))
  727. EXE(CustomCommandsCustomizeAction, PreferencesDialog(pmCustomCommands))
  728. // QUEUE
  729. EXE(QueueEnableAction, ScpExplorer->ToggleQueueEnabled())
  730. #define EXEQUEUE(OPERATION) EXE(Queue ## OPERATION ## Action, \
  731. ScpExplorer->ExecuteQueueOperation(qo ## OPERATION))
  732. EXEQUEUE(GoTo)
  733. EXEQUEUE(Preferences)
  734. EXEQUEUE(ItemQuery)
  735. EXEQUEUE(ItemError)
  736. EXEQUEUE(ItemPrompt)
  737. EXEQUEUE(ItemDelete)
  738. EXEQUEUE(ItemExecute)
  739. EXEQUEUE(ItemPause)
  740. EXEQUEUE(ItemResume)
  741. EXEQUEUE(ItemUp)
  742. EXEQUEUE(ItemDown)
  743. EXEQUEUE(PauseAll)
  744. EXEQUEUE(ResumeAll)
  745. EXEQUEUE(DeleteAll)
  746. EXEQUEUE(DeleteAllDone)
  747. #undef EXEQUEUE
  748. EXE(QueueToggleShowAction, ScpExplorer->ToggleQueueVisibility())
  749. #define QUEUEACTION(SHOW) EXE(Queue ## SHOW ## Action, \
  750. TQueueViewConfiguration Config = WinConfiguration->QueueView; \
  751. if (Config.Show != qvShow) Config.LastHideShow = Config.Show; \
  752. Config.Show = qv ## SHOW; \
  753. WinConfiguration->QueueView = Config)
  754. QUEUEACTION(Show)
  755. QUEUEACTION(HideWhenEmpty)
  756. QUEUEACTION(Hide)
  757. #undef QUEUEACTION
  758. EXE(QueueCycleOnceEmptyAction, CycleQueueOnceEmptyAction())
  759. EXE(QueueIdleOnceEmptyAction, SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction))
  760. EXE(QueueDisconnectOnceEmptyAction2, SetQueueOnceEmptyAction(QueueDisconnectOnceEmptyAction2))
  761. EXE(QueueSuspendOnceEmptyAction2, SetQueueOnceEmptyAction(QueueSuspendOnceEmptyAction2))
  762. EXE(QueueShutDownOnceEmptyAction2, SetQueueOnceEmptyAction(QueueShutDownOnceEmptyAction2))
  763. EXECOMP(QueueToolbar)
  764. EXE(QueueItemSpeedAction, )
  765. ;
  766. }
  767. DoIdle();
  768. }
  769. //---------------------------------------------------------------------------
  770. void __fastcall TNonVisualDataModule::UpdateNonVisibleActions()
  771. {
  772. // following actions needs to be updated even when all clients
  773. // are invisible, so the queue list toolbar button can be shown
  774. NonVisualDataModule->QueueItemQueryAction->Update();
  775. NonVisualDataModule->QueueItemErrorAction->Update();
  776. NonVisualDataModule->QueueItemPromptAction->Update();
  777. }
  778. //---------------------------------------------------------------------------
  779. #define CTRL TShiftState() << ssCtrl
  780. #define ALT TShiftState() << ssAlt
  781. #define SHIFT TShiftState() << ssShift
  782. #define CTRLSHIFT TShiftState() << ssCtrl << ssShift
  783. #define CTRLALT TShiftState() << ssCtrl << ssAlt
  784. #define NONE TShiftState()
  785. void __fastcall TNonVisualDataModule::ExplorerShortcuts()
  786. {
  787. // Directory
  788. CurrentCreateDirAction->ShortCut = ShortCut(L'D', CTRL);
  789. // File operation
  790. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  791. CurrentEditAction->ShortCut = ShortCut(L'E', CTRL);
  792. CurrentAddEditLinkAction->ShortCut = ShortCut(L'L', CTRLALT);
  793. CurrentEditInternalAction->ShortCut = 0;
  794. CurrentEditInternalFocusedAction->ShortCut = 0;
  795. // Focused operation
  796. RemoteCopyAction->ShortCut = ShortCut(L'T', CTRL);
  797. RemoteMoveAction->ShortCut = ShortCut(L'M', CTRL);
  798. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_DELETE, NONE);
  799. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_RETURN, ALT);
  800. RemoteMoveToFocusedAction->ShortCut = ShortCut(L'M', CTRLALT);
  801. // remote directory
  802. RemoteOpenDirAction->ShortCut = ShortCut(L'O', CTRL);
  803. RemoteRefreshAction->ShortCut = ShortCut(VK_F5, NONE);
  804. RemoteHomeDirAction->ShortCut = ShortCut(L'H', CTRL);
  805. RemotePathToClipboardAction->ShortCut = ShortCut(L'P', CTRLSHIFT);
  806. // selected operation
  807. CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_DELETE, SHIFT);
  808. RemoteMoveToAction->ShortCut = ShortCut(L'M', CTRLALT);
  809. // selection
  810. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  811. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  812. SelectAllAction->ShortCut = ShortCut(L'A', CTRL);
  813. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  814. ClearSelectionAction->ShortCut = ShortCut(L'L', CTRLSHIFT);
  815. RestoreSelectionAction->ShortCut = ShortCut(L'R', CTRLSHIFT);
  816. // commands
  817. NewFileAction->ShortCut = ShortCut(L'E', CTRLSHIFT);
  818. RemoteFindFilesAction->ShortCut = ShortCut(VK_F3, NONE);
  819. CloseApplicationAction->ShortCut = ShortCut(VK_F4, ALT);
  820. CloneShortcuts();
  821. }
  822. //---------------------------------------------------------------------------
  823. void __fastcall TNonVisualDataModule::CommanderShortcuts()
  824. {
  825. bool ExplorerKeyboardShortcuts = WinConfiguration->ScpCommander.ExplorerKeyboardShortcuts;
  826. // Directory
  827. CurrentCreateDirAction->ShortCut = ShortCut(VK_F7, NONE);
  828. // File operation
  829. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  830. CurrentEditAction->ShortCut = ShortCut(VK_F4, NONE);
  831. CurrentAddEditLinkAction->ShortCut = ShortCut(VK_F6, ALT);
  832. CurrentEditInternalAction->ShortCut = ShortCut(VK_F4, CTRLALT);
  833. CurrentEditInternalFocusedAction->ShortCut = ShortCut(VK_F4, CTRLALT);
  834. // Focused operation
  835. RemoteCopyAction->ShortCut =
  836. ExplorerKeyboardShortcuts ? ShortCut(L'K', CTRL) : ShortCut(VK_F5, NONE);
  837. RemoteMoveAction->ShortCut = ShortCut(VK_F6, NONE);
  838. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_F8, NONE);
  839. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_F9, NONE);
  840. RemoteMoveToFocusedAction->ShortCut = ShortCut(VK_F6, SHIFT);
  841. RemoteCopyToFocusedAction->ShortCut = ShortCut(VK_F5, SHIFT);
  842. // remote directory
  843. RemoteOpenDirAction->ShortCut = ShortCut(L'O', CTRL);
  844. RemoteRefreshAction->ShortCut =
  845. ExplorerKeyboardShortcuts ? ShortCut(VK_F5, NONE) : ShortCut(L'R', CTRL);
  846. RemoteHomeDirAction->ShortCut = ShortCut(L'H', CTRL);
  847. RemotePathToClipboardAction->ShortCut = ShortCut(VK_OEM_6 /* ] */, CTRL);
  848. // local directory
  849. LocalPathToClipboardAction->ShortCut = ShortCut(VK_OEM_4 /* [ */, CTRL);
  850. // selected operation
  851. CurrentDeleteAction->SecondaryShortCuts->Clear();
  852. CurrentDeleteAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, NONE)));
  853. CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_F8, SHIFT);
  854. CurrentDeleteAlternativeAction->SecondaryShortCuts->Clear();
  855. CurrentDeleteAlternativeAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, SHIFT)));
  856. RemoteMoveToAction->ShortCut = ShortCut(VK_F6, SHIFT);
  857. RemoteCopyToAction->ShortCut = ShortCut(VK_F5, SHIFT);
  858. // selection
  859. SelectOneAction->ShortCut = VK_INSERT;
  860. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  861. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  862. SelectAllAction->ShortCut = ShortCut(L'A', CTRL);
  863. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  864. ClearSelectionAction->ShortCut = ShortCut(L'L', CTRLSHIFT);
  865. RestoreSelectionAction->ShortCut = ShortCut(L'R', CTRLSHIFT);
  866. // commands
  867. NewFileAction->ShortCut = ShortCut(VK_F4, SHIFT);
  868. RemoteFindFilesAction->ShortCut =
  869. ExplorerKeyboardShortcuts ? ShortCut(VK_F3, NONE) : ShortCut(VK_F7, ALT);
  870. // legacy shortcut (can be removed when necessary)
  871. NewFileAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_F4, CTRLSHIFT)));
  872. // Backward compatibility, can be abandoned, once there's a better use for Ctrl+T
  873. ConsoleAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(L'T', CTRL)));
  874. CloseApplicationAction->ShortCut = ShortCut(VK_F10, NONE);
  875. CloneShortcuts();
  876. }
  877. #undef CTRL
  878. #undef ALT
  879. #undef NONE
  880. //---------------------------------------------------------------------------
  881. void __fastcall TNonVisualDataModule::CloneShortcuts()
  882. {
  883. // Commands
  884. NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
  885. // File operation
  886. CurrentAddEditLinkContextAction->ShortCut = CurrentAddEditLinkAction->ShortCut;
  887. LocalAddEditLinkAction2->ShortCut = CurrentAddEditLinkAction->ShortCut;
  888. RemoteAddEditLinkAction2->ShortCut = CurrentAddEditLinkAction->ShortCut;
  889. RemoteNewFileAction->ShortCut = NewFileAction->ShortCut;
  890. LocalNewFileAction->ShortCut = NewFileAction->ShortCut;
  891. // local directory
  892. LocalOpenDirAction->ShortCut = RemoteOpenDirAction->ShortCut;
  893. LocalRefreshAction->ShortCut = RemoteRefreshAction->ShortCut;
  894. LocalHomeDirAction->ShortCut = RemoteHomeDirAction->ShortCut;
  895. // selected operation
  896. CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
  897. CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
  898. // local selected operation
  899. LocalCopyAction->ShortCut = RemoteCopyAction->ShortCut;
  900. LocalRenameAction->ShortCut = CurrentRenameAction->ShortCut;
  901. LocalEditAction->ShortCut = CurrentEditAction->ShortCut;
  902. LocalMoveAction->ShortCut = RemoteMoveAction->ShortCut;
  903. LocalCreateDirAction2->ShortCut = CurrentCreateDirAction->ShortCut;
  904. LocalDeleteAction->ShortCut = CurrentDeleteAction->ShortCut;
  905. LocalPropertiesAction->ShortCut = CurrentPropertiesAction->ShortCut;
  906. // local focused operation
  907. LocalCopyFocusedAction->ShortCut = LocalCopyAction->ShortCut;
  908. LocalMoveFocusedAction->ShortCut = LocalMoveAction->ShortCut;
  909. // remote selected operation
  910. RemoteRenameAction->ShortCut = CurrentRenameAction->ShortCut;
  911. RemoteEditAction->ShortCut = CurrentEditAction->ShortCut;
  912. RemoteCreateDirAction2->ShortCut = CurrentCreateDirAction->ShortCut;
  913. RemoteDeleteAction->ShortCut = CurrentDeleteAction->ShortCut;
  914. RemotePropertiesAction->ShortCut = CurrentPropertiesAction->ShortCut;
  915. // remote focused operation
  916. RemoteCopyFocusedAction->ShortCut = RemoteCopyAction->ShortCut;
  917. RemoteMoveFocusedAction->ShortCut = RemoteMoveAction->ShortCut;
  918. // selection
  919. LocalSelectAction->ShortCut = SelectAction->ShortCut;
  920. LocalUnselectAction->ShortCut = UnselectAction->ShortCut;
  921. LocalSelectAllAction->ShortCut = SelectAllAction->ShortCut;
  922. RemoteSelectAction->ShortCut = SelectAction->ShortCut;
  923. RemoteUnselectAction->ShortCut = UnselectAction->ShortCut;
  924. RemoteSelectAllAction->ShortCut = SelectAllAction->ShortCut;
  925. }
  926. //---------------------------------------------------------------------------
  927. void __fastcall TNonVisualDataModule::SetScpExplorer(TCustomScpExplorerForm * value)
  928. {
  929. FScpExplorer = value;
  930. SessionIdleTimer->Enabled = (FScpExplorer != NULL);
  931. }
  932. //---------------------------------------------------------------------------
  933. void __fastcall TNonVisualDataModule::SessionIdleTimerTimer(
  934. TObject */*Sender*/)
  935. {
  936. DoIdle();
  937. }
  938. //---------------------------------------------------------------------------
  939. void __fastcall TNonVisualDataModule::DoIdle()
  940. {
  941. if (!FSessionIdleTimerExecuting)
  942. {
  943. FSessionIdleTimerExecuting = true;
  944. try
  945. {
  946. DebugAssert(ScpExplorer);
  947. ScpExplorer->Idle();
  948. }
  949. __finally
  950. {
  951. FSessionIdleTimerExecuting = false;
  952. }
  953. }
  954. }
  955. //---------------------------------------------------------------------------
  956. UnicodeString __fastcall TNonVisualDataModule::CustomCommandCaption(const TCustomCommandType * Command, bool Toolbar)
  957. {
  958. UnicodeString Result = Command->Name;
  959. if (Toolbar)
  960. {
  961. Result = StripHotkey(Result);
  962. Result = EscapeHotkey(Result);
  963. }
  964. return Result;
  965. }
  966. //---------------------------------------------------------------------------
  967. UnicodeString __fastcall TNonVisualDataModule::CustomCommandHint(const TCustomCommandType * Command)
  968. {
  969. UnicodeString Name = StripHotkey(Command->Name);
  970. UnicodeString ShortHint = FMTLOAD(CUSTOM_COMMAND_HINT, (Name));
  971. UnicodeString LongHint =
  972. !Command->Description.IsEmpty() ? Command->Description : FMTLOAD(CUSTOM_COMMAND_HINT_LONG, (Name, Command->Command));
  973. UnicodeString Result = FORMAT(L"%s|%s", (ShortHint, LongHint));
  974. return Result;
  975. }
  976. //---------------------------------------------------------------------------
  977. const int CustomCommandOnFocused = 0x0100;
  978. const int CustomCommandBoth = 0x0200;
  979. const int CustomCommandExtension = 0x0400;
  980. const int CustomCommandIndexMask = 0x00FF;
  981. //---------------------------------------------------------------------------
  982. int __fastcall TNonVisualDataModule::CreateCustomCommandsListMenu(
  983. TCustomCommandList * List, TTBCustomItem * Menu, bool OnFocused, bool Toolbar, TCustomCommandListType ListType, int Tag)
  984. {
  985. int Result = 0;
  986. for (int Index = 0; Index < List->Count; Index++)
  987. {
  988. const TCustomCommandType * Command = List->Commands[Index];
  989. int State = ScpExplorer->CustomCommandState(*Command, OnFocused, ListType);
  990. if (State >= 0)
  991. {
  992. TTBCustomItem * Item = new TTBXItem(Owner);
  993. Item->Caption = CustomCommandCaption(Command, Toolbar);
  994. Item->Tag = Index | Tag;
  995. Item->Enabled = (State > 0);
  996. if (OnFocused)
  997. {
  998. Item->Tag = Item->Tag | CustomCommandOnFocused;
  999. }
  1000. if (ListType == ccltBoth)
  1001. {
  1002. Item->Tag = Item->Tag | CustomCommandBoth;
  1003. }
  1004. Item->Hint = CustomCommandHint(Command);
  1005. if (ListType != ccltBoth)
  1006. {
  1007. Item->ShortCut = Command->ShortCut;
  1008. }
  1009. Item->OnClick = CustomCommandClick;
  1010. Menu->Add(Item);
  1011. Result++;
  1012. }
  1013. }
  1014. return Result;
  1015. }
  1016. //---------------------------------------------------------------------------
  1017. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
  1018. TTBCustomItem * Menu, bool OnFocused, bool Toolbar, TCustomCommandListType ListType)
  1019. {
  1020. CreateCustomCommandsListMenu(WinConfiguration->CustomCommandList, Menu, OnFocused, Toolbar, ListType, 0);
  1021. TTBCustomItem * Item;
  1022. if ((ListType == ccltAll) || (ListType == ccltFile) || (ListType == ccltNonFile))
  1023. {
  1024. Item = new TTBXItem(Menu);
  1025. Item->Action = OnFocused ? CustomCommandsEnterFocusedAction : CustomCommandsEnterAction;
  1026. Menu->Add(Item);
  1027. Item = new TTBXItem(Menu);
  1028. Item->Action = OnFocused ? CustomCommandsLastFocusedAction : CustomCommandsLastAction;
  1029. if (Toolbar)
  1030. {
  1031. Item->Caption = EscapeHotkey(StripHotkey(LoadStr(CUSTOM_COMMAND_LAST_SHORT)));
  1032. }
  1033. Menu->Add(Item);
  1034. }
  1035. TTBXSeparatorItem * Separator = AddMenuSeparator(Menu);
  1036. int ExtensionItems = CreateCustomCommandsListMenu(WinConfiguration->ExtensionList, Menu, OnFocused, Toolbar, ListType, CustomCommandExtension);
  1037. Separator->Visible = (ExtensionItems > 0);
  1038. AddMenuSeparator(Menu);
  1039. if (((ListType == ccltFile) || ((ListType == ccltNonFile) && !OnFocused)) && DebugAlwaysTrue(!Toolbar))
  1040. {
  1041. Item = new TTBXSubmenuItem(Menu);
  1042. // copy the texts from the action, but do not use is as a handler, because it will duplicate the auxiliary commands in the submenu
  1043. Item->Action = (ListType == ccltFile) ? CustomCommandsNonFileAction : CustomCommandsFileAction;
  1044. Item->Action = NULL;
  1045. TCustomCommandListType SubListType = (ListType == ccltFile) ? ccltNonFile : ccltFile;
  1046. int CustomCommandItems = CreateCustomCommandsListMenu(WinConfiguration->CustomCommandList, Item, OnFocused, Toolbar, SubListType, 0);
  1047. TTBXSeparatorItem * Separator = AddMenuSeparator(Item);
  1048. int ExtensionItems = CreateCustomCommandsListMenu(WinConfiguration->ExtensionList, Item, OnFocused, Toolbar, SubListType, CustomCommandExtension);
  1049. Separator->Visible = (ExtensionItems > 0);
  1050. Item->Enabled = (CustomCommandItems + ExtensionItems > 0);
  1051. Menu->Add(Item);
  1052. }
  1053. if (!Toolbar && (ListType != ccltBoth))
  1054. {
  1055. Item = new TTBXItem(Menu);
  1056. Item->Action = CustomCommandsBandAction;
  1057. Menu->Add(Item);
  1058. }
  1059. Item = new TTBXItem(Menu);
  1060. Item->Action = CustomCommandsCustomizeAction;
  1061. Menu->Add(Item);
  1062. }
  1063. //---------------------------------------------------------------------------
  1064. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
  1065. TAction * Action, bool OnFocused, TCustomCommandListType ListType)
  1066. {
  1067. DebugAssert(Action);
  1068. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1069. if (Menu)
  1070. {
  1071. int PrevCount = Menu->Count;
  1072. CreateCustomCommandsMenu(Menu, OnFocused, false, ListType);
  1073. for (int Index = 0; Index < PrevCount; Index++)
  1074. {
  1075. Menu->Delete(0);
  1076. }
  1077. }
  1078. }
  1079. //---------------------------------------------------------------------------
  1080. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(TAction * Action, TCustomCommandListType ListType)
  1081. {
  1082. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1083. if (DebugAlwaysTrue(Menu != NULL))
  1084. {
  1085. bool OnFocused =
  1086. (Menu == RemoteDirViewPopupCustomCommandsMenu) || (Menu == LocalFilePopupCustomCommandsMenu) || (Menu == RemoteFilePopupCustomCommandsMenu);
  1087. CreateCustomCommandsMenu(Action, OnFocused, ListType);
  1088. }
  1089. }
  1090. //---------------------------------------------------------------------------
  1091. bool __fastcall TNonVisualDataModule::CheckCustomCommandsToolbarList(TTBXToolbar * Toolbar, TCustomCommandList * List, int & Index)
  1092. {
  1093. bool Changed = false;
  1094. int CommandIndex = 0;
  1095. while (!Changed && (CommandIndex < List->Count))
  1096. {
  1097. TTBCustomItem * Item = Toolbar->Items->Items[Index];
  1098. const TCustomCommandType * Command = List->Commands[CommandIndex];
  1099. UnicodeString Caption = CustomCommandCaption(Command, true);
  1100. UnicodeString Hint = CustomCommandHint(Command);
  1101. Changed =
  1102. (Item->Caption != Caption) ||
  1103. (Item->Hint != Hint);
  1104. Index++;
  1105. CommandIndex++;
  1106. }
  1107. return Changed;
  1108. }
  1109. //---------------------------------------------------------------------------
  1110. void __fastcall TNonVisualDataModule::UpdateCustomCommandsToolbarList(TTBXToolbar * Toolbar, TCustomCommandList * List, int & Index)
  1111. {
  1112. for (int CommandIndex = 0; CommandIndex < List->Count; CommandIndex++, Index++)
  1113. {
  1114. TTBCustomItem * Item = Toolbar->Items->Items[Index];
  1115. DebugAssert((Item->Tag & CustomCommandIndexMask) == CommandIndex);
  1116. int State = ScpExplorer->CustomCommandState(*List->Commands[CommandIndex], false, ccltAll);
  1117. DebugAssert(State >= 0);
  1118. Item->Enabled = (State > 0);
  1119. }
  1120. }
  1121. //---------------------------------------------------------------------------
  1122. void __fastcall TNonVisualDataModule::UpdateCustomCommandsToolbar(TTBXToolbar * Toolbar)
  1123. {
  1124. // can be called while explorer is being created
  1125. if (ScpExplorer == NULL)
  1126. {
  1127. return;
  1128. }
  1129. TCustomCommandList * CustomCommandList = WinConfiguration->CustomCommandList;
  1130. TCustomCommandList * ExtensionList = WinConfiguration->ExtensionList;
  1131. int AfterCustomCommandsCommandCount = 2; // ad hoc, last
  1132. int AdditionalCommands = AfterCustomCommandsCommandCount + 3; // custom/ext separator + separator, customize
  1133. int CommandCount = CustomCommandList->Count + ExtensionList->Count;
  1134. bool Changed = (CommandCount + AdditionalCommands != Toolbar->Items->Count);
  1135. if (!Changed)
  1136. {
  1137. int Index = 0;
  1138. Changed = CheckCustomCommandsToolbarList(Toolbar, CustomCommandList, Index);
  1139. if (!Changed)
  1140. {
  1141. Index += AfterCustomCommandsCommandCount;
  1142. Changed = (dynamic_cast<TTBXSeparatorItem *>(Toolbar->Items->Items[Index]) == NULL);
  1143. Index++;
  1144. if (!Changed)
  1145. {
  1146. Changed = CheckCustomCommandsToolbarList(Toolbar, ExtensionList, Index);
  1147. }
  1148. }
  1149. }
  1150. if (Changed)
  1151. {
  1152. Toolbar->BeginUpdate();
  1153. try
  1154. {
  1155. Toolbar->Items->Clear();
  1156. CreateCustomCommandsMenu(Toolbar->Items, false, true, ccltAll);
  1157. DebugAssert(CommandCount + AdditionalCommands == Toolbar->Items->Count);
  1158. }
  1159. __finally
  1160. {
  1161. Toolbar->EndUpdate();
  1162. }
  1163. }
  1164. else
  1165. {
  1166. int Index = 0;
  1167. UpdateCustomCommandsToolbarList(Toolbar, CustomCommandList, Index);
  1168. Index += AfterCustomCommandsCommandCount + 1;
  1169. UpdateCustomCommandsToolbarList(Toolbar, ExtensionList, Index);
  1170. }
  1171. }
  1172. //---------------------------------------------------------------------------
  1173. void __fastcall TNonVisualDataModule::CustomCommandClick(TObject * Sender)
  1174. {
  1175. TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
  1176. DebugAssert(Item);
  1177. const TCustomCommandList * List = FLAGSET(Item->Tag, CustomCommandExtension) ? WinConfiguration->ExtensionList : WinConfiguration->CustomCommandList;
  1178. const TCustomCommandType * Command = List->Commands[Item->Tag & CustomCommandIndexMask];
  1179. if (FLAGCLEAR(Item->Tag, CustomCommandBoth))
  1180. {
  1181. ScpExplorer->ExecuteFileOperationCommand(foCustomCommand, osRemote,
  1182. FLAGSET(Item->Tag, CustomCommandOnFocused), false, const_cast<TCustomCommandType *>(Command));
  1183. }
  1184. else
  1185. {
  1186. ScpExplorer->BothCustomCommand(*Command);
  1187. }
  1188. }
  1189. //---------------------------------------------------------------------------
  1190. void __fastcall TNonVisualDataModule::CreateSessionColorMenu(TAction * Action)
  1191. {
  1192. if (DebugAlwaysTrue(Action->ActionComponent != NULL))
  1193. {
  1194. ::CreateSessionColorMenu(Action->ActionComponent, ScpExplorer->SessionColor,
  1195. SessionColorChange);
  1196. }
  1197. }
  1198. //---------------------------------------------------------------------------
  1199. void __fastcall TNonVisualDataModule::SessionColorChange(TColor Color)
  1200. {
  1201. ScpExplorer->SessionColor = Color;
  1202. }
  1203. //---------------------------------------------------------------------------
  1204. void __fastcall TNonVisualDataModule::CreateSessionListMenu(TAction * Action)
  1205. {
  1206. StoredSessions->Reload();
  1207. CreateSessionListMenuLevel(
  1208. dynamic_cast<TTBCustomItem *>(Action->ActionComponent), 0, 0);
  1209. }
  1210. //---------------------------------------------------------------------------
  1211. UnicodeString __fastcall TNonVisualDataModule::GetSessionFolderRoot(
  1212. TSessionData * Data, int Level)
  1213. {
  1214. UnicodeString Path = Data->Name;
  1215. UnicodeString Root;
  1216. for (int ALevel = 0; ALevel < Level; ALevel++)
  1217. {
  1218. Root.Insert(CutToChar(Path, L'/', false) + L'/', Root.Length() + 1);
  1219. }
  1220. return Root;
  1221. }
  1222. //---------------------------------------------------------------------------
  1223. void __fastcall TNonVisualDataModule::CreateSessionListMenuLevel(
  1224. TTBCustomItem * Menu, int Index, int Level)
  1225. {
  1226. Menu->Clear();
  1227. TTBCustomItem * Item = new TTBXItem(Menu);
  1228. UnicodeString Root;
  1229. if (Level == 0)
  1230. {
  1231. Item->Action = SiteManagerAction;
  1232. Root = L"";
  1233. }
  1234. else
  1235. {
  1236. DebugAssert(Index < StoredSessions->Count);
  1237. TSessionData * Data = StoredSessions->Sessions[Index];
  1238. Root = GetSessionFolderRoot(Data, Level);
  1239. Item->Caption = LoadStr(SAVEDSESSIONFOLDER_THIS_OPEN);
  1240. Item->Tag = MAKELONG(Index, Level);
  1241. UnicodeString FolderName = Root;
  1242. if (DebugAlwaysTrue(!FolderName.IsEmpty() && FolderName[FolderName.Length()] == L'/'))
  1243. {
  1244. FolderName.Delete(FolderName.Length(), 1);
  1245. }
  1246. Item->Hint = FMTLOAD(SAVEDSESSIONFOLDER_THIS_HINT, (FolderName));
  1247. Item->OnClick = SessionFolderThisItemClick;
  1248. }
  1249. Menu->Insert(Menu->Count, Item);
  1250. AddMenuSeparator(Menu);
  1251. int FirstSession = Menu->Count;
  1252. UnicodeString PrevName;
  1253. while (Index < StoredSessions->Count)
  1254. {
  1255. TSessionData * Data = StoredSessions->Sessions[Index];
  1256. if (!AnsiSameText(Data->Name.SubString(1, Root.Length()), Root))
  1257. {
  1258. // Sessions are sorted, so no chance further sessions may match
  1259. break;
  1260. }
  1261. else if (!Data->IsWorkspace)
  1262. {
  1263. UnicodeString Name = Data->Name.SubString(Root.Length() + 1, Data->Name.Length() - Root.Length());
  1264. int P = Name.Pos(L'/');
  1265. if (P > 0)
  1266. {
  1267. Name.SetLength(P - 1);
  1268. }
  1269. if (Name != PrevName)
  1270. {
  1271. if (P > 0)
  1272. {
  1273. TTBCustomItem * Item = new TTBXSubmenuItem(Menu);
  1274. Item->Caption = Name;
  1275. Item->Tag = ((Level + 1) << 16) | Index; // MAKELONG
  1276. Item->ImageIndex = SavedSessionsAction2->ImageIndex;
  1277. Item->OnClick = SessionFolderItemClick;
  1278. Menu->Insert(FirstSession, Item);
  1279. FirstSession++;
  1280. }
  1281. else
  1282. {
  1283. TTBCustomItem * Item = new TTBXItem(Menu);
  1284. Item->Caption = Name;
  1285. Item->Tag = Index;
  1286. Item->Hint = FMTLOAD(SAVEDSESSION_HINT, (Data->Name));
  1287. Item->OnClick = SessionItemClick;
  1288. Menu->Insert(Menu->Count, Item);
  1289. }
  1290. PrevName = Name;
  1291. }
  1292. }
  1293. Index++;
  1294. }
  1295. }
  1296. //---------------------------------------------------------------------------
  1297. void __fastcall TNonVisualDataModule::SessionFolderItemClick(TObject * Sender)
  1298. {
  1299. TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
  1300. DebugAssert(Item != NULL);
  1301. CreateSessionListMenuLevel(Item, LOWORD(Item->Tag), HIWORD(Item->Tag));
  1302. }
  1303. //---------------------------------------------------------------------------
  1304. void __fastcall TNonVisualDataModule::SessionFolderThisItemClick(TObject * Sender)
  1305. {
  1306. TTBCustomItem * Item = DebugNotNull(dynamic_cast<TTBCustomItem *>(Sender));
  1307. int Index = LOWORD(Item->Tag);
  1308. int Level = HIWORD(Item->Tag);
  1309. UnicodeString Folder = GetSessionFolderRoot(StoredSessions->Sessions[Index], Level);
  1310. ScpExplorer->OpenFolderOrWorkspace(Folder);
  1311. }
  1312. //---------------------------------------------------------------------------
  1313. void __fastcall TNonVisualDataModule::SessionItemClick(TObject * Sender)
  1314. {
  1315. DebugAssert(StoredSessions && (((TTBCustomItem *)Sender)->Tag < StoredSessions->Count));
  1316. ScpExplorer->OpenStoredSession(StoredSessions->Sessions[((TTBCustomItem *)Sender)->Tag]);
  1317. }
  1318. //---------------------------------------------------------------------------
  1319. void __fastcall TNonVisualDataModule::CreateWorkspacesMenu(TAction * Action)
  1320. {
  1321. StoredSessions->Reload();
  1322. if (!StoredSessions->HasAnyWorkspace())
  1323. {
  1324. Abort();
  1325. }
  1326. else
  1327. {
  1328. TTBCustomItem * Menu =
  1329. DebugNotNull(dynamic_cast<TTBCustomItem *>(Action->ActionComponent));
  1330. Menu->Clear();
  1331. std::unique_ptr<TStrings> Workspaces(StoredSessions->GetWorkspaces());
  1332. for (int Index = 0; Index < Workspaces->Count; Index++)
  1333. {
  1334. TTBCustomItem * Item = new TTBXItem(Menu);
  1335. Item->Caption = Workspaces->Strings[Index];
  1336. Item->Tag = Index;
  1337. Item->Hint = FMTLOAD(WORKSPACE_HINT, (Workspaces->Strings[Index]));
  1338. Item->OnClick = WorkspaceItemClick;
  1339. Menu->Insert(Menu->Count, Item);
  1340. }
  1341. }
  1342. }
  1343. //---------------------------------------------------------------------------
  1344. void __fastcall TNonVisualDataModule::WorkspaceItemClick(TObject * Sender)
  1345. {
  1346. std::unique_ptr<TStrings> Workspaces(StoredSessions->GetWorkspaces());
  1347. ScpExplorer->OpenFolderOrWorkspace(
  1348. Workspaces->Strings[DebugNotNull(dynamic_cast<TTBCustomItem *>(Sender))->Tag]);
  1349. }
  1350. //---------------------------------------------------------------------------
  1351. TShortCut __fastcall TNonVisualDataModule::OpenSessionShortCut(int Index)
  1352. {
  1353. if (Index >= 0 && Index < 10)
  1354. {
  1355. return ShortCut((Word)(Index < 9 ? L'0' + 1 + Index : L'0'),
  1356. TShiftState() << ssAlt);
  1357. }
  1358. else
  1359. {
  1360. return scNone;
  1361. }
  1362. }
  1363. //---------------------------------------------------------------------------
  1364. void __fastcall TNonVisualDataModule::CreateOpenedSessionListMenu(TAction * Action)
  1365. {
  1366. TTBCustomItem * OpenedSessionsMenu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1367. DebugAssert(OpenedSessionsMenu != NULL);
  1368. TTerminalManager * Manager = TTerminalManager::Instance();
  1369. TStrings * TerminalList = Manager->TerminalList;
  1370. int PrevCount = OpenedSessionsMenu->Count;
  1371. for (int Index = 0; Index < TerminalList->Count; Index++)
  1372. {
  1373. TTerminal * Terminal = dynamic_cast<TTerminal *>(TerminalList->Objects[Index]);
  1374. DebugAssert(Terminal);
  1375. TTBCustomItem * Item = new TTBXItem(OpenedSessionsMenu);
  1376. Item->Caption = TerminalList->Strings[Index];
  1377. Item->Tag = int(Terminal);
  1378. Item->Hint = FMTLOAD(OPENEDSESSION_HINT, (Item->Caption));
  1379. Item->Checked = (Manager->ActiveTerminal == Terminal);
  1380. Item->ShortCut = OpenSessionShortCut(Index);
  1381. Item->OnClick = OpenedSessionItemClick;
  1382. Item->RadioItem = true;
  1383. OpenedSessionsMenu->Add(Item);
  1384. }
  1385. for (int Index = 0; Index < PrevCount; Index++)
  1386. {
  1387. OpenedSessionsMenu->Delete(0);
  1388. }
  1389. }
  1390. //---------------------------------------------------------------------------
  1391. void __fastcall TNonVisualDataModule::OpenedSessionItemClick(TObject * Sender)
  1392. {
  1393. TTerminalManager::Instance()->ActiveTerminal = (TManagedTerminal*)(((TMenuItem *)Sender)->Tag);
  1394. }
  1395. //---------------------------------------------------------------------------
  1396. void __fastcall TNonVisualDataModule::CreateEditorListMenu(TTBCustomItem * Menu, bool OnFocused)
  1397. {
  1398. DebugAssert(Menu != NULL);
  1399. int PrevCount = Menu->Count;
  1400. TTBCustomItem * Item;
  1401. Item = new TTBXItem(Menu);
  1402. Item->Action = OnFocused ? CurrentEditFocusedAction : CurrentEditAction;
  1403. Menu->Add(Item);
  1404. AddMenuSeparator(Menu);
  1405. Item = new TTBXItem(Menu);
  1406. Item->Action = OnFocused ? CurrentEditInternalFocusedAction : CurrentEditInternalAction;
  1407. Menu->Add(Item);
  1408. AddMenuSeparator(Menu);
  1409. TStringList * UsedEditors = CreateSortedStringList();
  1410. try
  1411. {
  1412. const TEditorList * EditorList = WinConfiguration->EditorList;
  1413. for (int Index = 0; Index < EditorList->Count; Index++)
  1414. {
  1415. const TEditorPreferences * Editor = EditorList->Editors[Index];
  1416. if ((Editor->Data->Editor == edExternal) &&
  1417. (UsedEditors->IndexOf(Editor->Data->ExternalEditor) < 0))
  1418. {
  1419. UsedEditors->Add(Editor->Data->ExternalEditor);
  1420. TTBCustomItem * Item = new TTBXItem(Menu);
  1421. Item->Caption = Editor->Name;
  1422. Item->Tag = Index;
  1423. Item->Hint = FMTLOAD(EXTERNAL_EDITOR_HINT, (Editor->Name));
  1424. if (OnFocused)
  1425. {
  1426. Item->OnClick = EditorItemClickFocused;
  1427. }
  1428. else
  1429. {
  1430. Item->OnClick = EditorItemClick;
  1431. }
  1432. Menu->Add(Item);
  1433. }
  1434. }
  1435. Item = new TTBXItem(Menu);
  1436. Item->Action = OnFocused ? CurrentEditWithFocusedAction : CurrentEditWithAction;
  1437. Menu->Add(Item);
  1438. AddMenuSeparator(Menu);
  1439. Item = new TTBXItem(Menu);
  1440. Item->Action = EditorListCustomizeAction;
  1441. Menu->Add(Item);
  1442. for (int Index = 0; Index < PrevCount; Index++)
  1443. {
  1444. Menu->Delete(0);
  1445. }
  1446. }
  1447. __finally
  1448. {
  1449. delete UsedEditors;
  1450. }
  1451. }
  1452. //---------------------------------------------------------------------------
  1453. void __fastcall TNonVisualDataModule::DoEditorItemClick(TObject * Sender, bool OnFocused)
  1454. {
  1455. int Tag = dynamic_cast<TTBXItem*>(Sender)->Tag;
  1456. const TEditorList * EditorList = WinConfiguration->EditorList;
  1457. // sanity check
  1458. if (Tag < EditorList->Count)
  1459. {
  1460. ScpExplorer->ExecuteFile(osCurrent, efExternalEditor, EditorList->Editors[Tag]->Data,
  1461. true, OnFocused);
  1462. }
  1463. }
  1464. //---------------------------------------------------------------------------
  1465. void __fastcall TNonVisualDataModule::EditorItemClick(TObject * Sender)
  1466. {
  1467. DoEditorItemClick(Sender, false);
  1468. }
  1469. //---------------------------------------------------------------------------
  1470. void __fastcall TNonVisualDataModule::EditorItemClickFocused(TObject * Sender)
  1471. {
  1472. DoEditorItemClick(Sender, true);
  1473. }
  1474. //---------------------------------------------------------------------------
  1475. void __fastcall TNonVisualDataModule::QueuePopupPopup(TObject * /*Sender*/)
  1476. {
  1477. TAction * Action = NULL;
  1478. switch (ScpExplorer->DefaultQueueOperation())
  1479. {
  1480. case qoItemQuery:
  1481. Action = QueueItemQueryAction;
  1482. break;
  1483. case qoItemError:
  1484. Action = QueueItemErrorAction;
  1485. break;
  1486. case qoItemPrompt:
  1487. Action = QueueItemPromptAction;
  1488. break;
  1489. case qoItemExecute:
  1490. Action = QueueItemExecuteAction;
  1491. break;
  1492. case qoItemPause:
  1493. Action = QueueItemPauseAction;
  1494. break;
  1495. case qoItemResume:
  1496. Action = QueueItemResumeAction;
  1497. break;
  1498. }
  1499. TTBCustomItem * Item;
  1500. for (int Index = 0; Index < QueuePopup->Items->Count; Index++)
  1501. {
  1502. Item = QueuePopup->Items->Items[Index];
  1503. TTBItemOptions O = Item->Options;
  1504. if ((Action != NULL) && (Item->Action == Action))
  1505. {
  1506. O << tboDefault;
  1507. }
  1508. else
  1509. {
  1510. O >> tboDefault;
  1511. }
  1512. Item->Options = O;
  1513. }
  1514. QueueSpeedComboBoxItemUpdate(QueuePopupSpeedComboBoxItem);
  1515. }
  1516. //---------------------------------------------------------------------------
  1517. void __fastcall TNonVisualDataModule::ShowUpdatesUpdate()
  1518. {
  1519. TUpdatesConfiguration Updates = WinConfiguration->Updates;
  1520. unsigned short H, M, S, MS;
  1521. DecodeTime(Now(), H, M, S, MS);
  1522. int CurrentCompoundVer = Configuration->CompoundVersion;
  1523. CheckForUpdatesAction->ImageIndex =
  1524. ((Updates.HaveResults && (Updates.Results.ForVersion == CurrentCompoundVer) &&
  1525. !Updates.Results.Disabled &&
  1526. ((Updates.Results.Critical && !Updates.ShownResults && (MS >= 500)) ||
  1527. ((!Updates.Results.Critical || Updates.ShownResults) &&
  1528. ((Updates.Results.Version > CurrentCompoundVer) ||
  1529. !Updates.Results.Message.IsEmpty())))) ? 80 :
  1530. ((int(Updates.Period) <= 0) ? 81 : 63));
  1531. CheckForUpdatesAction->Visible = !IsUWP();
  1532. }
  1533. //---------------------------------------------------------------------------
  1534. void __fastcall TNonVisualDataModule::PreferencesDialog(TPreferencesMode APreferencesMode)
  1535. {
  1536. if (ScpExplorer != NULL)
  1537. {
  1538. ScpExplorer->PreferencesDialog(APreferencesMode);
  1539. }
  1540. else
  1541. {
  1542. DoPreferencesDialog(APreferencesMode);
  1543. }
  1544. }
  1545. //---------------------------------------------------------------------------
  1546. void __fastcall TNonVisualDataModule::CustomCommandsLastUpdate(TAction * Action)
  1547. {
  1548. TCustomCommandType Command;
  1549. int State;
  1550. bool Defined = ScpExplorer->GetLastCustomCommand(
  1551. (Action == CustomCommandsLastFocusedAction), Command, State);
  1552. Action->Visible = Defined;
  1553. if (Defined)
  1554. {
  1555. UnicodeString TitleCommand = Command.Command;
  1556. int MaxTitleCommandLen = 20;
  1557. if (TitleCommand.Length() > MaxTitleCommandLen)
  1558. {
  1559. TitleCommand = TitleCommand.SubString(1, MaxTitleCommandLen - 3) + Ellipsis;
  1560. }
  1561. Action->Caption = FMTLOAD(CUSTOM_COMMAND_LAST, (EscapeHotkey(TitleCommand)));
  1562. Action->Hint = FMTLOAD(CUSTOM_COMMAND_HINT, (Command.Command));
  1563. Action->Enabled = (State > 0);
  1564. }
  1565. }
  1566. //---------------------------------------------------------------------------
  1567. UnicodeString __fastcall TNonVisualDataModule::QueueItemSpeed(const UnicodeString & Text,
  1568. TTBXComboBoxItem * Item)
  1569. {
  1570. // Keep in sync with TProgressForm::ItemSpeed
  1571. unsigned long Speed = GetSpeedLimit(Text);
  1572. ScpExplorer->ExecuteQueueOperation(qoItemSpeed, reinterpret_cast<void*>(Speed));
  1573. UnicodeString Result = SetSpeedLimit(Speed);
  1574. SaveToHistory(Item->Strings, Result);
  1575. CustomWinConfiguration->History[L"SpeedLimit"] = Item->Strings;
  1576. return Result;
  1577. }
  1578. //---------------------------------------------------------------------------
  1579. void __fastcall TNonVisualDataModule::QueuePopupSpeedComboBoxItemItemClick(
  1580. TObject * Sender)
  1581. {
  1582. TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
  1583. QueueItemSpeedAction->Text = QueueItemSpeed(Item->Text, Item);
  1584. }
  1585. //---------------------------------------------------------------------------
  1586. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemAcceptText(
  1587. TObject * Sender, UnicodeString & NewText, bool & /*Accept*/)
  1588. {
  1589. TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
  1590. NewText = QueueItemSpeed(NewText, Item);
  1591. QueueItemSpeedAction->Text = NewText;
  1592. }
  1593. //---------------------------------------------------------------------------
  1594. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItem(TTBXComboBoxItem * Item)
  1595. {
  1596. // IDE often looses this link
  1597. Item->OnAcceptText = QueueSpeedComboBoxItemAcceptText;
  1598. Item->OnItemClick = QueuePopupSpeedComboBoxItemItemClick;
  1599. }
  1600. //---------------------------------------------------------------------------
  1601. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemUpdate(TTBXComboBoxItem * Item)
  1602. {
  1603. CopySpeedLimits(CustomWinConfiguration->History[L"SpeedLimit"], Item->Strings);
  1604. }
  1605. //---------------------------------------------------------------------------
  1606. void __fastcall TNonVisualDataModule::SetQueueOnceEmptyAction(TAction * Action)
  1607. {
  1608. TAction * Current = CurrentQueueOnceEmptyAction();
  1609. if (Current != Action)
  1610. {
  1611. Current->Checked = false;
  1612. Action->Checked = true;
  1613. }
  1614. }
  1615. //---------------------------------------------------------------------------
  1616. void __fastcall TNonVisualDataModule::CycleQueueOnceEmptyAction()
  1617. {
  1618. TAction * Current = CurrentQueueOnceEmptyAction();
  1619. Current->Checked = false;
  1620. if (Current == QueueIdleOnceEmptyAction)
  1621. {
  1622. QueueDisconnectOnceEmptyAction2->Checked = true;
  1623. }
  1624. else if (Current == QueueDisconnectOnceEmptyAction2)
  1625. {
  1626. QueueSuspendOnceEmptyAction2->Checked = true;
  1627. }
  1628. else if (Current == QueueSuspendOnceEmptyAction2)
  1629. {
  1630. QueueShutDownOnceEmptyAction2->Checked = true;
  1631. }
  1632. else if (Current == QueueShutDownOnceEmptyAction2)
  1633. {
  1634. QueueIdleOnceEmptyAction->Checked = true;
  1635. }
  1636. else
  1637. {
  1638. DebugFail();
  1639. }
  1640. }
  1641. //---------------------------------------------------------------------------
  1642. TAction * __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyAction()
  1643. {
  1644. TAction * Result;
  1645. if (QueueIdleOnceEmptyAction->Checked)
  1646. {
  1647. Result = QueueIdleOnceEmptyAction;
  1648. }
  1649. else if (QueueDisconnectOnceEmptyAction2->Checked)
  1650. {
  1651. Result = QueueDisconnectOnceEmptyAction2;
  1652. }
  1653. else if (QueueSuspendOnceEmptyAction2->Checked)
  1654. {
  1655. Result = QueueSuspendOnceEmptyAction2;
  1656. }
  1657. else if (QueueShutDownOnceEmptyAction2->Checked)
  1658. {
  1659. Result = QueueShutDownOnceEmptyAction2;
  1660. }
  1661. else
  1662. {
  1663. DebugFail();
  1664. }
  1665. return Result;
  1666. }
  1667. //---------------------------------------------------------------------------
  1668. TOnceDoneOperation __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyOperation()
  1669. {
  1670. TOnceDoneOperation Result;
  1671. TBasicAction * Current = CurrentQueueOnceEmptyAction();
  1672. if (Current == QueueIdleOnceEmptyAction)
  1673. {
  1674. Result = odoIdle;
  1675. }
  1676. else if (Current == QueueDisconnectOnceEmptyAction2)
  1677. {
  1678. Result = odoDisconnect;
  1679. }
  1680. else if (Current == QueueSuspendOnceEmptyAction2)
  1681. {
  1682. Result = odoSuspend;
  1683. }
  1684. else if (Current == QueueShutDownOnceEmptyAction2)
  1685. {
  1686. Result = odoShutDown;
  1687. }
  1688. else
  1689. {
  1690. DebugFail();
  1691. }
  1692. return Result;
  1693. }
  1694. //---------------------------------------------------------------------------
  1695. void __fastcall TNonVisualDataModule::ResetQueueOnceEmptyOperation()
  1696. {
  1697. SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction);
  1698. }
  1699. //---------------------------------------------------------------------------
  1700. void __fastcall TNonVisualDataModule::StartBusy()
  1701. {
  1702. FBusy++;
  1703. }
  1704. //---------------------------------------------------------------------------
  1705. void __fastcall TNonVisualDataModule::EndBusy()
  1706. {
  1707. FBusy--;
  1708. }
  1709. //---------------------------------------------------------------------------
  1710. bool __fastcall TNonVisualDataModule::GetBusy()
  1711. {
  1712. return
  1713. (FBusy > 0) ||
  1714. ((ScpExplorer != NULL) && ScpExplorer->IsBusy());
  1715. }
  1716. //---------------------------------------------------------------------------
  1717. void __fastcall TNonVisualDataModule::FocusedEditMenuItemPopup(TTBCustomItem * Sender,
  1718. bool /*FromLink*/)
  1719. {
  1720. CreateEditorListMenu(Sender, true);
  1721. }
  1722. //---------------------------------------------------------------------------
  1723. void __fastcall TNonVisualDataModule::EditMenuItemPopup(TTBCustomItem * Sender,
  1724. bool /*FromLink*/)
  1725. {
  1726. CreateEditorListMenu(Sender, false);
  1727. }
  1728. //---------------------------------------------------------------------------
  1729. void __fastcall TNonVisualDataModule::QueuePopupSpeedComboBoxItemAdjustImageIndex(
  1730. TTBXComboBoxItem * Sender, const UnicodeString /*AText*/, int /*AIndex*/, int & ImageIndex)
  1731. {
  1732. // Use fixed image (do not change image by item index)
  1733. ImageIndex = Sender->ImageIndex;
  1734. }
  1735. //---------------------------------------------------------------------------
  1736. void __fastcall TNonVisualDataModule::ToolbarButtonItemClick(TObject * Sender)
  1737. {
  1738. TTBCustomItem * Item = DebugNotNull(dynamic_cast<TTBCustomItem *>(Sender));
  1739. TTBCustomItem * ButtonItem = reinterpret_cast<TTBCustomItem *>(Item->Tag);
  1740. ButtonItem->Visible = !ButtonItem->Visible;
  1741. }
  1742. //---------------------------------------------------------------------------
  1743. bool __fastcall TNonVisualDataModule::IsCustomizableToolbarItem(TTBCustomItem * Item)
  1744. {
  1745. return
  1746. (dynamic_cast<TTBXItem *>(Item) != NULL) ||
  1747. (dynamic_cast<TTBXSubmenuItem *>(Item) != NULL);
  1748. }
  1749. //---------------------------------------------------------------------------
  1750. bool __fastcall TNonVisualDataModule::IsToolbarCustomizable()
  1751. {
  1752. bool Result = false;
  1753. if (FCustomizedToolbar != NULL)
  1754. {
  1755. for (int Index = 0; Index < FCustomizedToolbar->Items->Count; Index++)
  1756. {
  1757. if (IsCustomizableToolbarItem(FCustomizedToolbar->Items->Items[Index]))
  1758. {
  1759. Result = true;
  1760. break;
  1761. }
  1762. }
  1763. }
  1764. return Result;
  1765. }
  1766. //---------------------------------------------------------------------------
  1767. void __fastcall TNonVisualDataModule::CreateToolbarButtonsList()
  1768. {
  1769. if (FCustomizedToolbar != NULL)
  1770. {
  1771. TTBCustomItem * CustomizeItem = DebugNotNull(dynamic_cast<TTBCustomItem *>(CustomizeToolbarAction->ActionComponent));
  1772. CustomizeItem->Clear();
  1773. for (int Index = 0; Index < FCustomizedToolbar->Items->Count; Index++)
  1774. {
  1775. TTBCustomItem * ButtonItem = FCustomizedToolbar->Items->Items[Index];
  1776. TTBCustomItem * Item = NULL;
  1777. if (dynamic_cast<TTBSeparatorItem *>(ButtonItem) != NULL)
  1778. {
  1779. Item = new TTBSeparatorItem(CustomizeItem);
  1780. }
  1781. else if (IsCustomizableToolbarItem(ButtonItem))
  1782. {
  1783. Item = new TTBXItem(CustomizeItem);
  1784. Item->Caption = StripEllipsis(ButtonItem->Caption);
  1785. Item->ImageIndex = ButtonItem->ImageIndex;
  1786. Item->Tag = reinterpret_cast<int>(ButtonItem);
  1787. Item->OnClick = ToolbarButtonItemClick;
  1788. Item->Checked = ButtonItem->Visible;
  1789. }
  1790. if (Item != NULL)
  1791. {
  1792. CustomizeItem->Insert(CustomizeItem->Count, Item);
  1793. }
  1794. }
  1795. }
  1796. }
  1797. //---------------------------------------------------------------------------
  1798. void __fastcall TNonVisualDataModule::ControlContextPopup(TObject * Sender, const TPoint & MousePos)
  1799. {
  1800. TTBDock * Dock = dynamic_cast<TTBDock *>(Sender);
  1801. if (Dock != NULL)
  1802. {
  1803. // While we can identify toolbar for which context menu is popping up in OnExecute,
  1804. // we cannot in OnUpdate, so we have to remeber it here.
  1805. FCustomizedToolbar = dynamic_cast<TTBCustomToolbar *>(Dock->ControlAtPos(MousePos, true, true, false));
  1806. }
  1807. else
  1808. {
  1809. FCustomizedToolbar = NULL;
  1810. }
  1811. }