ScpCommander.cpp 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "ScpCommander.h"
  5. #include <Common.h>
  6. #include <Net.h>
  7. #include <ScpMain.h>
  8. #include <Interface.h>
  9. #include <TextsWin.h>
  10. #include <VCLCommon.h>
  11. #include <GUITools.h>
  12. #include <DragDrop.hpp>
  13. #include "NonVisual.h"
  14. #include "Tools.h"
  15. #include "WinConfiguration.h"
  16. #include "TerminalManager.h"
  17. //---------------------------------------------------------------------------
  18. #pragma package(smart_init)
  19. #pragma link "AssociatedStatusBar"
  20. #pragma link "CustomDirView"
  21. #pragma link "CustomScpExplorer"
  22. #pragma link "CustomUnixDirView"
  23. #pragma link "IEListView"
  24. #pragma link "NortonLikeListView"
  25. #pragma link "UnixDirView"
  26. #pragma link "DirView"
  27. #pragma link "CustomPathComboBox"
  28. #pragma link "IEComboBox"
  29. #pragma link "IEPathComboBox"
  30. #pragma link "PathLabel"
  31. #pragma link "UnixPathComboBox"
  32. #pragma link "ToolbarPanel"
  33. #pragma link "HistoryComboBox"
  34. #pragma link "CustomDriveView"
  35. #pragma link "DriveView"
  36. #pragma link "UnixDriveView"
  37. #pragma resource "*.dfm"
  38. //---------------------------------------------------------------------------
  39. __fastcall TScpCommanderForm::TScpCommanderForm(TComponent* Owner)
  40. : TCustomScpExplorerForm(Owner)
  41. {
  42. FCurrentSide = osLocal;
  43. FLastLocalPanelWidth = LocalPanelWidth;
  44. FSynchronisingBrowse = false;
  45. FFirstTerminal = true;
  46. FInternalDDDownloadList = new TStringList();
  47. LocalBackButton->DropdownMenu = LocalDirView->BackMenu;
  48. LocalForwardButton->DropdownMenu = LocalDirView->ForwardMenu;
  49. RemoteBackButton->DropdownMenu = RemoteDirView->BackMenu;
  50. RemoteForwardButton->DropdownMenu = RemoteDirView->ForwardMenu;
  51. SavedSessionsButton->OnClick = DropDownButtonMenu;
  52. TopCoolBar->PopupMenu = NonVisualDataModule->CommanderBarPopup;
  53. ToolbarPanel->PopupMenu = TopCoolBar->PopupMenu;
  54. StatusBar->PopupMenu = TopCoolBar->PopupMenu;
  55. QueueCoolBar->PopupMenu = TopCoolBar->PopupMenu;
  56. LocalCoolBar->PopupMenu = NonVisualDataModule->LocalPanelPopup;
  57. LocalPathLabel->PopupMenu = LocalCoolBar->PopupMenu;
  58. LocalStatusBar->PopupMenu = LocalCoolBar->PopupMenu;
  59. LocalDriveView->PopupMenu = LocalCoolBar->PopupMenu;
  60. RemoteCoolBar->PopupMenu = NonVisualDataModule->RemotePanelPopup;
  61. RemotePathLabel->PopupMenu = RemoteCoolBar->PopupMenu;
  62. RemoteStatusBar->PopupMenu = RemoteCoolBar->PopupMenu;
  63. RemoteDriveView->PopupMenu = RemoteCoolBar->PopupMenu;
  64. // set common norton shorcuts to our actions
  65. NonVisualDataModule->CommanderShortcuts();
  66. Splitter->ShowHint = True;
  67. reinterpret_cast<TLabel*>(Splitter)->OnDblClick = SplitterDblClick;
  68. reinterpret_cast<TLabel*>(LocalPanelSplitter)->OnDblClick = PanelSplitterDblClick;
  69. reinterpret_cast<TLabel*>(RemotePanelSplitter)->OnDblClick = PanelSplitterDblClick;
  70. RemotePathComboBox->TabStop = False;
  71. CommandLineLabel->FocusControl = CommandLineCombo;
  72. CommandLineCombo->Text = "";
  73. FCommandLineComboPopulated = false;
  74. LocalDirView->Font = Screen->IconFont;
  75. }
  76. //---------------------------------------------------------------------------
  77. __fastcall TScpCommanderForm::~TScpCommanderForm()
  78. {
  79. delete FInternalDDDownloadList;
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TScpCommanderForm::RestoreFormParams()
  83. {
  84. assert(WinConfiguration);
  85. TCustomScpExplorerForm::RestoreFormParams();
  86. WinConfiguration->RestoreForm(WinConfiguration->ScpCommander.WindowParams, this);
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TScpCommanderForm::RestoreParams()
  90. {
  91. assert(Configuration);
  92. // called later once again after menu font is updated (see FormShow)
  93. SetCoolBandsMinWidth(TopCoolBar);
  94. SetCoolBandsMinWidth(LocalCoolBar);
  95. SetCoolBandsMinWidth(RemoteCoolBar);
  96. // IDE often looses this link
  97. LocalDirView->HeaderImages = NonVisualDataModule->ArrowImages;
  98. TCustomScpExplorerForm::RestoreParams();
  99. LocalPanelWidth = WinConfiguration->ScpCommander.LocalPanelWidth;
  100. LoadCoolbarLayoutStr(TopCoolBar, WinConfiguration->ScpCommander.CoolBarLayout);
  101. StatusBar->Visible = WinConfiguration->ScpCommander.StatusBar;
  102. ToolbarPanel->Visible = WinConfiguration->ScpCommander.ToolBar;
  103. CommandLinePanel->Visible = WinConfiguration->ScpCommander.CommandLine;
  104. FDirViewToSelect = (WinConfiguration->ScpCommander.CurrentPanel == osLocal ?
  105. (TCustomDirView *)LocalDirView : (TCustomDirView *)RemoteDirView);
  106. #define RESTORE_PANEL_PARAMS(PANEL) \
  107. PANEL ## DirView->ColProperties->ParamsStr = WinConfiguration->ScpCommander.PANEL ## Panel.DirViewParams; \
  108. PANEL ## StatusBar->Visible = WinConfiguration->ScpCommander.PANEL ## Panel.StatusBar; \
  109. LoadCoolbarLayoutStr(PANEL ## CoolBar, WinConfiguration->ScpCommander.PANEL ## Panel.CoolBarLayout); \
  110. PANEL ## DriveView->Visible = WinConfiguration->ScpCommander.PANEL ## Panel.DriveView; \
  111. PANEL ## DriveView->Height = WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewHeight
  112. RESTORE_PANEL_PARAMS(Local);
  113. RESTORE_PANEL_PARAMS(Remote);
  114. #undef RESTORE_PANEL_PARAMS
  115. NonVisualDataModule->SynchronizeBrowsingAction->Checked = WinConfiguration->ScpCommander.SynchronizeBrowsing;
  116. }
  117. //---------------------------------------------------------------------------
  118. void __fastcall TScpCommanderForm::StoreParams()
  119. {
  120. assert(WinConfiguration);
  121. WinConfiguration->BeginUpdate();
  122. try
  123. {
  124. WinConfiguration->ScpCommander.CoolBarLayout = GetCoolbarLayoutStr(TopCoolBar);
  125. WinConfiguration->ScpCommander.LocalPanelWidth = LocalPanelWidth;
  126. WinConfiguration->ScpCommander.StatusBar = StatusBar->Visible;
  127. WinConfiguration->ScpCommander.ToolBar = ToolbarPanel->Visible;
  128. WinConfiguration->ScpCommander.CommandLine = CommandLinePanel->Visible;
  129. SaveCommandLine();
  130. WinConfiguration->ScpCommander.CurrentPanel = FCurrentSide;
  131. #define STORE_PANEL_PARAMS(PANEL) \
  132. WinConfiguration->ScpCommander.PANEL ## Panel.DirViewParams = PANEL ## DirView->ColProperties->ParamsStr; \
  133. WinConfiguration->ScpCommander.PANEL ## Panel.StatusBar = PANEL ## StatusBar->Visible; \
  134. WinConfiguration->ScpCommander.PANEL ## Panel.CoolBarLayout = GetCoolbarLayoutStr(PANEL ## CoolBar); \
  135. WinConfiguration->ScpCommander.PANEL ## Panel.DriveView = PANEL ## DriveView->Visible; \
  136. WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewHeight = PANEL ## DriveView->Height
  137. STORE_PANEL_PARAMS(Local);
  138. STORE_PANEL_PARAMS(Remote);
  139. #undef RESTORE_PANEL_PARAMS
  140. WinConfiguration->ScpCommander.WindowParams = WinConfiguration->StoreForm(this);;
  141. WinConfiguration->ScpCommander.SynchronizeBrowsing = NonVisualDataModule->SynchronizeBrowsingAction->Checked;
  142. TCustomScpExplorerForm::StoreParams();
  143. }
  144. __finally
  145. {
  146. WinConfiguration->EndUpdate();
  147. }
  148. }
  149. //---------------------------------------------------------------------------
  150. void __fastcall TScpCommanderForm::UpdateSessionData(TSessionData * Data)
  151. {
  152. assert(Terminal && Terminal->SessionData);
  153. if (!Data)
  154. {
  155. Data = Terminal->SessionData;
  156. }
  157. TCustomScpExplorerForm::UpdateSessionData(Data);
  158. assert(LocalDirView);
  159. Data->LocalDirectory = LocalDirView->PathName;
  160. }
  161. //---------------------------------------------------------------------------
  162. bool __fastcall TScpCommanderForm::InternalDDDownload(AnsiString & TargetDirectory)
  163. {
  164. assert(IsFileControl(FDDTargetControl, osLocal));
  165. bool Result = false;
  166. if (FDDTargetControl == LocalDirView)
  167. {
  168. if (LocalDirView->DropTarget)
  169. {
  170. // when drop target is not directory, it is probably file type, which have
  171. // associated drop handler (such as ZIP file in WinXP). in this case we
  172. // must leave drop handling to destination application.
  173. // ! this check is duplicated in LocalDirViewDDTargetHasDropHandler()
  174. // for shellex downloads
  175. if (LocalDirView->ItemIsDirectory(LocalDirView->DropTarget))
  176. {
  177. TargetDirectory = LocalDirView->ItemFullFileName(LocalDirView->DropTarget);
  178. Result = true;
  179. }
  180. }
  181. else
  182. {
  183. TargetDirectory = IncludeTrailingBackslash(LocalDirView->Path);
  184. Result = true;
  185. }
  186. }
  187. else if (FDDTargetControl == LocalDriveView)
  188. {
  189. assert(LocalDriveView->DropTarget != NULL);
  190. TargetDirectory = LocalDriveView->NodePathName(LocalDriveView->DropTarget);
  191. Result = true;
  192. }
  193. else
  194. {
  195. assert(false);
  196. Abort();
  197. }
  198. return Result;
  199. }
  200. //---------------------------------------------------------------------------
  201. bool __fastcall TScpCommanderForm::CopyParamDialog(TTransferDirection Direction,
  202. TTransferType Type, bool DragDrop, TStrings * FileList, AnsiString & TargetDirectory,
  203. TGUICopyParamType & CopyParam, bool Confirm)
  204. {
  205. bool Result = false;
  206. if (DragDrop && (Direction == tdToLocal) &&
  207. IsFileControl(FDDTargetControl, osLocal))
  208. {
  209. Result = InternalDDDownload(TargetDirectory);
  210. if (Result)
  211. {
  212. assert(FileList->Count > 0);
  213. FInternalDDDownloadList->Assign(FileList);
  214. }
  215. }
  216. else if (!DragDrop && TargetDirectory.IsEmpty())
  217. {
  218. if (Direction == tdToLocal)
  219. {
  220. TargetDirectory = IncludeTrailingBackslash(LocalDirView->Path);
  221. }
  222. else
  223. {
  224. TargetDirectory = UnixIncludeTrailingBackslash(RemoteDirView->Path);
  225. }
  226. }
  227. if (!Result)
  228. {
  229. Result = TCustomScpExplorerForm::CopyParamDialog(Direction, Type, DragDrop,
  230. FileList, TargetDirectory, CopyParam, Confirm);
  231. }
  232. return Result;
  233. }
  234. //---------------------------------------------------------------------------
  235. void __fastcall TScpCommanderForm::DoShow()
  236. {
  237. TCustomScpExplorerForm::DoShow();
  238. assert(FDirViewToSelect);
  239. FDirViewToSelect->SetFocus();
  240. // called for second time after menu font was updated (see also RestoreParams)
  241. SetCoolBandsMinWidth(TopCoolBar);
  242. SetCoolBandsMinWidth(LocalCoolBar);
  243. SetCoolBandsMinWidth(RemoteCoolBar);
  244. UpdateControls();
  245. }
  246. //---------------------------------------------------------------------------
  247. Boolean __fastcall TScpCommanderForm::AllowedAction(TAction * Action, TActionAllowed Allowed)
  248. {
  249. #define FLAG ((TActionFlag)(Action->Tag))
  250. return
  251. // always require Commander flag
  252. (FLAG & afCommander) &&
  253. // if action is execution or update, we don't require any other flag
  254. // if we check for shortcut, we require proper dirview to be selected
  255. ((Allowed != aaShortCut) ||
  256. ((FLAG & afLocal) && (FCurrentSide == osLocal)) ||
  257. ((FLAG & afRemote) && (FCurrentSide == osRemote))
  258. );
  259. #undef FLAG
  260. }
  261. //---------------------------------------------------------------------------
  262. TCustomDirView * __fastcall TScpCommanderForm::DirView(TOperationSide Side)
  263. {
  264. Side = GetSide(Side);
  265. if (Side == osLocal)
  266. {
  267. return LocalDirView;
  268. }
  269. else
  270. {
  271. return TCustomScpExplorerForm::DirView(Side);
  272. }
  273. }
  274. //---------------------------------------------------------------------------
  275. bool __fastcall TScpCommanderForm::IsFileControl(TObject * Control,
  276. TOperationSide Side)
  277. {
  278. return
  279. ((Side == osLocal) &&
  280. ((Control == LocalDirView) || (Control == LocalDriveView))) ||
  281. TCustomScpExplorerForm::IsFileControl(Control, Side);
  282. }
  283. //---------------------------------------------------------------------------
  284. void __fastcall TScpCommanderForm::ReloadLocalDirectory(const AnsiString Directory)
  285. {
  286. if (Directory.IsEmpty() || ComparePaths(Directory, LocalDirView->Path))
  287. {
  288. LocalDirView->ReloadDirectory();
  289. LocalDriveView->ValidateDirectory(LocalDriveView->Selected);
  290. }
  291. TCustomScpExplorerForm::ReloadLocalDirectory();
  292. }
  293. //---------------------------------------------------------------------------
  294. void __fastcall TScpCommanderForm::BatchStart(void *& Storage)
  295. {
  296. Storage = new bool;
  297. *static_cast<bool*>(Storage) = LocalDirView->WatchForChanges;
  298. LocalDirView->WatchForChanges = false;
  299. LocalDriveView->WatchDirectory = false;
  300. TCustomScpExplorerForm::BatchStart(Storage);
  301. }
  302. //---------------------------------------------------------------------------
  303. void __fastcall TScpCommanderForm::BatchEnd(void * Storage)
  304. {
  305. TCustomScpExplorerForm::BatchEnd(Storage);
  306. assert(Storage != NULL);
  307. LocalDirView->WatchForChanges = *static_cast<bool*>(Storage);
  308. LocalDriveView->WatchDirectory = LocalDirView->WatchForChanges;
  309. delete Storage;
  310. }
  311. //---------------------------------------------------------------------------
  312. void __fastcall TScpCommanderForm::TerminalChanged()
  313. {
  314. if (Terminal)
  315. {
  316. bool WasSynchronisingBrowsing = NonVisualDataModule->SynchronizeBrowsingAction->Checked;
  317. NonVisualDataModule->SynchronizeBrowsingAction->Checked = false;
  318. TCustomScpExplorerForm::TerminalChanged();
  319. if (FFirstTerminal || !WinConfiguration->ScpCommander.PreserveLocalDirectory)
  320. {
  321. AnsiString LocalDirectory = Terminal->SessionData->LocalDirectory;
  322. bool DocumentsDir = LocalDirectory.IsEmpty();
  323. if (!DocumentsDir)
  324. {
  325. try
  326. {
  327. LocalDirView->Path = LocalDirectory;
  328. }
  329. catch(Exception & E)
  330. {
  331. DocumentsDir = true;
  332. Terminal->DoShowExtendedException(&E);
  333. }
  334. }
  335. if (DocumentsDir)
  336. {
  337. try
  338. {
  339. LocalDirView->HomeDirectory = "";
  340. LocalDirView->ExecuteHomeDirectory();
  341. }
  342. catch(Exception & E)
  343. {
  344. Terminal->DoShowExtendedException(&E);
  345. LocalDirView->Path = ExtractFilePath(Application->ExeName);
  346. }
  347. }
  348. if (WinConfiguration->DefaultDirIsHome &&
  349. !Terminal->SessionData->UpdateDirectories)
  350. {
  351. LocalDirView->HomeDirectory = LocalDirectory;
  352. }
  353. }
  354. FFirstTerminal = false;
  355. if (WasSynchronisingBrowsing &&
  356. SameText(ExtractFileName(LocalDirView->PathName),
  357. UnixExtractFileName(RemoteDirView->PathName)))
  358. {
  359. NonVisualDataModule->SynchronizeBrowsingAction->Checked = true;
  360. }
  361. }
  362. else
  363. {
  364. TCustomScpExplorerForm::TerminalChanged();
  365. }
  366. }
  367. //---------------------------------------------------------------------------
  368. void __fastcall TScpCommanderForm::ConfigurationChanged()
  369. {
  370. TCustomScpExplorerForm::ConfigurationChanged();
  371. if (WinConfiguration->DefaultDirIsHome && Terminal)
  372. {
  373. LocalDirView->HomeDirectory = Terminal->SessionData->LocalDirectory;
  374. }
  375. else
  376. {
  377. LocalDirView->HomeDirectory = "";
  378. }
  379. LocalDirView->DimmHiddenFiles = WinConfiguration->DimmHiddenFiles;
  380. LocalDriveView->DimmHiddenDirs = WinConfiguration->DimmHiddenFiles;
  381. LocalDirView->ShowHiddenFiles = WinConfiguration->ShowHiddenFiles;
  382. LocalDriveView->ShowHiddenDirs = WinConfiguration->ShowHiddenFiles;
  383. LocalDirView->NortonLike = !WinConfiguration->ScpCommander.ExplorerStyleSelection;
  384. RemoteDirView->NortonLike = !WinConfiguration->ScpCommander.ExplorerStyleSelection;
  385. LocalDirView->DragDropFilesEx->ShellExtensions->DropHandler =
  386. !WinConfiguration->DDExtEnabled;
  387. LocalDriveView->DragDropFilesEx->ShellExtensions->DropHandler =
  388. !WinConfiguration->DDExtEnabled;
  389. }
  390. //---------------------------------------------------------------------------
  391. void __fastcall TScpCommanderForm::SetLocalPanelWidth(float value)
  392. {
  393. float Total = LocalPanel->Width + RemotePanel->Width;
  394. FLocalPanelWidth = value;
  395. if (value * Total != LocalPanel->Width)
  396. {
  397. LocalPanel->Width = value * Total;
  398. UpdateControls();
  399. }
  400. }
  401. //---------------------------------------------------------------------------
  402. float __fastcall TScpCommanderForm::GetLocalPanelWidth()
  403. {
  404. return FLocalPanelWidth;
  405. }
  406. //---------------------------------------------------------------------------
  407. void __fastcall TScpCommanderForm::SplitterMoved(TObject * /*Sender*/)
  408. {
  409. float Local = LocalPanel->Width;
  410. float Total = LocalPanel->Width + RemotePanel->Width;
  411. FLocalPanelWidth = Local / Total;
  412. FLastLocalPanelWidth = LocalPanelWidth;
  413. UpdateControls();
  414. }
  415. //---------------------------------------------------------------------------
  416. void __fastcall TScpCommanderForm::SplitterCanResize(TObject * /*Sender*/,
  417. int &NewSize, bool & /*Accept*/)
  418. {
  419. // When splitter is drag so far to right, that width contraint of remote panel would
  420. // be violated, it doesn't stop, but extend form width.
  421. // Following prevents this behaviour.
  422. if (ClientWidth - NewSize - Splitter->Width < RemotePanel->Constraints->MinWidth)
  423. NewSize = (ClientWidth - RemotePanel->Constraints->MinWidth - Splitter->Width);
  424. }
  425. //---------------------------------------------------------------------------
  426. void __fastcall TScpCommanderForm::SplitterDblClick(TObject * /*Sender*/)
  427. {
  428. LocalPanelWidth = 0.5;
  429. }
  430. //---------------------------------------------------------------------------
  431. void __fastcall TScpCommanderForm::PanelSplitterDblClick(TObject * Sender)
  432. {
  433. TSplitter * Splitter = dynamic_cast<TSplitter *>(Sender);
  434. assert(Splitter != NULL);
  435. TCustomDriveView * DriveView;
  436. TCustomDriveView * OtherDriveView;
  437. if (Splitter == LocalPanelSplitter)
  438. {
  439. DriveView = LocalDriveView;
  440. OtherDriveView = RemoteDriveView;
  441. }
  442. else
  443. {
  444. DriveView = RemoteDriveView;
  445. OtherDriveView = LocalDriveView;
  446. }
  447. assert(DriveView->Visible);
  448. if (OtherDriveView->Visible)
  449. {
  450. DriveView->Height = OtherDriveView->Height;
  451. }
  452. else
  453. {
  454. OtherDriveView->Height = DriveView->Height;
  455. OtherDriveView->Visible = true;
  456. }
  457. FixControlsPlacement();
  458. }
  459. //---------------------------------------------------------------------------
  460. void __fastcall TScpCommanderForm::UpdateControls()
  461. {
  462. Splitter->Hint = FormatFloat("0%|X", LocalPanelWidth*100);
  463. CommandLineLabel->UnixPath = (FCurrentSide == osRemote);
  464. CommandLineLabel->Caption = DirView(osCurrent)->PathName;
  465. CommandLinePromptLabel->Caption =
  466. (FCurrentSide == osRemote) ? "$" : ">";
  467. }
  468. //---------------------------------------------------------------------------
  469. void __fastcall TScpCommanderForm::ChangePath(TOperationSide Side)
  470. {
  471. assert((Side == osLocal) || (Side == osRemote));
  472. TCustomPathComboBox * PathComboBox;
  473. if (Side == osLocal) PathComboBox = LocalPathComboBox;
  474. else PathComboBox = RemotePathComboBox;
  475. assert(PathComboBox);
  476. PathComboBox->SetFocus();
  477. PathComboBox->DroppedDown = True;
  478. }
  479. //---------------------------------------------------------------------------
  480. void __fastcall TScpCommanderForm::PathComboBoxCloseUp(TObject * /*Sender*/,
  481. bool /*Canceled*/)
  482. {
  483. DirView(osCurrent)->SetFocus();
  484. }
  485. //---------------------------------------------------------------------------
  486. void __fastcall TScpCommanderForm::SessionComboCloseUp(TObject *Sender)
  487. {
  488. PathComboBoxCloseUp(Sender, false);
  489. }
  490. //---------------------------------------------------------------------------
  491. TControl * __fastcall TScpCommanderForm::GetComponent(Byte Component)
  492. {
  493. switch (Component) {
  494. case fcToolBar: return ToolbarPanel;
  495. case fcStatusBar: return StatusBar;
  496. case fcLocalCoolBar: return LocalCoolBar;
  497. case fcLocalStatusBar: return LocalStatusBar;
  498. case fcRemoteCoolBar: return RemoteCoolBar;
  499. case fcRemoteStatusBar: return RemoteStatusBar;
  500. case fcSessionCombo: return SessionCombo;
  501. case fcMenuToolBar: return MenuToolBar;
  502. case fcCommandLinePanel: return CommandLinePanel;
  503. case fcLocalTree: return LocalDriveView;
  504. default: return TCustomScpExplorerForm::GetComponent(Component);
  505. }
  506. }
  507. //---------------------------------------------------------------------------
  508. void __fastcall TScpCommanderForm::FixControlsPlacement()
  509. {
  510. TCustomScpExplorerForm::FixControlsPlacement();
  511. LocalPanelSplitter->Visible = LocalDriveView->Visible;
  512. TControl * ControlsOrder[] =
  513. { CommandLinePanel, QueueSplitter, QueuePanel, ToolbarPanel, StatusBar };
  514. SetVerticalControlsOrder(ControlsOrder, LENOF(ControlsOrder));
  515. TControl * LocalControlsOrder[] =
  516. { LocalDriveView, LocalPanelSplitter, LocalDirView };
  517. SetVerticalControlsOrder(LocalControlsOrder, LENOF(LocalControlsOrder));
  518. TControl * RemoteControlsOrder[] =
  519. { RemoteDriveView, RemotePanelSplitter, RemoteDirView };
  520. SetVerticalControlsOrder(RemoteControlsOrder, LENOF(RemoteControlsOrder));
  521. if (LocalDirView->ItemFocused != NULL)
  522. {
  523. LocalDirView->ItemFocused->MakeVisible(false);
  524. }
  525. }
  526. //---------------------------------------------------------------------------
  527. bool __fastcall TScpCommanderForm::GetHasDirView(TOperationSide Side)
  528. {
  529. return TCustomScpExplorerForm::GetHasDirView(Side) || (Side == osLocal);
  530. }
  531. //---------------------------------------------------------------------------
  532. void __fastcall TScpCommanderForm::CompareDirectories()
  533. {
  534. LocalDirView->CompareFiles(RemoteDirView, false,
  535. WinConfiguration->ScpCommander.CompareCriterias());
  536. RemoteDirView->CompareFiles(LocalDirView, false,
  537. WinConfiguration->ScpCommander.CompareCriterias());
  538. if (LocalDirView->SelCount + RemoteDirView->SelCount == 0)
  539. {
  540. MessageDialog(LoadStr(COMPARE_NO_DIFFERENCES), qtInformation, qaOK, 0);
  541. }
  542. }
  543. //---------------------------------------------------------------------------
  544. void __fastcall TScpCommanderForm::SynchronizeDirectories()
  545. {
  546. AnsiString LocalDirectory = LocalDirView->PathName;
  547. AnsiString RemoteDirectory = RemoteDirView->PathName;
  548. DoSynchronizeDirectories(LocalDirectory, RemoteDirectory);
  549. }
  550. //---------------------------------------------------------------------------
  551. void __fastcall TScpCommanderForm::FullSynchronizeDirectories()
  552. {
  553. AnsiString LocalDirectory = LocalDirView->PathName;
  554. AnsiString RemoteDirectory = RemoteDirView->PathName;
  555. TSynchronizeMode Mode = (FCurrentSide == osLocal) ? smRemote : smLocal;
  556. DoFullSynchronizeDirectories(LocalDirectory, RemoteDirectory, Mode);
  557. }
  558. //---------------------------------------------------------------------------
  559. void __fastcall TScpCommanderForm::ExploreLocalDirectory()
  560. {
  561. if ((int)ShellExecute(Application->Handle, "explore",
  562. (char*)LocalDirView->Path.data(), NULL, NULL, SW_SHOWNORMAL) <= 32)
  563. {
  564. throw Exception(FORMAT(EXPLORE_LOCAL_DIR_ERROR, (LocalDirView->Path)));
  565. }
  566. }
  567. //---------------------------------------------------------------------------
  568. void __fastcall TScpCommanderForm::LocalDirViewExecFile(TObject *Sender,
  569. TListItem *Item, bool &AllowExec)
  570. {
  571. assert(Item);
  572. if ((UpperCase(PFileRec(Item->Data)->FileExt) == "LNK") &&
  573. DirectoryExists(ResolveFileShortCut(LocalDirView->ItemFullFileName(Item), true)))
  574. {
  575. AllowExec = true;
  576. }
  577. else
  578. {
  579. DoDirViewExecFile(Sender, Item, AllowExec);
  580. }
  581. }
  582. //---------------------------------------------------------------------------
  583. void __fastcall TScpCommanderForm::LocalFileControlDDDragEnter(TObject *Sender,
  584. IDataObject *DataObj, int grfKeyState, TPoint &Point, int &dwEffect,
  585. bool &Accept)
  586. {
  587. // LocalDirViewDDDragEnter is duplication of
  588. // TCustomScpExplorerForm::DirViewDDDragEnter, but it differs in
  589. // literal type of 'DataObj' parameter.Actual type is however same
  590. FileControlDDDragEnter(Sender, DataObj, grfKeyState, Point, dwEffect, Accept);
  591. }
  592. //---------------------------------------------------------------------------
  593. bool __fastcall TScpCommanderForm::PanelOperation(TOperationSide Side,
  594. bool DragDrop)
  595. {
  596. return TCustomScpExplorerForm::PanelOperation(Side, DragDrop) ||
  597. (DropSourceControl == LocalDirView);
  598. }
  599. //---------------------------------------------------------------------------
  600. void __fastcall TScpCommanderForm::FileOperationProgress(
  601. TFileOperationProgressType & ProgressData, TCancelStatus & Cancel)
  602. {
  603. // Heuristic: When operation finishes and DD targed is local dir view,
  604. // we suppose that drag&drop download finished, so local dir view should be
  605. // reloaded
  606. if (!ProgressData.InProgress && FProgressForm &&
  607. IsFileControl(FDDTargetControl, osLocal) &&
  608. ((ProgressData.Operation == ::foCopy) || (ProgressData.Operation == ::foMove)))
  609. {
  610. ReloadLocalDirectory();
  611. }
  612. TCustomScpExplorerForm::FileOperationProgress(ProgressData, Cancel);
  613. }
  614. //---------------------------------------------------------------------------
  615. void __fastcall TScpCommanderForm::DirViewLoaded(TObject *Sender)
  616. {
  617. UpdateControls();
  618. try
  619. {
  620. TCustomDirView * ADirView = dynamic_cast<TCustomDirView *>(Sender);
  621. assert(ADirView);
  622. AnsiString PrevPath = FPrevPath[ADirView == LocalDirView];
  623. AnsiString FullPrevPath =
  624. (ADirView == LocalDirView) ? IncludeTrailingBackslash(PrevPath) :
  625. UnixIncludeTrailingBackslash(PrevPath);
  626. FPrevPath[ADirView == LocalDirView] = ADirView->Path;
  627. if (!FSynchronisingBrowse && NonVisualDataModule->SynchronizeBrowsingAction->Checked &&
  628. !PrevPath.IsEmpty() && PrevPath != ADirView->Path)
  629. {
  630. FSynchronisingBrowse = true;
  631. if (ADirView == LocalDirView)
  632. {
  633. Terminal->ExceptionOnFail = true;
  634. try
  635. {
  636. if (LocalDirView->Path.SubString(1, FullPrevPath.Length()) == FullPrevPath)
  637. {
  638. RemoteDirView->Path = UnixIncludeTrailingBackslash(RemoteDirView->Path) +
  639. ToUnixPath(LocalDirView->Path.SubString(FullPrevPath.Length() + 1,
  640. LocalDirView->Path.Length() - FullPrevPath.Length()));
  641. }
  642. else if (FullPrevPath.SubString(1, LocalDirView->Path.Length()) == LocalDirView->Path)
  643. {
  644. AnsiString RemotePath = RemoteDirView->Path;
  645. while (!ComparePaths(FullPrevPath, LocalDirView->Path))
  646. {
  647. if (RemotePath == UnixExcludeTrailingBackslash(RemotePath))
  648. {
  649. Abort();
  650. }
  651. RemotePath = UnixExtractFilePath(UnixExcludeTrailingBackslash(RemotePath));
  652. FullPrevPath = ExtractFilePath(ExcludeTrailingBackslash(FullPrevPath));
  653. }
  654. RemoteDirView->Path = RemotePath;
  655. }
  656. else
  657. {
  658. Abort();
  659. }
  660. }
  661. __finally
  662. {
  663. Terminal->ExceptionOnFail = false;
  664. }
  665. }
  666. else
  667. {
  668. if (RemoteDirView->Path.SubString(1, FullPrevPath.Length()) == FullPrevPath)
  669. {
  670. LocalDirView->Path = IncludeTrailingBackslash(LocalDirView->Path) +
  671. FromUnixPath(RemoteDirView->Path.SubString(FullPrevPath.Length() + 1,
  672. RemoteDirView->Path.Length() - FullPrevPath.Length()));
  673. }
  674. else if (FullPrevPath.SubString(1, RemoteDirView->Path.Length()) == RemoteDirView->Path)
  675. {
  676. AnsiString NewLocalPath;
  677. AnsiString LocalPath = ExcludeTrailingBackslash(LocalDirView->Path);
  678. while (!UnixComparePaths(FullPrevPath, RemoteDirView->Path))
  679. {
  680. NewLocalPath = ExcludeTrailingBackslash(ExtractFileDir(LocalPath));
  681. if (NewLocalPath == LocalPath)
  682. {
  683. Abort();
  684. }
  685. LocalPath = NewLocalPath;
  686. FullPrevPath = UnixExtractFilePath(UnixExcludeTrailingBackslash(FullPrevPath));
  687. }
  688. LocalDirView->Path = LocalPath;
  689. }
  690. else
  691. {
  692. Abort();
  693. }
  694. }
  695. FSynchronisingBrowse = false;
  696. }
  697. }
  698. catch(Exception & E)
  699. {
  700. FSynchronisingBrowse = false;
  701. NonVisualDataModule->SynchronizeBrowsingAction->Checked = false;
  702. if (!Application->Terminated)
  703. {
  704. Terminal->DoShowExtendedException(&E);
  705. MessageDialog(LoadStr(SYNC_DIR_BROWSE_ERROR), qtInformation, qaOK, 0);
  706. }
  707. else
  708. {
  709. throw;
  710. }
  711. }
  712. }
  713. //---------------------------------------------------------------------------
  714. void __fastcall TScpCommanderForm::AddEditLink()
  715. {
  716. if (FCurrentSide == osLocal)
  717. {
  718. bool Edit = false;
  719. AnsiString FileName;
  720. AnsiString PointTo;
  721. bool SymbolicLink = true;
  722. if (LocalDirView->ItemFocused)
  723. {
  724. assert(LocalDirView->ItemFocused->Data);
  725. PFileRec FileRec = (PFileRec)LocalDirView->ItemFocused->Data;
  726. Edit = UpperCase(FileRec->FileExt) == "LNK";
  727. if (Edit)
  728. {
  729. AnsiString FullName = LocalDirView->ItemFullFileName(LocalDirView->ItemFocused);
  730. FileName = FullName;//FileRec->FileName;
  731. PointTo = ResolveFileShortCut(FullName, false);
  732. if (PointTo.IsEmpty())
  733. {
  734. throw Exception(FMTLOAD(RESOLVE_SHORTCUT_ERROR, (FullName)));
  735. }
  736. }
  737. else
  738. {
  739. PointTo = FileRec->FileName;
  740. }
  741. }
  742. if (DoSymlinkDialog(FileName, PointTo, osLocal, SymbolicLink, Edit, false))
  743. {
  744. assert(SymbolicLink);
  745. assert(!FileName.IsEmpty());
  746. assert(!PointTo.IsEmpty());
  747. if (ExtractFileDrive(FileName) == "" && FileName[1] != '\\')
  748. {
  749. FileName = IncludeTrailingBackslash(LocalDirView->PathName) + FileName;
  750. }
  751. if (ExtractFileDrive(PointTo) == "" && PointTo[1] != '\\')
  752. {
  753. PointTo = IncludeTrailingBackslash(LocalDirView->PathName) + PointTo;
  754. }
  755. if (ExtractFileExt(FileName) == "")
  756. {
  757. FileName = FileName + ".lnk";
  758. }
  759. if (Edit && !DeleteFile(FileName))
  760. {
  761. throw Exception(FMTLOAD(DELETE_LOCAL_FILE_ERROR, (FileName)));
  762. }
  763. if (!CreateFileShortCut(PointTo, FileName, ""))
  764. {
  765. throw Exception(CREATE_SHORTCUT_ERROR);
  766. }
  767. }
  768. }
  769. else
  770. {
  771. TCustomScpExplorerForm::AddEditLink();
  772. }
  773. }
  774. //---------------------------------------------------------------------------
  775. void __fastcall TScpCommanderForm::DoOpenDirectoryDialog(TOpenDirectoryMode Mode,
  776. TOperationSide Side)
  777. {
  778. if (WinConfiguration->UseLocationProfiles)
  779. {
  780. TStrings * RemoteDirectories = CreateVisitedDirectories(osRemote);
  781. try
  782. {
  783. AnsiString Local = LocalDirView->PathName;
  784. AnsiString Remote = RemoteDirView->PathName;
  785. if (LocationProfilesDialog(Mode, Side, Local, Remote, RemoteDirectories, Terminal))
  786. {
  787. if (!Local.IsEmpty())
  788. {
  789. LocalDirView->Path = Local;
  790. }
  791. if (!Remote.IsEmpty())
  792. {
  793. RemoteDirView->Path = Remote;
  794. }
  795. }
  796. }
  797. __finally
  798. {
  799. delete RemoteDirectories;
  800. }
  801. }
  802. else
  803. {
  804. TCustomScpExplorerForm::DoOpenDirectoryDialog(Mode, Side);
  805. }
  806. }
  807. //---------------------------------------------------------------------------
  808. void __fastcall TScpCommanderForm::LocalDirViewDDTargetHasDropHandler(
  809. TObject * /*Sender*/, TListItem * Item, int & /*Effect*/, bool & DropHandler)
  810. {
  811. // when drop target is not directory, it is probably file type, which have
  812. // associated drop handler (such as ZIP file in WinXP). in this case we
  813. // cannot allow downloading when using shellex.
  814. // ! this check is duplicated in InternalDDDownload() for non-shellex downloads
  815. if ((FDDExtMapFile != NULL) &&
  816. !LocalDirView->ItemIsDirectory(Item))
  817. {
  818. DropHandler = false;
  819. }
  820. }
  821. //---------------------------------------------------------------------------
  822. void __fastcall TScpCommanderForm::LocalFileControlDDDragOver(TObject * /*Sender*/,
  823. int grfKeyState, TPoint & /*Point*/, int & dwEffect)
  824. {
  825. if (IsFileControl(DropSourceControl, osRemote))
  826. {
  827. if (((grfKeyState & (MK_CONTROL | MK_SHIFT)) == 0) ||
  828. (((grfKeyState & (MK_CONTROL | MK_SHIFT)) == MK_SHIFT) &&
  829. !WinConfiguration->DDAllowMoveInit))
  830. {
  831. dwEffect = DROPEFFECT_Copy;
  832. }
  833. }
  834. }
  835. //---------------------------------------------------------------------------
  836. void __fastcall TScpCommanderForm::DDGetTarget(AnsiString & Directory)
  837. {
  838. if (!FDDExtTarget.IsEmpty())
  839. {
  840. Directory = FDDExtTarget;
  841. FDDExtTarget = "";
  842. }
  843. else
  844. {
  845. TCustomScpExplorerForm::DDGetTarget(Directory);
  846. }
  847. }
  848. //---------------------------------------------------------------------------
  849. void __fastcall TScpCommanderForm::DDExtInitDrag(TFileList * FileList,
  850. bool & Created)
  851. {
  852. FDDExtTarget = "";
  853. TCustomScpExplorerForm::DDExtInitDrag(FileList, Created);
  854. }
  855. //---------------------------------------------------------------------------
  856. void __fastcall TScpCommanderForm::LocalFileControlDDFileOperation(
  857. TObject * /*Sender*/, int dwEffect, AnsiString SourcePath,
  858. AnsiString TargetPath, bool & DoOperation)
  859. {
  860. if (IsFileControl(DropSourceControl, osRemote))
  861. {
  862. AnsiString TargetDirectory;
  863. if (InternalDDDownload(TargetDirectory))
  864. {
  865. if (FDDExtMapFile != NULL)
  866. {
  867. FDDExtTarget = TargetDirectory;
  868. }
  869. else
  870. {
  871. assert(FInternalDDDownloadList->Count > 0);
  872. assert(dwEffect == DROPEFFECT_Copy || dwEffect == DROPEFFECT_Move);
  873. TGUICopyParamType CopyParams = GUIConfiguration->CopyParam;
  874. TTransferType TransferType = dwEffect == DROPEFFECT_Copy ? ttCopy : ttMove;
  875. if (FDDMoveSlipped)
  876. {
  877. TransferType = ttMove;
  878. }
  879. if (CopyParamDialog(tdToLocal, TransferType,
  880. false, FInternalDDDownloadList, TargetDirectory, CopyParams,
  881. WinConfiguration->DDTransferConfirmation))
  882. {
  883. int Params =
  884. (TransferType == ttMove ? cpDelete : 0) |
  885. (CopyParams.NewerOnly ? cpNewerOnly : 0);
  886. Terminal->CopyToLocal(FInternalDDDownloadList, TargetDirectory,
  887. &CopyParams, Params);
  888. FInternalDDDownloadList->Clear();
  889. }
  890. }
  891. DoOperation = false;
  892. }
  893. }
  894. }
  895. //---------------------------------------------------------------------------
  896. void __fastcall TScpCommanderForm::RemoteFileControlDDFileOperationExecuted(
  897. TObject * /*Sender*/, int dwEffect, AnsiString /*SourcePath*/,
  898. AnsiString /*TargetPath*/)
  899. {
  900. if ((dwEffect == DROPEFFECT_Move) &&
  901. IsFileControl(DropSourceControl, osLocal))
  902. {
  903. ReloadLocalDirectory();
  904. }
  905. }
  906. //---------------------------------------------------------------------------
  907. void __fastcall TScpCommanderForm::LocalDirViewEnter(TObject * /*Sender*/)
  908. {
  909. SideEnter(osLocal);
  910. }
  911. //---------------------------------------------------------------------------
  912. void __fastcall TScpCommanderForm::LocalDriveViewEnter(TObject * /*Sender*/)
  913. {
  914. MakeNextInTabOrder(LocalDirView, LocalDriveView);
  915. SideEnter(osLocal);
  916. }
  917. //---------------------------------------------------------------------------
  918. void __fastcall TScpCommanderForm::SideEnter(TOperationSide Side)
  919. {
  920. if (FCurrentSide != Side)
  921. {
  922. CommandLineCombo->Items->Clear();
  923. FCommandLineComboPopulated = false;
  924. }
  925. TCustomScpExplorerForm::SideEnter(Side);
  926. UpdateControls();
  927. LocalPathLabel->UpdateStatus();
  928. RemotePathLabel->UpdateStatus();
  929. }
  930. //---------------------------------------------------------------------------
  931. void __fastcall TScpCommanderForm::OpenConsole(AnsiString Command)
  932. {
  933. SaveCommandLine();
  934. try
  935. {
  936. TCustomScpExplorerForm::OpenConsole(Command);
  937. }
  938. __finally
  939. {
  940. FCommandLineComboPopulated = false;
  941. }
  942. }
  943. //---------------------------------------------------------------------------
  944. void __fastcall TScpCommanderForm::CommandLineComboKeyDown(TObject * /*Sender*/,
  945. WORD & Key, TShiftState /*Shift*/)
  946. {
  947. if (Key == VK_RETURN)
  948. {
  949. Key = 0;
  950. ExecuteCommandLine();
  951. }
  952. else if ((Key == VK_ESCAPE) && !CommandLineCombo->DroppedDown)
  953. {
  954. Key = 0;
  955. CommandLineCombo->Text = "";
  956. }
  957. else if ((Key == VK_UP) || (Key == VK_DOWN))
  958. {
  959. CommandLinePopulate();
  960. }
  961. }
  962. //---------------------------------------------------------------------------
  963. void __fastcall TScpCommanderForm::SaveCommandLine()
  964. {
  965. if (FCommandLineComboPopulated)
  966. {
  967. CustomWinConfiguration->History[
  968. FCurrentSide == osRemote ? "Commands" : "LocalCommands"] =
  969. CommandLineCombo->Items;
  970. }
  971. }
  972. //---------------------------------------------------------------------------
  973. void __fastcall TScpCommanderForm::ExecuteCommandLine()
  974. {
  975. if (!CommandLineCombo->Text.Trim().IsEmpty() &&
  976. ((FCurrentSide != osRemote) ||
  977. (Terminal->AllowedAnyCommand(CommandLineCombo->Text) &&
  978. EnsureAnyCommandCapability())))
  979. {
  980. CommandLinePopulate();
  981. CommandLineCombo->SaveToHistory();
  982. AnsiString Command = CommandLineCombo->Text;
  983. CommandLineCombo->Text = "";
  984. if (FCurrentSide == osRemote)
  985. {
  986. OpenConsole(Command);
  987. }
  988. else
  989. {
  990. AnsiString Program, Params, Dir;
  991. SplitCommand(Command, Program, Params, Dir);
  992. if (!ExecuteShell(Program, Params))
  993. {
  994. throw Exception(FMTLOAD(EXECUTE_APP_ERROR, (Program)));
  995. }
  996. }
  997. }
  998. }
  999. //---------------------------------------------------------------------------
  1000. void __fastcall TScpCommanderForm::CommandLineComboDropDown(
  1001. TObject * /*Sender*/)
  1002. {
  1003. CommandLinePopulate();
  1004. }
  1005. //---------------------------------------------------------------------------
  1006. void __fastcall TScpCommanderForm::CommandLinePopulate()
  1007. {
  1008. if (!FCommandLineComboPopulated)
  1009. {
  1010. TStrings * CommandsHistory;
  1011. CommandsHistory = CustomWinConfiguration->History[
  1012. FCurrentSide == osRemote ? "Commands" : "LocalCommands"];
  1013. if ((CommandsHistory != NULL) && (CommandsHistory->Count > 0))
  1014. {
  1015. CommandLineCombo->Items = CommandsHistory;
  1016. }
  1017. else
  1018. {
  1019. CommandLineCombo->Items->Clear();
  1020. }
  1021. FCommandLineComboPopulated = true;
  1022. }
  1023. }
  1024. //---------------------------------------------------------------------------
  1025. void __fastcall TScpCommanderForm::GoToCommandLine()
  1026. {
  1027. ComponentVisible[fcCommandLinePanel] = true;
  1028. if (CommandLineCombo->Enabled)
  1029. {
  1030. CommandLineCombo->SetFocus();
  1031. }
  1032. }
  1033. //---------------------------------------------------------------------------
  1034. void __fastcall TScpCommanderForm::GoToTree()
  1035. {
  1036. if (FCurrentSide == osLocal)
  1037. {
  1038. ComponentVisible[fcLocalTree] = true;
  1039. LocalDriveView->SetFocus();
  1040. }
  1041. else
  1042. {
  1043. TCustomScpExplorerForm::GoToTree();
  1044. }
  1045. }
  1046. //---------------------------------------------------------------------------
  1047. void __fastcall TScpCommanderForm::CommandLineComboEnter(TObject * /*Sender*/)
  1048. {
  1049. KeyPreview = false;
  1050. TPanel * LastPanel = FCurrentSide == osLocal ? LocalPanel : RemotePanel;
  1051. MakeNextInTabOrder(LastPanel, CommandLinePanel);
  1052. }
  1053. //---------------------------------------------------------------------------
  1054. void __fastcall TScpCommanderForm::CommandLineComboExit(TObject * /*Sender*/)
  1055. {
  1056. KeyPreview = true;
  1057. }
  1058. //---------------------------------------------------------------------------
  1059. void __fastcall TScpCommanderForm::PanelExportStore(TOperationSide Side,
  1060. TPanelExport Export, TPanelExportDestination Destination,
  1061. TStringList * ExportData)
  1062. {
  1063. if (Destination == pedCommandLine)
  1064. {
  1065. ComponentVisible[fcCommandLinePanel] = true;
  1066. AnsiString Buf;
  1067. for (int Index = 0; Index < ExportData->Count; Index++)
  1068. {
  1069. Buf += ExportData->Strings[Index] + " ";
  1070. }
  1071. if (CommandLineCombo->Focused())
  1072. {
  1073. CommandLineCombo->SelText = Buf;
  1074. }
  1075. else
  1076. {
  1077. CommandLineCombo->Text = CommandLineCombo->Text + Buf;
  1078. }
  1079. }
  1080. else
  1081. {
  1082. TCustomScpExplorerForm::PanelExportStore(Side, Export, Destination, ExportData);
  1083. }
  1084. }
  1085. //---------------------------------------------------------------------------
  1086. int __fastcall TScpCommanderForm::GetStaticComponentsHeight()
  1087. {
  1088. return TCustomScpExplorerForm::GetStaticComponentsHeight() +
  1089. (CommandLinePanel->Visible ? CommandLinePanel->Height : 0) +
  1090. (ToolbarPanel->Visible ? ToolbarPanel->Height : 0) +
  1091. (StatusBar->Visible ? StatusBar->Height : 0);
  1092. }
  1093. //---------------------------------------------------------------------------
  1094. void __fastcall TScpCommanderForm::Resize()
  1095. {
  1096. TCustomScpExplorerForm::Resize();
  1097. LocalPanelWidth = FLastLocalPanelWidth;
  1098. UpdateControls();
  1099. }
  1100. //---------------------------------------------------------------------------
  1101. void __fastcall TScpCommanderForm::StatusBarDblClick(TObject * /*Sender*/)
  1102. {
  1103. DoFileSystemInfoDialog(Terminal);
  1104. }
  1105. //---------------------------------------------------------------------------
  1106. void __fastcall TScpCommanderForm::LocalFileControlDDMenuPopup(TObject * /*Sender*/,
  1107. HMENU AMenu, IDataObject * /*DataObj*/, int /*AMinCustCmd*/, int /*grfKeyState*/,
  1108. TPoint & /*pt*/)
  1109. {
  1110. if (IsFileControl(DropSourceControl, osRemote) &&
  1111. !WinConfiguration->DDAllowMoveInit)
  1112. {
  1113. // index of copy item
  1114. int Index = GetMenuDefaultItem(AMenu, TRUE, 0);
  1115. assert(Index >= 0);
  1116. AnsiString Caption = Dragdrop_MIMoveStr;
  1117. MENUITEMINFO MI;
  1118. memset(&MI, 0, sizeof(MI));
  1119. MI.cbSize = sizeof(MI);
  1120. MI.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
  1121. MI.fType = MFT_STRING;
  1122. MI.wID = 1 /*DragDrop::CmdMove*/;
  1123. MI.dwTypeData = Caption.c_str();
  1124. MI.cch = Caption.Length();
  1125. MI.fState = MFS_ENABLED;
  1126. InsertMenuItem(AMenu, Index, TRUE, &MI);
  1127. if (FDDMoveSlipped)
  1128. {
  1129. SetMenuDefaultItem(AMenu, Index, TRUE);
  1130. }
  1131. FDDMoveSlipped = false;
  1132. }
  1133. }
  1134. //---------------------------------------------------------------------------
  1135. void __fastcall TScpCommanderForm::PathLabelDblClick(TObject * Sender)
  1136. {
  1137. OpenDirectory(Sender == LocalPathLabel ? osLocal : osRemote);
  1138. }
  1139. //---------------------------------------------------------------------------
  1140. void __fastcall TScpCommanderForm::LocalPathLabelGetStatus(
  1141. TCustomPathLabel * /*Sender*/, bool & Active)
  1142. {
  1143. // this strange form is here to make borland compiler work :-)
  1144. Active = Active || LocalDriveView->Focused();
  1145. }
  1146. //---------------------------------------------------------------------------
  1147. void __fastcall TScpCommanderForm::RemotePathLabelGetStatus(
  1148. TCustomPathLabel * /*Sender*/, bool & Active)
  1149. {
  1150. // this strange form is here to make borland compiler work :-)
  1151. Active = Active || RemoteDriveView->Focused();
  1152. }
  1153. //---------------------------------------------------------------------------