ScpCommander.cpp 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "ScpCommander.h"
  5. #include <Common.h>
  6. #include <CoreMain.h>
  7. #include <Interface.h>
  8. #include <TextsCore.h>
  9. #include <TextsWin.h>
  10. #include <HelpWin.h>
  11. #include <VCLCommon.h>
  12. #include <GUITools.h>
  13. #include <DragDrop.hpp>
  14. #include <StrUtils.hpp>
  15. #include "Glyphs.h"
  16. #include "NonVisual.h"
  17. #include "Tools.h"
  18. #include "WinConfiguration.h"
  19. #include "TerminalManager.h"
  20. //---------------------------------------------------------------------------
  21. #pragma package(smart_init)
  22. #pragma link "CustomDirView"
  23. #pragma link "CustomScpExplorer"
  24. #pragma link "CustomUnixDirView"
  25. #pragma link "IEListView"
  26. #pragma link "NortonLikeListView"
  27. #pragma link "UnixDirView"
  28. #pragma link "DirView"
  29. #pragma link "PathLabel"
  30. #pragma link "HistoryComboBox"
  31. #pragma link "CustomDriveView"
  32. #pragma link "DriveView"
  33. #pragma link "UnixDriveView"
  34. #pragma link "TB2Dock"
  35. #pragma link "TB2Item"
  36. #pragma link "TB2Toolbar"
  37. #pragma link "TBX"
  38. #pragma link "TB2ExtItems"
  39. #pragma link "TBXExtItems"
  40. #pragma link "TBXLists"
  41. #pragma link "TBXStatusBars"
  42. #pragma link "TBXToolPals"
  43. #pragma link "ThemePageControl"
  44. #ifndef NO_RESOURCES
  45. #pragma resource "*.dfm"
  46. #endif
  47. //---------------------------------------------------------------------------
  48. class TSynchronizedBrowsingGuard
  49. {
  50. public:
  51. TSynchronizedBrowsingGuard()
  52. {
  53. FWasSynchronisingBrowsing = NonVisualDataModule->SynchronizeBrowsingAction->Checked;
  54. NonVisualDataModule->SynchronizeBrowsingAction->Checked = false;
  55. }
  56. ~TSynchronizedBrowsingGuard()
  57. {
  58. NonVisualDataModule->SynchronizeBrowsingAction->Checked = FWasSynchronisingBrowsing;
  59. }
  60. private:
  61. bool FWasSynchronisingBrowsing;
  62. };
  63. //---------------------------------------------------------------------------
  64. __fastcall TScpCommanderForm::TScpCommanderForm(TComponent* Owner)
  65. : TCustomScpExplorerForm(Owner)
  66. {
  67. FConstructed = true;
  68. FCurrentSide = osLocal;
  69. FLastLeftPanelWidth = LeftPanelWidth;
  70. FNormalPanelsWidth = -1;
  71. FSynchronisingBrowse = false;
  72. FFirstTerminal = true;
  73. FInternalDDDownloadList = new TStringList();
  74. FLocalPathComboBoxPaths = new TStringList();
  75. RemotePathComboBox->Images = FSystemImageList;
  76. RemotePathComboBox->SubMenuImages = FSystemImageList;
  77. LocalPathComboBox->Images = FSystemImageList;
  78. LocalPathComboBox->SubMenuImages = FSystemImageList;
  79. LocalPathComboUpdateDrives();
  80. LocalBackButton->LinkSubitems = HistoryMenu(osLocal, true)->Items;
  81. LocalForwardButton->LinkSubitems = HistoryMenu(osLocal, false)->Items;
  82. RemoteBackButton->LinkSubitems = HistoryMenu(osRemote, true)->Items;
  83. RemoteForwardButton->LinkSubitems = HistoryMenu(osRemote, false)->Items;
  84. TopDock->PopupMenu = NonVisualDataModule->CommanderBarPopup;
  85. StatusBar->PopupMenu = TopDock->PopupMenu;
  86. QueueDock->PopupMenu = TopDock->PopupMenu;
  87. QueueLabel->PopupMenu = TopDock->PopupMenu;
  88. BottomDock->PopupMenu = TopDock->PopupMenu;
  89. QueueSeparatorPanel->PopupMenu = TopDock->PopupMenu;
  90. LocalTopDock->PopupMenu = NonVisualDataModule->LocalPanelPopup;
  91. LocalPathLabel->PopupMenu = LocalTopDock->PopupMenu;
  92. LocalStatusBar->PopupMenu = LocalTopDock->PopupMenu;
  93. LocalDriveView->PopupMenu = LocalTopDock->PopupMenu;
  94. LocalBottomDock->PopupMenu = LocalTopDock->PopupMenu;
  95. RemoteTopDock->PopupMenu = NonVisualDataModule->RemotePanelPopup;
  96. RemotePathLabel->PopupMenu = RemoteTopDock->PopupMenu;
  97. RemoteStatusBar->PopupMenu = RemoteTopDock->PopupMenu;
  98. RemoteDriveView->PopupMenu = RemoteTopDock->PopupMenu;
  99. RemoteBottomDock->PopupMenu = RemoteTopDock->PopupMenu;
  100. SetShortcuts();
  101. Splitter->ShowHint = True;
  102. reinterpret_cast<TLabel*>(Splitter)->OnDblClick = SplitterDblClick;
  103. reinterpret_cast<TLabel*>(LocalPanelSplitter)->OnDblClick = PanelSplitterDblClick;
  104. reinterpret_cast<TLabel*>(RemotePanelSplitter)->OnDblClick = PanelSplitterDblClick;
  105. CommandLineCombo->Text = L"";
  106. FCommandLineComboPopulated = false;
  107. for (int i = 0; i < Toolbar2Toolbar->Items->Count; i++)
  108. {
  109. UpdateToolbar2ItemCaption(Toolbar2Toolbar->Items->Items[i]);
  110. }
  111. UseDesktopFont(LocalDirView);
  112. UseDesktopFont(LocalDriveView);
  113. UseDesktopFont(LocalPathLabel);
  114. UseDesktopFont(RemotePathLabel);
  115. UseDesktopFont(LocalStatusBar);
  116. UseDesktopFont(StatusBar);
  117. NonVisualDataModule->QueueSpeedComboBoxItem(QueueSpeedComboBoxItem);
  118. // particularly to reorder panels on right-to-left bidi mode
  119. ConfigurationChanged();
  120. }
  121. //---------------------------------------------------------------------------
  122. __fastcall TScpCommanderForm::~TScpCommanderForm()
  123. {
  124. delete FInternalDDDownloadList;
  125. SAFE_DESTROY(FLocalPathComboBoxPaths);
  126. }
  127. //---------------------------------------------------------------------------
  128. void __fastcall TScpCommanderForm::UpdateToolbar2ItemCaption(TTBCustomItem * Item)
  129. {
  130. Item->Caption =
  131. ShortCutToText(Item->ShortCut) + L" " +
  132. Trim(ReplaceStr(StripHotkey(Item->Caption), L"...", L""));
  133. }
  134. //---------------------------------------------------------------------------
  135. void __fastcall TScpCommanderForm::RestoreFormParams()
  136. {
  137. DebugAssert(WinConfiguration);
  138. TCustomScpExplorerForm::RestoreFormParams();
  139. RestoreForm(WinConfiguration->ScpCommander.WindowParams, this);
  140. }
  141. //---------------------------------------------------------------------------
  142. void __fastcall TScpCommanderForm::RestoreParams()
  143. {
  144. DebugAssert(Configuration);
  145. TCustomScpExplorerForm::RestoreParams();
  146. LeftPanelWidth = WinConfiguration->ScpCommander.LocalPanelWidth;
  147. LoadToolbarsLayoutStr(WinConfiguration->ScpCommander.ToolbarsLayout);
  148. SessionsPageControl->Visible = WinConfiguration->ScpCommander.SessionsTabs;
  149. StatusBar->Visible = WinConfiguration->ScpCommander.StatusBar;
  150. #define RESTORE_PANEL_PARAMS(PANEL) \
  151. PANEL ## DirView->ColProperties->ParamsStr = WinConfiguration->ScpCommander.PANEL ## Panel.DirViewParams; \
  152. PANEL ## StatusBar->Visible = WinConfiguration->ScpCommander.PANEL ## Panel.StatusBar; \
  153. PANEL ## DriveView->Visible = WinConfiguration->ScpCommander.PANEL ## Panel.DriveView; \
  154. if (PANEL ## DriveView->Align == alTop) \
  155. PANEL ## DriveView->Height = LoadDimension(WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewHeight, WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewHeightPixelsPerInch); \
  156. else \
  157. PANEL ## DriveView->Width = LoadDimension(WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewWidth, WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewWidthPixelsPerInch)
  158. RESTORE_PANEL_PARAMS(Local);
  159. RESTORE_PANEL_PARAMS(Remote);
  160. #undef RESTORE_PANEL_PARAMS
  161. FPanelsRestored = true;
  162. // just to make sure
  163. LocalDirView->DirColProperties->ExtVisible = false;
  164. RemoteDirView->UnixColProperties->ExtVisible = false;
  165. }
  166. //---------------------------------------------------------------------------
  167. void __fastcall TScpCommanderForm::StoreParams()
  168. {
  169. DebugAssert(WinConfiguration);
  170. WinConfiguration->BeginUpdate();
  171. try
  172. {
  173. WinConfiguration->ScpCommander.ToolbarsLayout = GetToolbarsLayoutStr();
  174. WinConfiguration->ScpCommander.LocalPanelWidth = LeftPanelWidth;
  175. WinConfiguration->ScpCommander.SessionsTabs = SessionsPageControl->Visible;
  176. WinConfiguration->ScpCommander.StatusBar = StatusBar->Visible;
  177. SaveCommandLine();
  178. WinConfiguration->ScpCommander.CurrentPanel = FCurrentSide;
  179. #define STORE_PANEL_PARAMS(PANEL) \
  180. WinConfiguration->ScpCommander.PANEL ## Panel.DirViewParams = PANEL ## DirView->ColProperties->ParamsStr; \
  181. WinConfiguration->ScpCommander.PANEL ## Panel.StatusBar = PANEL ## StatusBar->Visible; \
  182. WinConfiguration->ScpCommander.PANEL ## Panel.DriveView = PANEL ## DriveView->Visible; \
  183. if (PANEL ## DriveView->Align == alTop) \
  184. { \
  185. WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewHeight = PANEL ## DriveView->Height; \
  186. WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewHeightPixelsPerInch = Screen->PixelsPerInch; \
  187. } \
  188. else \
  189. { \
  190. WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewWidth = PANEL ## DriveView->Width; \
  191. WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewWidthPixelsPerInch = Screen->PixelsPerInch; \
  192. }
  193. STORE_PANEL_PARAMS(Local);
  194. STORE_PANEL_PARAMS(Remote);
  195. #undef RESTORE_PANEL_PARAMS
  196. WinConfiguration->ScpCommander.WindowParams = StoreForm(this);
  197. TCustomScpExplorerForm::StoreParams();
  198. }
  199. __finally
  200. {
  201. WinConfiguration->EndUpdate();
  202. }
  203. }
  204. //---------------------------------------------------------------------------
  205. void __fastcall TScpCommanderForm::UpdateTerminal(TTerminal * Terminal)
  206. {
  207. TCustomScpExplorerForm::UpdateTerminal(Terminal);
  208. TManagedTerminal * ManagedTerminal = dynamic_cast<TManagedTerminal *>(Terminal);
  209. DebugAssert(ManagedTerminal != NULL);
  210. DebugAssert(LocalDirView != NULL);
  211. SAFE_DESTROY(ManagedTerminal->LocalExplorerState);
  212. if (WinConfiguration->PreservePanelState)
  213. {
  214. ManagedTerminal->LocalExplorerState = LocalDirView->SaveState();
  215. }
  216. }
  217. //---------------------------------------------------------------------------
  218. void __fastcall TScpCommanderForm::UpdateSessionData(TSessionData * Data)
  219. {
  220. // Keep in sync with TSessionData::CopyStateData
  221. TCustomScpExplorerForm::UpdateSessionData(Data);
  222. DebugAssert(LocalDirView);
  223. Data->LocalDirectory = LocalDirView->PathName;
  224. Data->SynchronizeBrowsing = NonVisualDataModule->SynchronizeBrowsingAction->Checked;
  225. }
  226. //---------------------------------------------------------------------------
  227. bool __fastcall TScpCommanderForm::InternalDDDownload(UnicodeString & TargetDirectory)
  228. {
  229. DebugAssert(IsFileControl(FDDTargetControl, osLocal));
  230. bool Result = false;
  231. if (FDDTargetControl == LocalDirView)
  232. {
  233. if (LocalDirView->DropTarget)
  234. {
  235. // when drop target is not directory, it is probably file type, which have
  236. // associated drop handler (such as ZIP file in WinXP). in this case we
  237. // must leave drop handling to destination application.
  238. // ! this check is duplicated in LocalDirViewDDTargetHasDropHandler()
  239. // for shellex downloads
  240. if (LocalDirView->ItemIsDirectory(LocalDirView->DropTarget))
  241. {
  242. TargetDirectory = LocalDirView->ItemFullFileName(LocalDirView->DropTarget);
  243. Result = true;
  244. }
  245. }
  246. else
  247. {
  248. TargetDirectory = DefaultDownloadTargetDirectory();
  249. Result = true;
  250. }
  251. }
  252. else if (FDDTargetControl == LocalDriveView)
  253. {
  254. DebugAssert(LocalDriveView->DropTarget != NULL);
  255. TargetDirectory = LocalDriveView->NodePathName(LocalDriveView->DropTarget);
  256. Result = true;
  257. }
  258. else
  259. {
  260. DebugFail();
  261. Abort();
  262. }
  263. return Result;
  264. }
  265. //---------------------------------------------------------------------------
  266. UnicodeString __fastcall TScpCommanderForm::DefaultDownloadTargetDirectory()
  267. {
  268. return IncludeTrailingBackslash(LocalDirView->Path);
  269. }
  270. //---------------------------------------------------------------------------
  271. bool __fastcall TScpCommanderForm::CopyParamDialog(TTransferDirection Direction,
  272. TTransferType Type, bool Temp, TStrings * FileList, UnicodeString & TargetDirectory,
  273. TGUICopyParamType & CopyParam, bool Confirm, bool DragDrop, int Options)
  274. {
  275. bool Result = false;
  276. // Temp means d&d here so far, may change in future!
  277. if (Temp && (Direction == tdToLocal) &&
  278. IsFileControl(FDDTargetControl, osLocal))
  279. {
  280. Result = InternalDDDownload(TargetDirectory);
  281. if (Result)
  282. {
  283. DebugAssert(FileList->Count > 0);
  284. FInternalDDDownloadList->Assign(FileList);
  285. }
  286. }
  287. else if (!Temp && TargetDirectory.IsEmpty())
  288. {
  289. if (Direction == tdToLocal)
  290. {
  291. TargetDirectory = DefaultDownloadTargetDirectory();
  292. }
  293. else
  294. {
  295. TargetDirectory = UnixIncludeTrailingBackslash(RemoteDirView->Path);
  296. }
  297. }
  298. if (!Result)
  299. {
  300. Result = TCustomScpExplorerForm::CopyParamDialog(Direction, Type, Temp,
  301. FileList, TargetDirectory, CopyParam, Confirm, DragDrop, Options);
  302. }
  303. return Result;
  304. }
  305. //---------------------------------------------------------------------------
  306. void __fastcall TScpCommanderForm::DoShow()
  307. {
  308. // Make sure the RemoteDirView is disabled (if not connected yet)
  309. // before the focusing below,
  310. // otherwise we disable the view while setting it focused
  311. // (UpdateControls gets calling within the SetFocus),
  312. // leading to VCL focus inconsistency wih Windows,
  313. // and the view [anothing actually] not getting focused after the session
  314. // is finally connected
  315. UpdateControls();
  316. // If we do not call SetFocus on any control before DoShow,
  317. // no control will get focused on Login dialog
  318. // (HACK seems like a bug in VCL)
  319. if (WinConfiguration->ScpCommander.CurrentPanel == osLocal)
  320. {
  321. LocalDirView->SetFocus();
  322. FRemoteDirViewWasFocused = false;
  323. }
  324. else
  325. {
  326. if (RemoteDirView->Enabled)
  327. {
  328. RemoteDirView->SetFocus();
  329. }
  330. else
  331. {
  332. LocalDirView->SetFocus();
  333. }
  334. FRemoteDirViewWasFocused = true;
  335. }
  336. TCustomScpExplorerForm::DoShow();
  337. }
  338. //---------------------------------------------------------------------------
  339. Boolean __fastcall TScpCommanderForm::AllowedAction(TAction * Action, TActionAllowed Allowed)
  340. {
  341. #define FLAG ((TActionFlag)(Action->Tag))
  342. return
  343. TCustomScpExplorerForm::AllowedAction(Action, Allowed) &&
  344. // always require Commander flag
  345. (FLAG & afCommander) &&
  346. // if action is execution or update, we don't require any other flag
  347. // if we check for shortcut, we require proper dirview to be selected
  348. ((Allowed != aaShortCut) ||
  349. ((FLAG & afLocal) && (FCurrentSide == osLocal)) ||
  350. ((FLAG & afRemote) && (FCurrentSide == osRemote))
  351. );
  352. #undef FLAG
  353. }
  354. //---------------------------------------------------------------------------
  355. TCustomDirView * __fastcall TScpCommanderForm::DirView(TOperationSide Side)
  356. {
  357. Side = GetSide(Side);
  358. if (Side == osLocal)
  359. {
  360. return LocalDirView;
  361. }
  362. else
  363. {
  364. return TCustomScpExplorerForm::DirView(Side);
  365. }
  366. }
  367. //---------------------------------------------------------------------------
  368. bool __fastcall TScpCommanderForm::DirViewEnabled(TOperationSide Side)
  369. {
  370. Side = GetSide(Side);
  371. if (Side == osLocal)
  372. {
  373. return true;
  374. }
  375. else
  376. {
  377. return TCustomScpExplorerForm::DirViewEnabled(Side);
  378. }
  379. }
  380. //---------------------------------------------------------------------------
  381. bool __fastcall TScpCommanderForm::IsFileControl(TObject * Control,
  382. TOperationSide Side)
  383. {
  384. return
  385. ((Side == osLocal) &&
  386. ((Control == LocalDirView) || (Control == LocalDriveView))) ||
  387. TCustomScpExplorerForm::IsFileControl(Control, Side);
  388. }
  389. //---------------------------------------------------------------------------
  390. void __fastcall TScpCommanderForm::ReloadLocalDirectory(const UnicodeString Directory)
  391. {
  392. if (Directory.IsEmpty() || ComparePaths(Directory, LocalDirView->Path))
  393. {
  394. LocalDirView->ReloadDirectory();
  395. LocalDriveView->ValidateDirectory(LocalDriveView->Selected);
  396. }
  397. TCustomScpExplorerForm::ReloadLocalDirectory();
  398. }
  399. //---------------------------------------------------------------------------
  400. void __fastcall TScpCommanderForm::BatchStart(void *& Storage)
  401. {
  402. Storage = new bool;
  403. *static_cast<bool*>(Storage) = LocalDirView->WatchForChanges;
  404. LocalDirView->WatchForChanges = false;
  405. LocalDriveView->WatchDirectory = false;
  406. TCustomScpExplorerForm::BatchStart(Storage);
  407. }
  408. //---------------------------------------------------------------------------
  409. void __fastcall TScpCommanderForm::BatchEnd(void * Storage)
  410. {
  411. TCustomScpExplorerForm::BatchEnd(Storage);
  412. DebugAssert(Storage != NULL);
  413. LocalDirView->WatchForChanges = *static_cast<bool*>(Storage);
  414. LocalDriveView->WatchDirectory = LocalDirView->WatchForChanges;
  415. delete Storage;
  416. }
  417. //---------------------------------------------------------------------------
  418. void __fastcall TScpCommanderForm::StartingDisconnected()
  419. {
  420. TCustomScpExplorerForm::StartingDisconnected();
  421. LocalDefaultDirectory();
  422. }
  423. //---------------------------------------------------------------------------
  424. void __fastcall TScpCommanderForm::TerminalChanged()
  425. {
  426. NonVisualDataModule->SynchronizeBrowsingAction->Checked = false;
  427. TCustomScpExplorerForm::TerminalChanged();
  428. if (Terminal)
  429. {
  430. // we will load completelly different directory, so particularly
  431. // do not attempt to select previously selected directory
  432. LocalDirView->ContinueSession(false);
  433. TManagedTerminal * ManagedTerminal = dynamic_cast<TManagedTerminal *>(Terminal);
  434. DebugAssert(ManagedTerminal != NULL);
  435. // reset home directory
  436. LocalDirView->HomeDirectory = L"";
  437. if (FFirstTerminal || !WinConfiguration->ScpCommander.PreserveLocalDirectory)
  438. {
  439. UnicodeString LocalDirectory = ManagedTerminal->StateData->LocalDirectory;
  440. bool DocumentsDir = LocalDirectory.IsEmpty();
  441. if (!DocumentsDir)
  442. {
  443. try
  444. {
  445. LocalDirView->Path = LocalDirectory;
  446. }
  447. catch(Exception & E)
  448. {
  449. DocumentsDir = true;
  450. Terminal->ShowExtendedException(&E);
  451. }
  452. }
  453. if (DocumentsDir)
  454. {
  455. LocalDefaultDirectory();
  456. }
  457. }
  458. FFirstTerminal = false;
  459. if (WinConfiguration->DefaultDirIsHome &&
  460. !Terminal->SessionData->UpdateDirectories)
  461. {
  462. LocalDirView->HomeDirectory = ExpandFileName(Terminal->SessionData->LocalDirectory);
  463. }
  464. if (WinConfiguration->PreservePanelState &&
  465. !WinConfiguration->ScpCommander.PreserveLocalDirectory)
  466. {
  467. if (ManagedTerminal->LocalExplorerState != NULL)
  468. {
  469. LocalDirView->RestoreState(ManagedTerminal->LocalExplorerState);
  470. }
  471. else
  472. {
  473. LocalDirView->ClearState();
  474. }
  475. NonVisualDataModule->SynchronizeBrowsingAction->Checked = ManagedTerminal->StateData->SynchronizeBrowsing;
  476. }
  477. }
  478. }
  479. //---------------------------------------------------------------------------
  480. void __fastcall TScpCommanderForm::LocalDefaultDirectory()
  481. {
  482. try
  483. {
  484. LocalDirView->HomeDirectory = L"";
  485. LocalDirView->ExecuteHomeDirectory();
  486. }
  487. catch(Exception & E)
  488. {
  489. Terminal->ShowExtendedException(&E);
  490. LocalDirView->Path = ExtractFilePath(Application->ExeName);
  491. }
  492. }
  493. //---------------------------------------------------------------------------
  494. void __fastcall TScpCommanderForm::ConfigurationChanged()
  495. {
  496. TCustomScpExplorerForm::ConfigurationChanged();
  497. if (WinConfiguration->DefaultDirIsHome && Terminal &&
  498. !Terminal->SessionData->UpdateDirectories)
  499. {
  500. LocalDirView->HomeDirectory = ExpandFileName(Terminal->SessionData->LocalDirectory);
  501. }
  502. else
  503. {
  504. LocalDirView->HomeDirectory = L"";
  505. }
  506. LocalDirView->DimmHiddenFiles = WinConfiguration->DimmHiddenFiles;
  507. LocalDriveView->DimmHiddenDirs = WinConfiguration->DimmHiddenFiles;
  508. LocalDirView->ShowHiddenFiles = WinConfiguration->ShowHiddenFiles;
  509. LocalDirView->FormatSizeBytes = WinConfiguration->FormatSizeBytes;
  510. LocalDriveView->ShowHiddenDirs = WinConfiguration->ShowHiddenFiles;
  511. LocalDirView->ConfirmOverwrite = WinConfiguration->ConfirmOverwriting;
  512. LocalDriveView->ConfirmOverwrite = WinConfiguration->ConfirmOverwriting;
  513. LocalDirView->NortonLike = WinConfiguration->ScpCommander.NortonLikeMode;
  514. RemoteDirView->NortonLike = WinConfiguration->ScpCommander.NortonLikeMode;
  515. if (LocalDirView->RowSelect != WinConfiguration->FullRowSelect)
  516. {
  517. LocalDirView->RowSelect = WinConfiguration->FullRowSelect;
  518. // selection is not redrawn automatically when RowSelect changes
  519. LocalDirView->Invalidate();
  520. }
  521. // See also LocalDirViewDDTargetHasDropHandler
  522. LocalDirView->DragDropFilesEx->ShellExtensions->DropHandler =
  523. !WinConfiguration->DDExtEnabled;
  524. LocalDriveView->DragDropFilesEx->ShellExtensions->DropHandler =
  525. !WinConfiguration->DDExtEnabled;
  526. if (Panel(true)->Left > Panel(false)->Left)
  527. {
  528. DisableAlign();
  529. try
  530. {
  531. int AWidth = ClientWidth;
  532. Panel(false)->Align = alClient;
  533. // In bidi mode it gets swapped to alRight, what does not work with the rest of this logic
  534. Splitter->Align = alLeft;
  535. Panel(true)->Align = alLeft;
  536. TControl * ControlsOrder[] =
  537. { Panel(true), Splitter, Panel(false) };
  538. SetHorizontalControlsOrder(ControlsOrder, LENOF(ControlsOrder));
  539. Panel(true)->TabOrder = 0;
  540. Panel(false)->TabOrder = 1;
  541. ClientWidth = AWidth;
  542. LeftPanelWidth = FLastLeftPanelWidth;
  543. }
  544. __finally
  545. {
  546. EnableAlign();
  547. }
  548. int LocalIndex = MenuToolbar->Items->IndexOf(LocalMenuButton);
  549. int RemoteIndex = MenuToolbar->Items->IndexOf(RemoteMenuButton);
  550. MenuToolbar->Items->Move(LocalIndex, RemoteIndex);
  551. RemoteIndex = MenuToolbar->Items->IndexOf(RemoteMenuButton);
  552. MenuToolbar->Items->Move(RemoteIndex, LocalIndex);
  553. SWAP(TShortCut, NonVisualDataModule->LocalChangePathAction->ShortCut,
  554. NonVisualDataModule->RemoteChangePathAction->ShortCut);
  555. }
  556. if ((RemoteDriveView->Align == alLeft) != WinConfiguration->ScpCommander.TreeOnLeft)
  557. {
  558. TScpCommanderPanelConfiguration LocalPanel = WinConfiguration->ScpCommander.LocalPanel;
  559. TScpCommanderPanelConfiguration RemotePanel = WinConfiguration->ScpCommander.RemotePanel;
  560. bool TreeOnLeft = WinConfiguration->ScpCommander.TreeOnLeft;
  561. // save value only is it was set yet
  562. if (FPanelsRestored)
  563. {
  564. if (TreeOnLeft)
  565. {
  566. // want to be on left, so it is on top, saving height
  567. LocalPanel.DriveViewHeight = LocalDriveView->Height;
  568. RemotePanel.DriveViewHeight = RemoteDriveView->Height;
  569. }
  570. else
  571. {
  572. LocalPanel.DriveViewWidth = LocalDriveView->Width;
  573. RemotePanel.DriveViewWidth = RemoteDriveView->Width;
  574. }
  575. }
  576. TAlign NonClientAlign = (TreeOnLeft ? alLeft : alTop);
  577. // VCL adjusts cursors only between crVSplit and crHSplit,
  578. // See TSplitter.RequestAlign
  579. TCursor SplitterCursor = (TreeOnLeft ? crSizeWE : crSizeNS);
  580. LocalDriveView->Align = NonClientAlign;
  581. LocalPanelSplitter->Align = NonClientAlign;
  582. LocalPanelSplitter->Cursor = SplitterCursor;
  583. RemoteDriveView->Align = NonClientAlign;
  584. RemotePanelSplitter->Align = NonClientAlign;
  585. RemotePanelSplitter->Cursor = SplitterCursor;
  586. FixControlsPlacement();
  587. if (TreeOnLeft)
  588. {
  589. LocalDriveView->Width = LocalPanel.DriveViewWidth;
  590. RemoteDriveView->Width = RemotePanel.DriveViewWidth;
  591. }
  592. else
  593. {
  594. LocalDriveView->Height = LocalPanel.DriveViewHeight;
  595. RemoteDriveView->Height = RemotePanel.DriveViewHeight;
  596. }
  597. // in case it trigges config-changed event (does not),
  598. // make sure it does only after we apply the TreeOnLeft change to avoid endless recursion
  599. WinConfiguration->ScpCommander.LocalPanel = LocalPanel;
  600. WinConfiguration->ScpCommander.RemotePanel = RemotePanel;
  601. }
  602. if (FExplorerKeyboardShortcuts != WinConfiguration->ScpCommander.ExplorerKeyboardShortcuts)
  603. {
  604. SetShortcuts();
  605. }
  606. }
  607. //---------------------------------------------------------------------------
  608. void __fastcall TScpCommanderForm::SetShortcuts()
  609. {
  610. // set common norton shorcuts to our actions
  611. NonVisualDataModule->CommanderShortcuts();
  612. FExplorerKeyboardShortcuts = WinConfiguration->ScpCommander.ExplorerKeyboardShortcuts;
  613. }
  614. //---------------------------------------------------------------------------
  615. TPanel * __fastcall TScpCommanderForm::Panel(bool Left)
  616. {
  617. bool SwappedPanels = WinConfiguration->ScpCommander.SwappedPanels;
  618. if (IsRightToLeft())
  619. {
  620. SwappedPanels = !SwappedPanels;
  621. }
  622. return (SwappedPanels == Left ? RemotePanel : LocalPanel);
  623. }
  624. //---------------------------------------------------------------------------
  625. TPanel * __fastcall TScpCommanderForm::CurrentPanel()
  626. {
  627. return (FCurrentSide == osLocal ? LocalPanel : RemotePanel);
  628. }
  629. //---------------------------------------------------------------------------
  630. void __fastcall TScpCommanderForm::SetLeftPanelWidth(double value)
  631. {
  632. double Total = LocalPanel->Width + RemotePanel->Width;
  633. FLeftPanelWidth = value;
  634. if (value * Total != Panel(true)->Width)
  635. {
  636. Panel(true)->Width = static_cast<int>(value * Total);
  637. UpdateControls();
  638. }
  639. }
  640. //---------------------------------------------------------------------------
  641. double __fastcall TScpCommanderForm::GetLeftPanelWidth()
  642. {
  643. return FLeftPanelWidth;
  644. }
  645. //---------------------------------------------------------------------------
  646. void __fastcall TScpCommanderForm::SplitterMoved(TObject * /*Sender*/)
  647. {
  648. double Left = Panel(true)->Width;
  649. double Total = LocalPanel->Width + RemotePanel->Width;
  650. FLeftPanelWidth = Left / Total;
  651. FLastLeftPanelWidth = LeftPanelWidth;
  652. UpdateControls();
  653. }
  654. //---------------------------------------------------------------------------
  655. void __fastcall TScpCommanderForm::SplitterCanResize(TObject * /*Sender*/,
  656. int &NewSize, bool & /*Accept*/)
  657. {
  658. // When splitter is drag so far to right, that width contraint of remote panel would
  659. // be violated, it doesn't stop, but extend form width.
  660. // Following prevents this behavior.
  661. if (ClientWidth - NewSize - Splitter->Width < Panel(false)->Constraints->MinWidth)
  662. NewSize = (ClientWidth - Panel(false)->Constraints->MinWidth - Splitter->Width);
  663. }
  664. //---------------------------------------------------------------------------
  665. void __fastcall TScpCommanderForm::SplitterDblClick(TObject * /*Sender*/)
  666. {
  667. LeftPanelWidth = 0.5;
  668. }
  669. //---------------------------------------------------------------------------
  670. void __fastcall TScpCommanderForm::PanelSplitterDblClick(TObject * Sender)
  671. {
  672. TSplitter * Splitter = dynamic_cast<TSplitter *>(Sender);
  673. DebugAssert(Splitter != NULL);
  674. TCustomDriveView * DriveView;
  675. TCustomDriveView * OtherDriveView;
  676. if (Splitter == LocalPanelSplitter)
  677. {
  678. DriveView = LocalDriveView;
  679. OtherDriveView = RemoteDriveView;
  680. }
  681. else
  682. {
  683. DriveView = RemoteDriveView;
  684. OtherDriveView = LocalDriveView;
  685. }
  686. bool TreeOnLeft = WinConfiguration->ScpCommander.TreeOnLeft;
  687. DebugAssert(DriveView->Visible);
  688. if (OtherDriveView->Visible)
  689. {
  690. if (TreeOnLeft)
  691. {
  692. DriveView->Width = OtherDriveView->Width;
  693. }
  694. else
  695. {
  696. DriveView->Height = OtherDriveView->Height;
  697. }
  698. }
  699. else
  700. {
  701. if (TreeOnLeft)
  702. {
  703. OtherDriveView->Width = DriveView->Width;
  704. }
  705. else
  706. {
  707. OtherDriveView->Height = DriveView->Height;
  708. }
  709. OtherDriveView->Visible = true;
  710. }
  711. FixControlsPlacement();
  712. }
  713. //---------------------------------------------------------------------------
  714. void __fastcall TScpCommanderForm::UpdateControls()
  715. {
  716. TCustomScpExplorerForm::UpdateControls();
  717. UnicodeString SplitterLongHint = Splitter->Hint;
  718. SplitterLongHint.Delete(1, SplitterLongHint.Pos(L"|"));
  719. Splitter->Hint = FORMAT(L"%0.0f%%|%s", (LeftPanelWidth*100, SplitterLongHint));
  720. UnicodeString ACommandLinePromptLabel = LoadStr(COMMAND_LINE_LABEL) + " " +
  721. ((FCurrentSide == osRemote) ? L"$" : L">");
  722. if (CommandLinePromptLabel->Caption != ACommandLinePromptLabel)
  723. {
  724. CommandLinePromptLabel->Caption = ACommandLinePromptLabel;
  725. // command line combo width needs to be updated as caption width has probably changed
  726. ToolBarResize(CommandLineToolbar);
  727. }
  728. LocalDirView->Color = (SessionColor != 0 ? SessionColor : clWindow);
  729. LocalDriveView->Color = LocalDirView->Color;
  730. bool LocalSide = (FCurrentSide == osLocal);
  731. TAction * CurrentCopyAction = LocalSide ? NonVisualDataModule->LocalCopyAction : NonVisualDataModule->RemoteCopyAction;
  732. if (CurrentCopyItem->Action != CurrentCopyAction)
  733. {
  734. CurrentCopyItem->Action = CurrentCopyAction;
  735. CurrentCopyToolbar2Item->Action = CurrentCopyAction;
  736. UpdateToolbar2ItemCaption(CurrentCopyToolbar2Item);
  737. CurrentCopyNonQueueItem->Action = LocalSide ? NonVisualDataModule->LocalCopyNonQueueAction : NonVisualDataModule->RemoteCopyNonQueueAction;
  738. CurrentCopyQueueItem->Action = LocalSide ? NonVisualDataModule->LocalCopyQueueAction : NonVisualDataModule->RemoteCopyQueueAction;
  739. TAction * CurrentMoveAction = LocalSide ? NonVisualDataModule->LocalMoveAction : NonVisualDataModule->RemoteMoveAction;
  740. CurrentMoveItem->Action = CurrentMoveAction;
  741. CurrentMoveToolbar2Item->Action = CurrentMoveAction;
  742. UpdateToolbar2ItemCaption(CurrentMoveToolbar2Item);
  743. }
  744. CommandLineCombo->Enabled = (Terminal != NULL);
  745. CommandLinePromptLabel->Enabled = CommandLineCombo->Enabled;
  746. }
  747. //---------------------------------------------------------------------------
  748. void __fastcall TScpCommanderForm::ChangePath(TOperationSide Side)
  749. {
  750. DebugAssert((Side == osLocal) || (Side == osRemote));
  751. TTBXComboBoxItem * PathComboBox;
  752. if (Side == osLocal)
  753. {
  754. PathComboBox = LocalPathComboBox;
  755. }
  756. else
  757. {
  758. PathComboBox = RemotePathComboBox;
  759. }
  760. ClickToolbarItem(PathComboBox, false);
  761. }
  762. //---------------------------------------------------------------------------
  763. TControl * __fastcall TScpCommanderForm::GetComponent(Byte Component)
  764. {
  765. switch (Component) {
  766. case fcToolBar2: return Toolbar2Toolbar; // name changed to enforce change of default visibility
  767. case fcStatusBar: return StatusBar;
  768. case fcLocalStatusBar: return LocalStatusBar;
  769. case fcRemoteStatusBar: return RemoteStatusBar;
  770. case fcCommandLinePanel: return CommandLineToolbar;
  771. case fcLocalTree: return LocalDriveView;
  772. case fcSessionToolbar: return SessionToolbar;
  773. case fcCustomCommandsBand: return CustomCommandsToolbar;
  774. case fcColorMenu: return reinterpret_cast<TControl*>(ColorMenuItem);
  775. case fcTransferDropDown: return reinterpret_cast<TControl*>(TransferDropDown);
  776. case fcTransferList: return reinterpret_cast<TControl*>(TransferList);
  777. case fcTransferLabel: return reinterpret_cast<TControl*>(TransferLabel);
  778. case fcLocalPopup: return reinterpret_cast<TControl *>(NonVisualDataModule->LocalFilePopup);
  779. case fcRemotePathComboBox: return reinterpret_cast<TControl*>(RemotePathComboBox);
  780. case fcCommanderMenuBand: return MenuToolbar;
  781. case fcCommanderSessionBand: return SessionToolbar;
  782. case fcCommanderPreferencesBand: return PreferencesToolbar;
  783. case fcCommanderSortBand: return SortToolbar;
  784. case fcCommanderCommandsBand: return CommandsToolbar;
  785. case fcCommanderUpdatesBand: return UpdatesToolbar;
  786. case fcCommanderTransferBand: return TransferToolbar;
  787. case fcCommanderCustomCommandsBand: return CustomCommandsToolbar;
  788. case fcCommanderLocalHistoryBand: return LocalHistoryToolbar;
  789. case fcCommanderLocalNavigationBand: return LocalNavigationToolbar;
  790. case fcCommanderLocalFileBand: return LocalFileToolbar;
  791. case fcCommanderLocalSelectionBand: return LocalSelectionToolbar;
  792. case fcCommanderRemoteHistoryBand: return RemoteHistoryToolbar;
  793. case fcCommanderRemoteNavigationBand: return RemoteNavigationToolbar;
  794. case fcCommanderRemoteFileBand: return RemoteFileToolbar;
  795. case fcCommanderRemoteSelectionBand: return RemoteSelectionToolbar;
  796. default: return TCustomScpExplorerForm::GetComponent(Component);
  797. }
  798. }
  799. //---------------------------------------------------------------------------
  800. void __fastcall TScpCommanderForm::FixControlsPlacement()
  801. {
  802. TCustomScpExplorerForm::FixControlsPlacement();
  803. QueueSeparatorPanel->Visible = QueuePanel->Visible;
  804. LocalPanelSplitter->Visible = LocalDriveView->Visible;
  805. TControl * ControlsOrder[] =
  806. { BottomDock, QueueSeparatorPanel, QueueSplitter, QueuePanel, StatusBar };
  807. SetVerticalControlsOrder(ControlsOrder, LENOF(ControlsOrder));
  808. TControl * LocalControlsOrder[] =
  809. { LocalTopDock, LocalPathLabel, LocalDriveView, LocalPanelSplitter,
  810. LocalDirView, LocalBottomDock, LocalStatusBar };
  811. SetVerticalControlsOrder(LocalControlsOrder, LENOF(LocalControlsOrder));
  812. SetHorizontalControlsOrder(LocalControlsOrder, LENOF(LocalControlsOrder));
  813. TControl * RemoteControlsOrder[] =
  814. { RemoteTopDock, RemotePathLabel, RemoteDriveView, RemotePanelSplitter,
  815. RemoteDirView, RemoteBottomDock, RemoteStatusBar };
  816. SetVerticalControlsOrder(RemoteControlsOrder, LENOF(RemoteControlsOrder));
  817. SetHorizontalControlsOrder(RemoteControlsOrder, LENOF(RemoteControlsOrder));
  818. if (LocalDirView->ItemFocused != NULL)
  819. {
  820. LocalDirView->ItemFocused->MakeVisible(false);
  821. }
  822. }
  823. //---------------------------------------------------------------------------
  824. bool __fastcall TScpCommanderForm::GetHasDirView(TOperationSide Side)
  825. {
  826. return TCustomScpExplorerForm::GetHasDirView(Side) || (Side == osLocal);
  827. }
  828. //---------------------------------------------------------------------------
  829. void __fastcall TScpCommanderForm::CompareDirectories()
  830. {
  831. LocalDirView->CompareFiles(RemoteDirView, false,
  832. WinConfiguration->ScpCommander.CompareCriterias());
  833. RemoteDirView->CompareFiles(LocalDirView, false,
  834. WinConfiguration->ScpCommander.CompareCriterias());
  835. if (LocalDirView->SelCount + RemoteDirView->SelCount == 0)
  836. {
  837. MessageDialog(LoadStr(COMPARE_NO_DIFFERENCES), qtInformation, qaOK,
  838. HELP_COMPARE_NO_DIFFERENCES);
  839. }
  840. }
  841. //---------------------------------------------------------------------------
  842. void __fastcall TScpCommanderForm::SynchronizeDirectories()
  843. {
  844. UnicodeString LocalDirectory = LocalDirView->PathName;
  845. UnicodeString RemoteDirectory = RemoteDirView->PathName;
  846. DoSynchronizeDirectories(LocalDirectory, RemoteDirectory, false);
  847. }
  848. //---------------------------------------------------------------------------
  849. void __fastcall TScpCommanderForm::FullSynchronizeDirectories()
  850. {
  851. UnicodeString LocalDirectory = LocalDirView->PathName;
  852. UnicodeString RemoteDirectory = RemoteDirView->PathName;
  853. bool SaveMode = !(GUIConfiguration->SynchronizeModeAuto < 0);
  854. TSynchronizeMode Mode =
  855. (SaveMode ? (TSynchronizeMode)GUIConfiguration->SynchronizeModeAuto :
  856. ((FCurrentSide == osLocal) ? smRemote : smLocal));
  857. if (DoFullSynchronizeDirectories(LocalDirectory, RemoteDirectory, Mode,
  858. SaveMode, false))
  859. {
  860. if (SaveMode)
  861. {
  862. GUIConfiguration->SynchronizeModeAuto = Mode;
  863. }
  864. }
  865. }
  866. //---------------------------------------------------------------------------
  867. void __fastcall TScpCommanderForm::ExploreLocalDirectory()
  868. {
  869. if ((int)ShellExecute(Application->Handle, L"explore",
  870. (wchar_t*)LocalDirView->Path.data(), NULL, NULL, SW_SHOWNORMAL) <= 32)
  871. {
  872. throw Exception(FORMAT(EXPLORE_LOCAL_DIR_ERROR, (LocalDirView->Path)));
  873. }
  874. }
  875. //---------------------------------------------------------------------------
  876. void __fastcall TScpCommanderForm::LocalDirViewExecFile(TObject *Sender,
  877. TListItem *Item, bool &AllowExec)
  878. {
  879. DebugAssert(Item);
  880. if ((UpperCase(PFileRec(Item->Data)->FileExt) == L"LNK") &&
  881. DirectoryExists(ApiPath(ResolveFileShortCut(LocalDirView->ItemFullFileName(Item), true))))
  882. {
  883. AllowExec = true;
  884. }
  885. else
  886. {
  887. DoDirViewExecFile(Sender, Item, AllowExec);
  888. }
  889. }
  890. //---------------------------------------------------------------------------
  891. void __fastcall TScpCommanderForm::LocalFileControlDDDragEnter(TObject *Sender,
  892. IDataObject *DataObj, int grfKeyState, TPoint &Point, int &dwEffect,
  893. bool &Accept)
  894. {
  895. // LocalDirViewDDDragEnter is duplication of
  896. // TCustomScpExplorerForm::DirViewDDDragEnter, but it differs in
  897. // literal type of 'DataObj' parameter.Actual type is however same
  898. FileControlDDDragEnter(Sender, DataObj, grfKeyState, Point, dwEffect, Accept);
  899. }
  900. //---------------------------------------------------------------------------
  901. bool __fastcall TScpCommanderForm::PanelOperation(TOperationSide Side,
  902. bool DragDrop)
  903. {
  904. return TCustomScpExplorerForm::PanelOperation(Side, DragDrop) ||
  905. (DropSourceControl == LocalDirView);
  906. }
  907. //---------------------------------------------------------------------------
  908. void __fastcall TScpCommanderForm::FileOperationProgress(
  909. TFileOperationProgressType & ProgressData)
  910. {
  911. // Heuristic: When operation finishes and DD targed is local dir view,
  912. // we suppose that drag&drop download finished, so local dir view should be
  913. // reloaded
  914. if (!ProgressData.InProgress && FProgressForm &&
  915. IsFileControl(FDDTargetControl, osLocal) &&
  916. ((ProgressData.Operation == ::foCopy) || (ProgressData.Operation == ::foMove)))
  917. {
  918. ReloadLocalDirectory();
  919. }
  920. TCustomScpExplorerForm::FileOperationProgress(ProgressData);
  921. }
  922. //---------------------------------------------------------------------------
  923. UnicodeString __fastcall TScpCommanderForm::ChangeFilePath(UnicodeString Path, TOperationSide Side)
  924. {
  925. TGUICopyParamType CopyParams = GUIConfiguration->CurrentCopyParam;
  926. UnicodeString Result;
  927. while (!Path.IsEmpty())
  928. {
  929. int P = Path.Pos(Side == osLocal ? L'\\' : L'/');
  930. if (P > 0)
  931. {
  932. Result += Terminal->ChangeFileName(&CopyParams, Path.SubString(1, P - 1), Side, false) +
  933. (Side == osLocal ? L'/' : L'\\');
  934. Path.Delete(1, P);
  935. }
  936. else
  937. {
  938. Result += Terminal->ChangeFileName(&CopyParams, Path, osLocal, false);
  939. Path = L"";
  940. }
  941. }
  942. return Result;
  943. }
  944. //---------------------------------------------------------------------------
  945. void __fastcall TScpCommanderForm::SynchronizeBrowsingLocal(
  946. UnicodeString PrevPath, UnicodeString & NewPath, bool Create)
  947. {
  948. Terminal->ExceptionOnFail = true;
  949. TStrings * Paths = new TStringList();
  950. try
  951. {
  952. Paths->Add(IncludeTrailingBackslash(PrevPath));
  953. Paths->Add(IncludeTrailingBackslash(LocalDirView->Path));
  954. UnicodeString CommonPath;
  955. if (ExtractCommonPath(Paths, CommonPath))
  956. {
  957. PrevPath = IncludeTrailingBackslash(PrevPath);
  958. CommonPath = IncludeTrailingBackslash(CommonPath);
  959. NewPath = RemoteDirView->Path;
  960. while (!ComparePaths(PrevPath, CommonPath))
  961. {
  962. if (NewPath == UnixExcludeTrailingBackslash(NewPath))
  963. {
  964. Abort();
  965. }
  966. NewPath = UnixExtractFilePath(UnixExcludeTrailingBackslash(NewPath));
  967. PrevPath = ExtractFilePath(ExcludeTrailingBackslash(PrevPath));
  968. }
  969. NewPath = UnixIncludeTrailingBackslash(NewPath) +
  970. ToUnixPath(LocalDirView->Path.SubString(PrevPath.Length() + 1,
  971. LocalDirView->Path.Length() - PrevPath.Length()));
  972. }
  973. else
  974. {
  975. Abort();
  976. }
  977. if (Create)
  978. {
  979. TRemoteProperties Properties = GUIConfiguration->NewDirectoryProperties;
  980. RemoteDirView->CreateDirectoryEx(NewPath, &Properties);
  981. }
  982. RemoteDirView->Path = NewPath;
  983. }
  984. __finally
  985. {
  986. Terminal->ExceptionOnFail = false;
  987. delete Paths;
  988. }
  989. }
  990. //---------------------------------------------------------------------------
  991. void __fastcall TScpCommanderForm::SynchronizeBrowsingRemote(
  992. UnicodeString PrevPath, UnicodeString & NewPath, bool Create)
  993. {
  994. TStrings * Paths = new TStringList();
  995. try
  996. {
  997. Paths->Add(UnixIncludeTrailingBackslash(PrevPath));
  998. Paths->Add(UnixIncludeTrailingBackslash(RemoteDirView->Path));
  999. UnicodeString CommonPath;
  1000. if (UnixExtractCommonPath(Paths, CommonPath))
  1001. {
  1002. PrevPath = UnixIncludeTrailingBackslash(PrevPath);
  1003. CommonPath = UnixIncludeTrailingBackslash(CommonPath);
  1004. UnicodeString NewLocalPath;
  1005. NewPath = ExcludeTrailingBackslash(LocalDirView->Path);
  1006. while (!UnixSamePath(PrevPath, CommonPath))
  1007. {
  1008. NewLocalPath = ExcludeTrailingBackslash(ExtractFileDir(NewPath));
  1009. if (NewLocalPath == NewPath)
  1010. {
  1011. Abort();
  1012. }
  1013. NewPath = NewLocalPath;
  1014. PrevPath = UnixExtractFilePath(UnixExcludeTrailingBackslash(PrevPath));
  1015. }
  1016. NewPath = IncludeTrailingBackslash(NewPath) +
  1017. ChangeFilePath(
  1018. RemoteDirView->Path.SubString(PrevPath.Length() + 1,
  1019. RemoteDirView->Path.Length() - PrevPath.Length()),
  1020. osRemote);
  1021. }
  1022. else
  1023. {
  1024. Abort();
  1025. }
  1026. }
  1027. __finally
  1028. {
  1029. delete Paths;
  1030. }
  1031. if (Create)
  1032. {
  1033. LocalDirView->CreateDirectory(NewPath);
  1034. }
  1035. LocalDirView->Path = NewPath;
  1036. }
  1037. //---------------------------------------------------------------------------
  1038. void __fastcall TScpCommanderForm::SynchronizeBrowsing(TCustomDirView * ADirView,
  1039. UnicodeString PrevPath, UnicodeString & NewPath, bool Create)
  1040. {
  1041. if (ADirView == LocalDirView)
  1042. {
  1043. SynchronizeBrowsingLocal(PrevPath, NewPath, Create);
  1044. }
  1045. else
  1046. {
  1047. SynchronizeBrowsingRemote(PrevPath, NewPath, Create);
  1048. }
  1049. }
  1050. //---------------------------------------------------------------------------
  1051. void __fastcall TScpCommanderForm::SynchronizeBrowsing(TCustomDirView * ADirView)
  1052. {
  1053. UnicodeString PrevPath;
  1054. // cannot assign to UnicodeString before the class is constructed,
  1055. // if we do, the value get lost when UnicodeString constructor gets finally called,
  1056. // what results in memory leak in the best case
  1057. if (FConstructed)
  1058. {
  1059. PrevPath = FPrevPath[ADirView == LocalDirView];
  1060. FPrevPath[ADirView == LocalDirView] = ADirView->Path;
  1061. }
  1062. if (!FSynchronisingBrowse && NonVisualDataModule->SynchronizeBrowsingAction->Checked &&
  1063. !PrevPath.IsEmpty() && PrevPath != ADirView->Path)
  1064. {
  1065. TValueRestorer<bool> AllowTransferPresetAutoSelectRestorer(FAllowTransferPresetAutoSelect);
  1066. FAllowTransferPresetAutoSelect = false;
  1067. TValueRestorer<bool> SynchronisingBrowseRestorer(FSynchronisingBrowse);
  1068. FSynchronisingBrowse = true;
  1069. try
  1070. {
  1071. UnicodeString NewPath;
  1072. bool Error = false;
  1073. std::unique_ptr<TStrings> ErrorMoreMessages;
  1074. UnicodeString ErrorHelpKeyword;
  1075. try
  1076. {
  1077. SynchronizeBrowsing(ADirView, PrevPath, NewPath, false);
  1078. }
  1079. // EAbort means that we do not know how to synchronize browsing
  1080. // there's no fallback scenario for that
  1081. catch(EAbort &)
  1082. {
  1083. throw;
  1084. }
  1085. catch(Exception & E)
  1086. {
  1087. // what does this say?
  1088. if (Application->Terminated)
  1089. {
  1090. throw;
  1091. }
  1092. else
  1093. {
  1094. Error = true;
  1095. ErrorMoreMessages.reset(ExceptionToMoreMessages(&E));
  1096. ErrorHelpKeyword =
  1097. MergeHelpKeyword(HELP_SYNC_DIR_BROWSE_ERROR, GetExceptionHelpKeyword(&E));
  1098. }
  1099. }
  1100. // this was moved here out of the above catch clause,
  1101. // to avoid deep nesting, what seems to cause some stray access violations
  1102. if (Error)
  1103. {
  1104. if (MoreMessageDialog(FMTLOAD(SYNC_DIR_BROWSE_CREATE2, (NewPath)),
  1105. ErrorMoreMessages.get(), qtConfirmation, qaYes | qaNo,
  1106. ErrorHelpKeyword) == qaYes)
  1107. {
  1108. try
  1109. {
  1110. SynchronizeBrowsing(ADirView, PrevPath, NewPath, true);
  1111. }
  1112. catch(Exception & E)
  1113. {
  1114. if (!Application->Terminated)
  1115. {
  1116. Terminal->ShowExtendedException(&E);
  1117. }
  1118. throw;
  1119. }
  1120. }
  1121. else
  1122. {
  1123. NonVisualDataModule->SynchronizeBrowsingAction->Checked = false;
  1124. }
  1125. }
  1126. }
  1127. catch(Exception & E)
  1128. {
  1129. NonVisualDataModule->SynchronizeBrowsingAction->Checked = false;
  1130. // what does this say?
  1131. if (Application->Terminated)
  1132. {
  1133. throw;
  1134. }
  1135. else
  1136. {
  1137. MessageDialog(LoadStr(SYNC_DIR_BROWSE_ERROR), qtInformation, qaOK,
  1138. HELP_SYNC_DIR_BROWSE_ERROR);
  1139. }
  1140. }
  1141. // note the value restorers at the beginning of this block
  1142. }
  1143. }
  1144. //---------------------------------------------------------------------------
  1145. void __fastcall TScpCommanderForm::DoDirViewLoaded(TCustomDirView * ADirView)
  1146. {
  1147. TCustomScpExplorerForm::DoDirViewLoaded(ADirView);
  1148. UpdateControls();
  1149. SynchronizeBrowsing(ADirView);
  1150. }
  1151. //---------------------------------------------------------------------------
  1152. void __fastcall TScpCommanderForm::AddEditLink(TOperationSide Side, bool Add)
  1153. {
  1154. if (GetSide(Side) == osLocal)
  1155. {
  1156. bool Edit = false;
  1157. UnicodeString FileName;
  1158. UnicodeString PointTo;
  1159. bool SymbolicLink = true;
  1160. if (LocalDirView->ItemFocused)
  1161. {
  1162. DebugAssert(LocalDirView->ItemFocused->Data);
  1163. PFileRec FileRec = (PFileRec)LocalDirView->ItemFocused->Data;
  1164. Edit = !Add && (UpperCase(FileRec->FileExt) == L"LNK");
  1165. if (Edit)
  1166. {
  1167. UnicodeString FullName = LocalDirView->ItemFullFileName(LocalDirView->ItemFocused);
  1168. FileName = FullName;
  1169. PointTo = ResolveFileShortCut(FullName, false);
  1170. if (PointTo.IsEmpty())
  1171. {
  1172. throw Exception(FMTLOAD(RESOLVE_SHORTCUT_ERROR, (FullName)));
  1173. }
  1174. }
  1175. else
  1176. {
  1177. PointTo = FileRec->FileName;
  1178. }
  1179. }
  1180. if (DoSymlinkDialog(FileName, PointTo, osLocal, SymbolicLink, Edit, false))
  1181. {
  1182. Configuration->Usage->Inc(L"LocalShortcutsCreated");
  1183. DebugAssert(SymbolicLink);
  1184. DebugAssert(!FileName.IsEmpty());
  1185. DebugAssert(!PointTo.IsEmpty());
  1186. if (ExtractFileDrive(FileName) == L"" && FileName[1] != L'\\')
  1187. {
  1188. FileName = IncludeTrailingBackslash(LocalDirView->PathName) + FileName;
  1189. }
  1190. if (ExtractFileDrive(PointTo) == L"" && PointTo[1] != L'\\')
  1191. {
  1192. PointTo = IncludeTrailingBackslash(LocalDirView->PathName) + PointTo;
  1193. }
  1194. if (ExtractFileExt(FileName) == L"")
  1195. {
  1196. FileName = FileName + L".lnk";
  1197. }
  1198. if (Edit)
  1199. {
  1200. DeleteFileChecked(FileName);
  1201. }
  1202. if (!CreateFileShortCut(PointTo, FileName, L""))
  1203. {
  1204. throw Exception(CREATE_SHORTCUT_ERROR);
  1205. }
  1206. }
  1207. }
  1208. else
  1209. {
  1210. TCustomScpExplorerForm::AddEditLink(Side, Add);
  1211. }
  1212. }
  1213. //---------------------------------------------------------------------------
  1214. void __fastcall TScpCommanderForm::DoOpenDirectoryDialog(TOpenDirectoryMode Mode,
  1215. TOperationSide Side)
  1216. {
  1217. bool UseLocationProfiles;
  1218. do
  1219. {
  1220. UseLocationProfiles = WinConfiguration->UseLocationProfiles;
  1221. // Location profiles dialog is not ready to be run without terminal
  1222. if (UseLocationProfiles && (Terminal != NULL))
  1223. {
  1224. TStrings * LocalDirectories = NULL;
  1225. TStrings * RemoteDirectories = NULL;
  1226. try
  1227. {
  1228. LocalDirectories = CreateVisitedDirectories(osLocal);
  1229. RemoteDirectories = CreateVisitedDirectories(osRemote);
  1230. UnicodeString Local = LocalDirView->PathName;
  1231. UnicodeString Remote = RemoteDirView->PathName;
  1232. if (LocationProfilesDialog(Mode, Side, Local, Remote, LocalDirectories,
  1233. RemoteDirectories, Terminal))
  1234. {
  1235. DoOpenBookmark(Local, Remote);
  1236. }
  1237. }
  1238. __finally
  1239. {
  1240. delete LocalDirectories;
  1241. delete RemoteDirectories;
  1242. }
  1243. }
  1244. else
  1245. {
  1246. TSynchronizedBrowsingGuard SynchronizedBrowsingGuard;
  1247. TCustomScpExplorerForm::DoOpenDirectoryDialog(Mode, Side);
  1248. }
  1249. // for second and further rounds, always do browse only
  1250. Mode = odBrowse;
  1251. }
  1252. while (UseLocationProfiles != WinConfiguration->UseLocationProfiles);
  1253. }
  1254. //---------------------------------------------------------------------------
  1255. void __fastcall TScpCommanderForm::DoOpenBookmark(UnicodeString Local, UnicodeString Remote)
  1256. {
  1257. TSynchronizedBrowsingGuard SynchronizedBrowsingGuard;
  1258. // make sure that whatever path is valid it is opened first and only
  1259. // after that an eventual error is reported
  1260. try
  1261. {
  1262. if (!Local.IsEmpty())
  1263. {
  1264. LocalDirView->Path = Local;
  1265. }
  1266. }
  1267. __finally
  1268. {
  1269. if (!Remote.IsEmpty())
  1270. {
  1271. // While we might get here when the session is closed (from location profiles),
  1272. // it's not a problem as the Path setter is noop then
  1273. RemoteDirView->Path = Remote;
  1274. }
  1275. }
  1276. }
  1277. //---------------------------------------------------------------------------
  1278. bool __fastcall TScpCommanderForm::OpenBookmark(UnicodeString Local, UnicodeString Remote)
  1279. {
  1280. bool Result;
  1281. if (WinConfiguration->UseLocationProfiles)
  1282. {
  1283. DoOpenBookmark(Local, Remote);
  1284. Result = true;
  1285. }
  1286. else
  1287. {
  1288. Result = TCustomScpExplorerForm::OpenBookmark(Local, Remote);
  1289. }
  1290. return Result;
  1291. }
  1292. //---------------------------------------------------------------------------
  1293. void __fastcall TScpCommanderForm::LocalDirViewDDTargetHasDropHandler(
  1294. TObject * /*Sender*/, TListItem * Item, int & /*Effect*/, bool & DropHandler)
  1295. {
  1296. // When drop target is not directory, it is probably file type, which have
  1297. // associated drop handler (such as EXE file). In this case we
  1298. // cannot allow drop when when using shellex,
  1299. // as drop handlers are disabled, so drop would error
  1300. // (see TShellExtension.DropHandler assignment in ConfigurationChanged),
  1301. if (WinConfiguration->DDExtEnabled &&
  1302. !LocalDirView->ItemIsDirectory(Item))
  1303. {
  1304. DropHandler = false;
  1305. }
  1306. }
  1307. //---------------------------------------------------------------------------
  1308. void __fastcall TScpCommanderForm::LocalFileControlDDDragOver(TObject * /*Sender*/,
  1309. int grfKeyState, TPoint & /*Point*/, int & dwEffect)
  1310. {
  1311. if (IsFileControl(DropSourceControl, osRemote))
  1312. {
  1313. if (((grfKeyState & (MK_CONTROL | MK_SHIFT)) == 0) ||
  1314. (((grfKeyState & (MK_CONTROL | MK_SHIFT)) == MK_SHIFT) &&
  1315. !WinConfiguration->DDAllowMoveInit))
  1316. {
  1317. dwEffect = DROPEFFECT_Copy;
  1318. }
  1319. }
  1320. }
  1321. //---------------------------------------------------------------------------
  1322. bool __fastcall TScpCommanderForm::DDGetTarget(
  1323. UnicodeString & Directory, bool & ForceQueue, bool & Internal)
  1324. {
  1325. bool Result;
  1326. if (!FDDExtTarget.IsEmpty())
  1327. {
  1328. Directory = FDDExtTarget;
  1329. FDDExtTarget = L"";
  1330. Result = true;
  1331. Internal = true;
  1332. }
  1333. else
  1334. {
  1335. Result = TCustomScpExplorerForm::DDGetTarget(Directory, ForceQueue, Internal);
  1336. }
  1337. return Result;
  1338. }
  1339. //---------------------------------------------------------------------------
  1340. void __fastcall TScpCommanderForm::DDExtInitDrag(TFileList * FileList,
  1341. bool & Created)
  1342. {
  1343. FDDExtTarget = L"";
  1344. TCustomScpExplorerForm::DDExtInitDrag(FileList, Created);
  1345. }
  1346. //---------------------------------------------------------------------------
  1347. void __fastcall TScpCommanderForm::LocalFileControlDDFileOperation(
  1348. TObject * /*Sender*/, int dwEffect, UnicodeString SourcePath,
  1349. UnicodeString TargetPath, bool & DoOperation)
  1350. {
  1351. if (IsFileControl(DropSourceControl, osRemote))
  1352. {
  1353. UnicodeString TargetDirectory;
  1354. if (InternalDDDownload(TargetDirectory))
  1355. {
  1356. // See TCustomScpExplorerForm::QueueDDProcessDropped
  1357. if (FDDExtMapFile != NULL)
  1358. {
  1359. FDDExtTarget = TargetDirectory;
  1360. }
  1361. else
  1362. {
  1363. DebugAssert(FInternalDDDownloadList->Count > 0);
  1364. DebugAssert(dwEffect == DROPEFFECT_Copy || dwEffect == DROPEFFECT_Move);
  1365. TGUICopyParamType CopyParams = GUIConfiguration->CurrentCopyParam;
  1366. TTransferType TransferType = dwEffect == DROPEFFECT_Copy ? ttCopy : ttMove;
  1367. if (FDDMoveSlipped)
  1368. {
  1369. TransferType = ttMove;
  1370. }
  1371. int Options = 0;
  1372. if (CopyParamDialog(tdToLocal, TransferType,
  1373. false, FInternalDDDownloadList, TargetDirectory, CopyParams,
  1374. (WinConfiguration->DDTransferConfirmation != asOff), true, Options))
  1375. {
  1376. int Params =
  1377. (TransferType == ttMove ? cpDelete : 0);
  1378. DDDownload(FInternalDDDownloadList, TargetDirectory,
  1379. &CopyParams, Params);
  1380. Configuration->Usage->Inc(L"DownloadsDragDropInternal");
  1381. FInternalDDDownloadList->Clear();
  1382. }
  1383. }
  1384. DoOperation = false;
  1385. }
  1386. }
  1387. }
  1388. //---------------------------------------------------------------------------
  1389. void __fastcall TScpCommanderForm::RemoteFileControlDDFileOperationExecuted(
  1390. TObject * /*Sender*/, int dwEffect, UnicodeString /*SourcePath*/,
  1391. UnicodeString /*TargetPath*/)
  1392. {
  1393. if ((dwEffect == DROPEFFECT_Move) &&
  1394. IsFileControl(DropSourceControl, osLocal))
  1395. {
  1396. ReloadLocalDirectory();
  1397. }
  1398. }
  1399. //---------------------------------------------------------------------------
  1400. void __fastcall TScpCommanderForm::LocalDirViewEnter(TObject * /*Sender*/)
  1401. {
  1402. SideEnter(osLocal);
  1403. }
  1404. //---------------------------------------------------------------------------
  1405. void __fastcall TScpCommanderForm::LocalDriveViewEnter(TObject * /*Sender*/)
  1406. {
  1407. MakeNextInTabOrder(LocalDirView, LocalDriveView);
  1408. SideEnter(osLocal);
  1409. }
  1410. //---------------------------------------------------------------------------
  1411. void __fastcall TScpCommanderForm::SideEnter(TOperationSide Side)
  1412. {
  1413. if (Visible && (FCurrentSide != Side))
  1414. {
  1415. // this may get called yet before controls are initialized
  1416. CommandLineCombo->Strings->Clear();
  1417. FCommandLineComboPopulated = false;
  1418. }
  1419. TCustomScpExplorerForm::SideEnter(Side);
  1420. if (Visible)
  1421. {
  1422. UpdateControls();
  1423. UpdatePanelsPathLabelsStatus();
  1424. }
  1425. }
  1426. //---------------------------------------------------------------------------
  1427. void __fastcall TScpCommanderForm::UpdatePanelsPathLabelsStatus()
  1428. {
  1429. LocalPathLabel->UpdateStatus();
  1430. RemotePathLabel->UpdateStatus();
  1431. }
  1432. //---------------------------------------------------------------------------
  1433. void __fastcall TScpCommanderForm::OpenConsole(UnicodeString Command)
  1434. {
  1435. SaveCommandLine();
  1436. try
  1437. {
  1438. TCustomScpExplorerForm::OpenConsole(Command);
  1439. }
  1440. __finally
  1441. {
  1442. FCommandLineComboPopulated = false;
  1443. }
  1444. }
  1445. //---------------------------------------------------------------------------
  1446. void __fastcall TScpCommanderForm::SaveCommandLine()
  1447. {
  1448. if (FCommandLineComboPopulated)
  1449. {
  1450. CustomWinConfiguration->History[
  1451. FCurrentSide == osRemote ? L"Commands" : L"LocalCommands"] =
  1452. CommandLineCombo->Strings;
  1453. }
  1454. }
  1455. //---------------------------------------------------------------------------
  1456. bool __fastcall TScpCommanderForm::ExecuteCommandLine()
  1457. {
  1458. UnicodeString Command = CommandLineCombo->Text;
  1459. bool Result =
  1460. !Command.IsEmpty() &&
  1461. ((FCurrentSide != osRemote) ||
  1462. (Terminal->AllowedAnyCommand(Command) &&
  1463. EnsureCommandSessionFallback(fcAnyCommand)));
  1464. if (Result)
  1465. {
  1466. CommandLinePopulate();
  1467. SaveToHistory(CommandLineCombo->Strings, Command);
  1468. CommandLineCombo->Text = L"";
  1469. if (FCurrentSide == osRemote)
  1470. {
  1471. OpenConsole(Command);
  1472. }
  1473. else
  1474. {
  1475. UnicodeString Program, Params, Dir;
  1476. SplitCommand(Command, Program, Params, Dir);
  1477. if (!ExecuteShell(Program, Params))
  1478. {
  1479. throw Exception(FMTLOAD(EXECUTE_APP_ERROR, (Program)));
  1480. }
  1481. }
  1482. }
  1483. return Result;
  1484. }
  1485. //---------------------------------------------------------------------------
  1486. void __fastcall TScpCommanderForm::CommandLinePopulate()
  1487. {
  1488. if (!FCommandLineComboPopulated)
  1489. {
  1490. TStrings * CommandsHistory;
  1491. CommandsHistory = CustomWinConfiguration->History[
  1492. FCurrentSide == osRemote ? L"Commands" : L"LocalCommands"];
  1493. if ((CommandsHistory != NULL) && (CommandsHistory->Count > 0))
  1494. {
  1495. CommandLineCombo->Strings = CommandsHistory;
  1496. }
  1497. else
  1498. {
  1499. CommandLineCombo->Strings->Clear();
  1500. }
  1501. FCommandLineComboPopulated = true;
  1502. }
  1503. }
  1504. //---------------------------------------------------------------------------
  1505. void __fastcall TScpCommanderForm::GoToCommandLine()
  1506. {
  1507. ComponentVisible[fcCommandLinePanel] = true;
  1508. if (CommandLineCombo->Enabled)
  1509. {
  1510. ClickToolbarItem(CommandLineCombo, true);
  1511. }
  1512. }
  1513. //---------------------------------------------------------------------------
  1514. void __fastcall TScpCommanderForm::GoToTree()
  1515. {
  1516. if (FCurrentSide == osLocal)
  1517. {
  1518. ComponentVisible[fcLocalTree] = true;
  1519. LocalDriveView->SetFocus();
  1520. }
  1521. else
  1522. {
  1523. TCustomScpExplorerForm::GoToTree();
  1524. }
  1525. }
  1526. //---------------------------------------------------------------------------
  1527. void __fastcall TScpCommanderForm::PanelExportStore(TOperationSide Side,
  1528. TPanelExport Export, TPanelExportDestination Destination,
  1529. TStrings * ExportData)
  1530. {
  1531. if (Destination == pedCommandLine)
  1532. {
  1533. ComponentVisible[fcCommandLinePanel] = true;
  1534. UnicodeString Buf;
  1535. for (int Index = 0; Index < ExportData->Count; Index++)
  1536. {
  1537. Buf += ExportData->Strings[Index] + L" ";
  1538. }
  1539. CommandLineCombo->Text = CommandLineCombo->Text + Buf;
  1540. }
  1541. else
  1542. {
  1543. TCustomScpExplorerForm::PanelExportStore(Side, Export, Destination, ExportData);
  1544. }
  1545. }
  1546. //---------------------------------------------------------------------------
  1547. int __fastcall TScpCommanderForm::GetStaticComponentsHeight()
  1548. {
  1549. return TCustomScpExplorerForm::GetStaticComponentsHeight() +
  1550. (BottomDock->Visible ? BottomDock->Height : 0) +
  1551. (QueueSeparatorPanel->Visible ? QueueSeparatorPanel->Height : 0) +
  1552. (StatusBar->Visible ? StatusBar->Height : 0);
  1553. }
  1554. //---------------------------------------------------------------------------
  1555. void __fastcall TScpCommanderForm::SysResizing(unsigned int Cmd)
  1556. {
  1557. TCustomScpExplorerForm::SysResizing(Cmd);
  1558. if ((Cmd == SC_MAXIMIZE) ||
  1559. ((Cmd == SC_DEFAULT) && (WindowState != wsMaximized)))
  1560. {
  1561. FNormalPanelsWidth = LocalPanel->Width + RemotePanel->Width;
  1562. }
  1563. else if ((Cmd == SC_RESTORE) ||
  1564. ((Cmd == SC_DEFAULT) && (WindowState == wsMaximized)))
  1565. {
  1566. if (FNormalPanelsWidth >= 0)
  1567. {
  1568. Panel(true)->Width = static_cast<int>(FLeftPanelWidth * FNormalPanelsWidth);
  1569. FNormalPanelsWidth = -1;
  1570. }
  1571. }
  1572. }
  1573. //---------------------------------------------------------------------------
  1574. void __fastcall TScpCommanderForm::Resize()
  1575. {
  1576. TCustomScpExplorerForm::Resize();
  1577. LeftPanelWidth = FLastLeftPanelWidth;
  1578. UpdateControls();
  1579. }
  1580. //---------------------------------------------------------------------------
  1581. void __fastcall TScpCommanderForm::LocalFileControlDDMenuPopup(TObject * /*Sender*/,
  1582. HMENU AMenu, IDataObject * /*DataObj*/, int /*AMinCustCmd*/, int /*grfKeyState*/,
  1583. TPoint & /*pt*/)
  1584. {
  1585. if (IsFileControl(DropSourceControl, osRemote) &&
  1586. !WinConfiguration->DDAllowMoveInit)
  1587. {
  1588. // index of copy item
  1589. int Index = GetMenuDefaultItem(AMenu, TRUE, 0);
  1590. DebugAssert(Index >= 0);
  1591. UnicodeString Caption = Dragdrop_MIMoveStr;
  1592. MENUITEMINFO MI;
  1593. memset(&MI, 0, sizeof(MI));
  1594. MI.cbSize = sizeof(MI);
  1595. MI.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
  1596. MI.fType = MFT_STRING;
  1597. MI.wID = 1 /*DragDrop::CmdMove*/;
  1598. MI.dwTypeData = Caption.c_str();
  1599. MI.cch = Caption.Length();
  1600. MI.fState = MFS_ENABLED;
  1601. InsertMenuItem(AMenu, Index, TRUE, &MI);
  1602. if (FDDMoveSlipped)
  1603. {
  1604. SetMenuDefaultItem(AMenu, Index, TRUE);
  1605. }
  1606. FDDMoveSlipped = false;
  1607. }
  1608. }
  1609. //---------------------------------------------------------------------------
  1610. void __fastcall TScpCommanderForm::PathLabelDblClick(TObject * Sender)
  1611. {
  1612. OpenDirectory(Sender == LocalPathLabel ? osLocal : osRemote);
  1613. }
  1614. //---------------------------------------------------------------------------
  1615. void __fastcall TScpCommanderForm::LocalPathLabelGetStatus(
  1616. TCustomPathLabel * /*Sender*/, bool & Active)
  1617. {
  1618. // WORKAROUND this strange form is here to make borland compiler work :-)
  1619. Active = Active || LocalDriveView->Focused();
  1620. }
  1621. //---------------------------------------------------------------------------
  1622. void __fastcall TScpCommanderForm::RemotePathLabelGetStatus(
  1623. TCustomPathLabel * /*Sender*/, bool & Active)
  1624. {
  1625. // WORKAROUND this strange form is here to make borland compiler work :-)
  1626. Active = Active || RemoteDriveView->Focused();
  1627. }
  1628. //---------------------------------------------------------------------------
  1629. void __fastcall TScpCommanderForm::LocalPathLabelPathClick(
  1630. TCustomPathLabel * /*Sender*/, UnicodeString Path)
  1631. {
  1632. if (ComparePaths(Path, LocalDirView->Path))
  1633. {
  1634. OpenDirectory(osLocal);
  1635. }
  1636. else
  1637. {
  1638. LocalDirView->Path = Path;
  1639. }
  1640. }
  1641. //---------------------------------------------------------------------------
  1642. void __fastcall TScpCommanderForm::RemotePathLabelPathClick(
  1643. TCustomPathLabel * /*Sender*/, UnicodeString Path)
  1644. {
  1645. if (UnixSamePath(Path, RemoteDirView->Path))
  1646. {
  1647. OpenDirectory(osRemote);
  1648. }
  1649. else
  1650. {
  1651. RemoteDirView->Path = Path;
  1652. }
  1653. }
  1654. //---------------------------------------------------------------------------
  1655. void __fastcall TScpCommanderForm::LocalDirViewFileIconForName(
  1656. TObject * /*Sender*/, TListItem * /*Item*/, UnicodeString & FileName)
  1657. {
  1658. UnicodeString PartialExt = Configuration->PartialExt;
  1659. if (AnsiSameText(ExtractFileExt(FileName), PartialExt))
  1660. {
  1661. FileName.SetLength(FileName.Length() - PartialExt.Length());
  1662. }
  1663. if (WinConfiguration->LocalIconsByExt)
  1664. {
  1665. FileName = ExtractFileName(FileName);
  1666. }
  1667. }
  1668. //---------------------------------------------------------------------------
  1669. void __fastcall TScpCommanderForm::LocalDirViewUpdateStatusBar(
  1670. TObject * /*Sender*/, const TStatusFileInfo & FileInfo)
  1671. {
  1672. UpdateFileStatusBar(LocalStatusBar, FileInfo, osLocal);
  1673. }
  1674. //---------------------------------------------------------------------------
  1675. void __fastcall TScpCommanderForm::RemoteDirViewUpdateStatusBar(
  1676. TObject * /*Sender*/, const TStatusFileInfo & FileInfo)
  1677. {
  1678. UpdateFileStatusBar(RemoteStatusBar, FileInfo, osRemote);
  1679. }
  1680. //---------------------------------------------------------------------------
  1681. void __fastcall TScpCommanderForm::LocalStatusBarClick(TObject * /*Sender*/)
  1682. {
  1683. LocalDirView->SetFocus();
  1684. }
  1685. //---------------------------------------------------------------------------
  1686. UnicodeString __fastcall TScpCommanderForm::PathForCaption()
  1687. {
  1688. UnicodeString Result;
  1689. if (FCurrentSide == osLocal)
  1690. {
  1691. // for consistency do not show even local path when there is no terminal
  1692. if (Terminal != NULL)
  1693. {
  1694. switch (WinConfiguration->PathInCaption)
  1695. {
  1696. case picShort:
  1697. {
  1698. Result = ExtractFileName(LocalDirView->PathName);
  1699. if (Result.IsEmpty())
  1700. {
  1701. Result = LocalDirView->PathName;
  1702. }
  1703. }
  1704. break;
  1705. case picFull:
  1706. Result = LocalDirView->PathName;
  1707. break;
  1708. }
  1709. }
  1710. }
  1711. else
  1712. {
  1713. Result = TCustomScpExplorerForm::PathForCaption();
  1714. }
  1715. return Result;
  1716. }
  1717. //---------------------------------------------------------------------------
  1718. void __fastcall TScpCommanderForm::GetTransferPresetAutoSelectData(
  1719. TCopyParamRuleData & Data)
  1720. {
  1721. TCustomScpExplorerForm::GetTransferPresetAutoSelectData(Data);
  1722. Data.LocalDirectory = LocalDirView->PathName;
  1723. }
  1724. //---------------------------------------------------------------------------
  1725. void __fastcall TScpCommanderForm::BeforeAction()
  1726. {
  1727. TCustomScpExplorerForm::BeforeAction();
  1728. if (LocalDirView->ItemFocused != NULL)
  1729. {
  1730. LocalDirView->ItemFocused->CancelEdit();
  1731. }
  1732. }
  1733. //---------------------------------------------------------------------------
  1734. void __fastcall TScpCommanderForm::RemoteDirViewPathChange(TCustomDirView * /*Sender*/)
  1735. {
  1736. UpdateRemotePathComboBox(false);
  1737. }
  1738. //---------------------------------------------------------------------------
  1739. void __fastcall TScpCommanderForm::LocalPathComboUpdateDrives()
  1740. {
  1741. TStrings* Strings = LocalPathComboBox->Strings;
  1742. Strings->BeginUpdate();
  1743. try
  1744. {
  1745. Strings->Clear();
  1746. FLocalPathComboBoxPaths->Clear();
  1747. Strings->Add(LoadStr(SPECIAL_FOLDER_MY_DOCUMENTS));
  1748. FLocalPathComboBoxPaths->AddObject(GetPersonalFolder(),
  1749. (TObject *)DriveInfo->SpecialFolder[CSIDL_PERSONAL]->ImageIndex);
  1750. Strings->Add(LoadStr(SPECIAL_FOLDER_DESKTOP));
  1751. FLocalPathComboBoxPaths->AddObject(GetDesktopFolder(),
  1752. (TObject *)DriveInfo->SpecialFolder[CSIDL_DESKTOP]->ImageIndex);
  1753. for (TDrive Drive = FirstDrive; Drive <= LastDrive; Drive++)
  1754. {
  1755. if (DriveInfo->Data[Drive]->Valid)
  1756. {
  1757. Strings->Add(UnicodeString(L"&") + DriveInfo->GetPrettyName(Drive));
  1758. FLocalPathComboBoxPaths->AddObject(UnicodeString(Drive) + L":\\",
  1759. (TObject *)DriveInfo->GetImageIndex(Drive));
  1760. }
  1761. }
  1762. }
  1763. __finally
  1764. {
  1765. Strings->EndUpdate();
  1766. }
  1767. }
  1768. //---------------------------------------------------------------------------
  1769. void __fastcall TScpCommanderForm::LocalPathComboUpdate()
  1770. {
  1771. // this may get called even after destructor finishes
  1772. // (e.g. from SetDockAllowDrag invoked [indirectly] from StoreParams)
  1773. if (FLocalPathComboBoxPaths != NULL)
  1774. {
  1775. DebugAssert(FLocalPathComboBoxPaths->Count == LocalPathComboBox->Strings->Count);
  1776. int Index = 0;
  1777. while ((Index < FLocalPathComboBoxPaths->Count) &&
  1778. !ComparePaths(FLocalPathComboBoxPaths->Strings[Index],
  1779. LocalDirView->Path.SubString(1, FLocalPathComboBoxPaths->Strings[Index].Length())))
  1780. {
  1781. Index++;
  1782. }
  1783. // what to do if not?
  1784. if (Index < FLocalPathComboBoxPaths->Count)
  1785. {
  1786. LocalPathComboBox->ItemIndex = Index;
  1787. }
  1788. }
  1789. }
  1790. //---------------------------------------------------------------------------
  1791. void __fastcall TScpCommanderForm::LocalDirViewPathChange(TCustomDirView * /*Sender*/)
  1792. {
  1793. LocalPathComboUpdate();
  1794. }
  1795. //---------------------------------------------------------------------------
  1796. void __fastcall TScpCommanderForm::LocalPathComboBoxCancel(TObject * /*Sender*/)
  1797. {
  1798. LocalPathComboUpdate();
  1799. }
  1800. //---------------------------------------------------------------------------
  1801. void __fastcall TScpCommanderForm::LocalPathComboBoxAdjustImageIndex(
  1802. TTBXComboBoxItem * /*Sender*/, const UnicodeString AText, int AIndex,
  1803. int & ImageIndex)
  1804. {
  1805. // this may get called even before constructor starts
  1806. // (e.g. from FixControlsPlacement)
  1807. if (FLocalPathComboBoxPaths != NULL)
  1808. {
  1809. DebugAssert(FLocalPathComboBoxPaths->Count == LocalPathComboBox->Strings->Count);
  1810. DebugAssert(AIndex < FLocalPathComboBoxPaths->Count);
  1811. if (AIndex < 0)
  1812. {
  1813. AIndex = LocalPathComboBox->ItemIndex;
  1814. }
  1815. if (AIndex >= 0)
  1816. {
  1817. ImageIndex = int(FLocalPathComboBoxPaths->Objects[AIndex]);
  1818. }
  1819. }
  1820. }
  1821. //---------------------------------------------------------------------------
  1822. void __fastcall TScpCommanderForm::LocalPathComboBoxItemClick(TObject * /*Sender*/)
  1823. {
  1824. DebugAssert(FLocalPathComboBoxPaths->Count == LocalPathComboBox->Strings->Count);
  1825. DebugAssert((LocalPathComboBox->ItemIndex >= 0) && (LocalPathComboBox->ItemIndex < FLocalPathComboBoxPaths->Count));
  1826. UnicodeString Path = FLocalPathComboBoxPaths->Strings[LocalPathComboBox->ItemIndex];
  1827. if (Path.Length() == 3)
  1828. {
  1829. LocalDirView->ExecuteDrive(Path[1]);
  1830. }
  1831. else
  1832. {
  1833. LocalDirView->Path = FLocalPathComboBoxPaths->Strings[LocalPathComboBox->ItemIndex];
  1834. }
  1835. }
  1836. //---------------------------------------------------------------------------
  1837. void __fastcall TScpCommanderForm::ToolbarItemResize(TTBXCustomDropDownItem * Item, int Width)
  1838. {
  1839. TCustomScpExplorerForm::ToolbarItemResize(Item, Width);
  1840. if ((Item == LocalPathComboBox) ||
  1841. (Item == RemotePathComboBox) ||
  1842. (Item == CommandLineCombo))
  1843. {
  1844. dynamic_cast<TTBXComboBoxItem *>(Item)->MinListWidth = Width - 4;
  1845. }
  1846. }
  1847. //---------------------------------------------------------------------------
  1848. void __fastcall TScpCommanderForm::CommandLineComboPopup(
  1849. TTBCustomItem * /*Sender*/, bool /*FromLink*/)
  1850. {
  1851. CommandLinePopulate();
  1852. }
  1853. //---------------------------------------------------------------------------
  1854. void __fastcall TScpCommanderForm::CommandLineComboBeginEdit(
  1855. TTBEditItem * /*Sender*/, TTBEditItemViewer * /*Viewer*/, TEdit *EditControl)
  1856. {
  1857. InstallPathWordBreakProc(EditControl);
  1858. FCommandLineComboEdit = EditControl;
  1859. FToolbarEditOldWndProc = EditControl->WindowProc;
  1860. EditControl->WindowProc = CommandLineComboEditWndProc;
  1861. }
  1862. //---------------------------------------------------------------------------
  1863. void __fastcall TScpCommanderForm::ExitToolbar()
  1864. {
  1865. CurrentPanel()->SetFocus();
  1866. }
  1867. //---------------------------------------------------------------------------
  1868. void __fastcall TScpCommanderForm::CommandLineComboEditWndProc(TMessage & Message)
  1869. {
  1870. bool Handled = false;
  1871. if (Message.Msg == WM_CHAR)
  1872. {
  1873. switch (reinterpret_cast<TWMChar &>(Message).CharCode)
  1874. {
  1875. case VK_ESCAPE:
  1876. CommandLineCombo->Text = L"";
  1877. ExitToolbar();
  1878. Handled = true;
  1879. break;
  1880. case VK_TAB:
  1881. CommandLineCombo->Text = FCommandLineComboEdit->Text;
  1882. ExitToolbar();
  1883. Handled = true;
  1884. break;
  1885. case VK_RETURN:
  1886. CommandLineCombo->Text = FCommandLineComboEdit->Text;
  1887. ExitToolbar();
  1888. if (!ExecuteCommandLine())
  1889. {
  1890. // re-enter command line
  1891. // (most probably exited by now as message dialog was shown)
  1892. GoToCommandLine();
  1893. }
  1894. Handled = true;
  1895. break;
  1896. }
  1897. }
  1898. if (!Handled)
  1899. {
  1900. FToolbarEditOldWndProc(Message);
  1901. }
  1902. }
  1903. //---------------------------------------------------------------------------
  1904. void __fastcall TScpCommanderForm::LocalDriveViewRefreshDrives(TObject * /*Sender*/)
  1905. {
  1906. LocalPathComboUpdateDrives();
  1907. LocalPathComboUpdate();
  1908. }
  1909. //---------------------------------------------------------------------------
  1910. void __fastcall TScpCommanderForm::HomeDirectory(TOperationSide Side)
  1911. {
  1912. TSynchronizedBrowsingGuard SynchronizedBrowsingGuard;
  1913. TCustomScpExplorerForm::HomeDirectory(Side);
  1914. }
  1915. //---------------------------------------------------------------------------
  1916. void __fastcall TScpCommanderForm::QueueSubmenuItemPopup(
  1917. TTBCustomItem * /*Sender*/, bool /*FromLink*/)
  1918. {
  1919. NonVisualDataModule->QueueSpeedComboBoxItemUpdate(QueueSpeedComboBoxItem);
  1920. }
  1921. //---------------------------------------------------------------------------
  1922. void __fastcall TScpCommanderForm::DoFocusRemotePath(UnicodeString Path)
  1923. {
  1924. TSynchronizedBrowsingGuard SynchronizedBrowsingGuard;
  1925. TCustomScpExplorerForm::DoFocusRemotePath(Path);
  1926. }
  1927. //---------------------------------------------------------------------------
  1928. void __fastcall TScpCommanderForm::HistoryGo(TOperationSide Side, int Index)
  1929. {
  1930. TOperationSide OtherSide = ((Side == osLocal) ? osRemote : osLocal);
  1931. if (NonVisualDataModule->SynchronizeBrowsingAction->Checked &&
  1932. ((Index < 0) ? (-Index < DirView(OtherSide)->BackCount) : (Index < DirView(OtherSide)->ForwardCount)))
  1933. {
  1934. TSynchronizedBrowsingGuard SynchronizedBrowsingGuard;
  1935. TCustomScpExplorerForm::HistoryGo(Side, Index);
  1936. TCustomScpExplorerForm::HistoryGo(OtherSide, Index);
  1937. }
  1938. else
  1939. {
  1940. TCustomScpExplorerForm::HistoryGo(Side, Index);
  1941. }
  1942. }
  1943. //---------------------------------------------------------------------------
  1944. void __fastcall TScpCommanderForm::DirViewHistoryGo(
  1945. TCustomDirView * Sender, int Index, bool & Cancel)
  1946. {
  1947. TOperationSide Side = (Sender == DirView(osRemote) ? osRemote : osLocal);
  1948. HistoryGo(Side, Index);
  1949. Cancel = true;
  1950. }
  1951. //---------------------------------------------------------------------------
  1952. bool __fastcall TScpCommanderForm::EligibleForImageDisplayMode(TTBCustomItem * Item)
  1953. {
  1954. return
  1955. TCustomScpExplorerForm::EligibleForImageDisplayMode(Item) &&
  1956. ((Item->Parent == NULL) || (Item->Parent->ParentComponent != Toolbar2Toolbar));
  1957. }
  1958. //---------------------------------------------------------------------------
  1959. bool __fastcall TScpCommanderForm::UpdateToolbarDisplayMode()
  1960. {
  1961. bool Result = TCustomScpExplorerForm::UpdateToolbarDisplayMode();
  1962. if (Result)
  1963. {
  1964. // command line combo width needs to be updated as caption visibility has changed
  1965. ToolBarResize(CommandLineToolbar);
  1966. }
  1967. return Result;
  1968. }
  1969. //---------------------------------------------------------------------------
  1970. void __fastcall TScpCommanderForm::QueueLabelUpdateStatus()
  1971. {
  1972. TCustomScpExplorerForm::QueueLabelUpdateStatus();
  1973. // this is here to deactivate panels path labels when moving focus from
  1974. // directory tree to queue
  1975. UpdatePanelsPathLabelsStatus();
  1976. }
  1977. //---------------------------------------------------------------------------
  1978. void __fastcall TScpCommanderForm::LocalDirViewContextPopup(TObject * /*Sender*/,
  1979. TPoint & MousePos, bool & Handled)
  1980. {
  1981. if (!WinConfiguration->ScpCommander.SystemContextMenu && !FForceSystemContextMenu)
  1982. {
  1983. DirViewContextPopupDefaultItem(osLocal, NonVisualDataModule->LocalOpenMenuItem, dcaOpen);
  1984. DirViewContextPopupDefaultItem(osLocal, NonVisualDataModule->LocalEditMenuItem, dcaEdit);
  1985. DirViewContextPopupDefaultItem(osLocal, NonVisualDataModule->LocalCopyMenuItem, dcaCopy);
  1986. DirViewContextPopup(osLocal, fcLocalPopup, MousePos);
  1987. Handled = true;
  1988. }
  1989. }
  1990. //---------------------------------------------------------------------------
  1991. void __fastcall TScpCommanderForm::DisplaySystemContextMenu()
  1992. {
  1993. TAutoFlag Flag(FForceSystemContextMenu);
  1994. if ((FLastContextPopupScreenPoint.x >= 0) && (FLastContextPopupScreenPoint.Y >= 0))
  1995. {
  1996. LocalDirView->DisplayContextMenu(FLastContextPopupScreenPoint);
  1997. }
  1998. else
  1999. {
  2000. LocalDirView->DisplayContextMenuInSitu();
  2001. }
  2002. }
  2003. //---------------------------------------------------------------------------
  2004. void __fastcall TScpCommanderForm::LocalStatusBarPanelClick(TTBXCustomStatusBar * /*Sender*/,
  2005. TTBXStatusPanel * Panel)
  2006. {
  2007. FileStatusBarPanelClick(Panel, osLocal);
  2008. }
  2009. //---------------------------------------------------------------------------
  2010. void __fastcall TScpCommanderForm::RemoteStatusBarPanelClick(TTBXCustomStatusBar * /*Sender*/,
  2011. TTBXStatusPanel *Panel)
  2012. {
  2013. FileStatusBarPanelClick(Panel, osRemote);
  2014. }
  2015. //---------------------------------------------------------------------------
  2016. void __fastcall TScpCommanderForm::GoToAddress()
  2017. {
  2018. OpenDirectory(GetSide(osCurrent));
  2019. }
  2020. //---------------------------------------------------------------------------