ScpCommander.cpp 74 KB

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