ScpCommander.cpp 74 KB

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