ScpCommander.cpp 73 KB

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