ScpCommander.cpp 74 KB

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