1
0

NonVisual.cpp 81 KB

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