NonVisual.cpp 77 KB

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