1
0

NonVisual.cpp 78 KB

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