ScpCommander.cpp 74 KB

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