NonVisual.cpp 79 KB

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