ScpCommander.cpp 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  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. EnableControl(CommandLineCombo,
  468. (FCurrentSide == osLocal) ||
  469. ((Terminal != NULL) && Terminal->IsCapable[fcAnyCommand]));
  470. }
  471. //---------------------------------------------------------------------------
  472. void __fastcall TScpCommanderForm::ChangePath(TOperationSide Side)
  473. {
  474. assert((Side == osLocal) || (Side == osRemote));
  475. TCustomPathComboBox * PathComboBox;
  476. if (Side == osLocal) PathComboBox = LocalPathComboBox;
  477. else PathComboBox = RemotePathComboBox;
  478. assert(PathComboBox);
  479. PathComboBox->SetFocus();
  480. PathComboBox->DroppedDown = True;
  481. }
  482. //---------------------------------------------------------------------------
  483. void __fastcall TScpCommanderForm::PathComboBoxCloseUp(TObject * /*Sender*/,
  484. bool /*Canceled*/)
  485. {
  486. DirView(osCurrent)->SetFocus();
  487. }
  488. //---------------------------------------------------------------------------
  489. void __fastcall TScpCommanderForm::SessionComboCloseUp(TObject *Sender)
  490. {
  491. PathComboBoxCloseUp(Sender, false);
  492. }
  493. //---------------------------------------------------------------------------
  494. TControl * __fastcall TScpCommanderForm::GetComponent(Byte Component)
  495. {
  496. switch (Component) {
  497. case fcToolBar: return ToolbarPanel;
  498. case fcStatusBar: return StatusBar;
  499. case fcLocalCoolBar: return LocalCoolBar;
  500. case fcLocalStatusBar: return LocalStatusBar;
  501. case fcRemoteCoolBar: return RemoteCoolBar;
  502. case fcRemoteStatusBar: return RemoteStatusBar;
  503. case fcSessionCombo: return SessionCombo;
  504. case fcMenuToolBar: return MenuToolBar;
  505. case fcCommandLinePanel: return CommandLinePanel;
  506. case fcLocalTree: return LocalDriveView;
  507. default: return TCustomScpExplorerForm::GetComponent(Component);
  508. }
  509. }
  510. //---------------------------------------------------------------------------
  511. void __fastcall TScpCommanderForm::FixControlsPlacement()
  512. {
  513. TCustomScpExplorerForm::FixControlsPlacement();
  514. LocalPanelSplitter->Visible = LocalDriveView->Visible;
  515. TControl * ControlsOrder[] =
  516. { CommandLinePanel, QueueSplitter, QueuePanel, ToolbarPanel, StatusBar };
  517. SetVerticalControlsOrder(ControlsOrder, LENOF(ControlsOrder));
  518. TControl * LocalControlsOrder[] =
  519. { LocalDriveView, LocalPanelSplitter, LocalDirView };
  520. SetVerticalControlsOrder(LocalControlsOrder, LENOF(LocalControlsOrder));
  521. TControl * RemoteControlsOrder[] =
  522. { RemoteDriveView, RemotePanelSplitter, RemoteDirView };
  523. SetVerticalControlsOrder(RemoteControlsOrder, LENOF(RemoteControlsOrder));
  524. if (LocalDirView->ItemFocused != NULL)
  525. {
  526. LocalDirView->ItemFocused->MakeVisible(false);
  527. }
  528. }
  529. //---------------------------------------------------------------------------
  530. bool __fastcall TScpCommanderForm::GetHasDirView(TOperationSide Side)
  531. {
  532. return TCustomScpExplorerForm::GetHasDirView(Side) || (Side == osLocal);
  533. }
  534. //---------------------------------------------------------------------------
  535. void __fastcall TScpCommanderForm::CompareDirectories()
  536. {
  537. LocalDirView->CompareFiles(RemoteDirView, false,
  538. WinConfiguration->ScpCommander.CompareCriterias());
  539. RemoteDirView->CompareFiles(LocalDirView, false,
  540. WinConfiguration->ScpCommander.CompareCriterias());
  541. if (LocalDirView->SelCount + RemoteDirView->SelCount == 0)
  542. {
  543. MessageDialog(LoadStr(COMPARE_NO_DIFFERENCES), qtInformation, qaOK, 0);
  544. }
  545. }
  546. //---------------------------------------------------------------------------
  547. void __fastcall TScpCommanderForm::SynchronizeDirectories()
  548. {
  549. AnsiString LocalDirectory = LocalDirView->PathName;
  550. AnsiString RemoteDirectory = RemoteDirView->PathName;
  551. DoSynchronizeDirectories(LocalDirectory, RemoteDirectory);
  552. }
  553. //---------------------------------------------------------------------------
  554. void __fastcall TScpCommanderForm::FullSynchronizeDirectories()
  555. {
  556. AnsiString LocalDirectory = LocalDirView->PathName;
  557. AnsiString RemoteDirectory = RemoteDirView->PathName;
  558. TSynchronizeMode Mode = (FCurrentSide == osLocal) ? smRemote : smLocal;
  559. DoFullSynchronizeDirectories(LocalDirectory, RemoteDirectory, Mode);
  560. }
  561. //---------------------------------------------------------------------------
  562. void __fastcall TScpCommanderForm::ExploreLocalDirectory()
  563. {
  564. if ((int)ShellExecute(Application->Handle, "explore",
  565. (char*)LocalDirView->Path.data(), NULL, NULL, SW_SHOWNORMAL) <= 32)
  566. {
  567. throw Exception(FORMAT(EXPLORE_LOCAL_DIR_ERROR, (LocalDirView->Path)));
  568. }
  569. }
  570. //---------------------------------------------------------------------------
  571. void __fastcall TScpCommanderForm::LocalDirViewExecFile(TObject *Sender,
  572. TListItem *Item, bool &AllowExec)
  573. {
  574. assert(Item);
  575. if ((UpperCase(PFileRec(Item->Data)->FileExt) == "LNK") &&
  576. DirectoryExists(ResolveFileShortCut(LocalDirView->ItemFullFileName(Item), true)))
  577. {
  578. AllowExec = true;
  579. }
  580. else
  581. {
  582. DoDirViewExecFile(Sender, Item, AllowExec);
  583. }
  584. }
  585. //---------------------------------------------------------------------------
  586. void __fastcall TScpCommanderForm::LocalFileControlDDDragEnter(TObject *Sender,
  587. IDataObject *DataObj, int grfKeyState, TPoint &Point, int &dwEffect,
  588. bool &Accept)
  589. {
  590. // LocalDirViewDDDragEnter is duplication of
  591. // TCustomScpExplorerForm::DirViewDDDragEnter, but it differs in
  592. // literal type of 'DataObj' parameter.Actual type is however same
  593. FileControlDDDragEnter(Sender, DataObj, grfKeyState, Point, dwEffect, Accept);
  594. }
  595. //---------------------------------------------------------------------------
  596. bool __fastcall TScpCommanderForm::PanelOperation(TOperationSide Side,
  597. bool DragDrop)
  598. {
  599. return TCustomScpExplorerForm::PanelOperation(Side, DragDrop) ||
  600. (DropSourceControl == LocalDirView);
  601. }
  602. //---------------------------------------------------------------------------
  603. void __fastcall TScpCommanderForm::FileOperationProgress(
  604. TFileOperationProgressType & ProgressData, TCancelStatus & Cancel)
  605. {
  606. // Heuristic: When operation finishes and DD targed is local dir view,
  607. // we suppose that drag&drop download finished, so local dir view should be
  608. // reloaded
  609. if (!ProgressData.InProgress && FProgressForm &&
  610. IsFileControl(FDDTargetControl, osLocal) &&
  611. ((ProgressData.Operation == ::foCopy) || (ProgressData.Operation == ::foMove)))
  612. {
  613. ReloadLocalDirectory();
  614. }
  615. TCustomScpExplorerForm::FileOperationProgress(ProgressData, Cancel);
  616. }
  617. //---------------------------------------------------------------------------
  618. void __fastcall TScpCommanderForm::DirViewLoaded(TObject *Sender)
  619. {
  620. UpdateControls();
  621. try
  622. {
  623. TCustomDirView * ADirView = dynamic_cast<TCustomDirView *>(Sender);
  624. assert(ADirView);
  625. AnsiString PrevPath = FPrevPath[ADirView == LocalDirView];
  626. AnsiString FullPrevPath =
  627. (ADirView == LocalDirView) ? IncludeTrailingBackslash(PrevPath) :
  628. UnixIncludeTrailingBackslash(PrevPath);
  629. FPrevPath[ADirView == LocalDirView] = ADirView->Path;
  630. if (!FSynchronisingBrowse && NonVisualDataModule->SynchronizeBrowsingAction->Checked &&
  631. !PrevPath.IsEmpty() && PrevPath != ADirView->Path)
  632. {
  633. FSynchronisingBrowse = true;
  634. if (ADirView == LocalDirView)
  635. {
  636. Terminal->ExceptionOnFail = true;
  637. try
  638. {
  639. if (LocalDirView->Path.SubString(1, FullPrevPath.Length()) == FullPrevPath)
  640. {
  641. RemoteDirView->Path = UnixIncludeTrailingBackslash(RemoteDirView->Path) +
  642. ToUnixPath(LocalDirView->Path.SubString(FullPrevPath.Length() + 1,
  643. LocalDirView->Path.Length() - FullPrevPath.Length()));
  644. }
  645. else if (FullPrevPath.SubString(1, LocalDirView->Path.Length()) == LocalDirView->Path)
  646. {
  647. AnsiString RemotePath = RemoteDirView->Path;
  648. while (!ComparePaths(FullPrevPath, LocalDirView->Path))
  649. {
  650. if (RemotePath == UnixExcludeTrailingBackslash(RemotePath))
  651. {
  652. Abort();
  653. }
  654. RemotePath = UnixExtractFilePath(UnixExcludeTrailingBackslash(RemotePath));
  655. FullPrevPath = ExtractFilePath(ExcludeTrailingBackslash(FullPrevPath));
  656. }
  657. RemoteDirView->Path = RemotePath;
  658. }
  659. else
  660. {
  661. Abort();
  662. }
  663. }
  664. __finally
  665. {
  666. Terminal->ExceptionOnFail = false;
  667. }
  668. }
  669. else
  670. {
  671. if (RemoteDirView->Path.SubString(1, FullPrevPath.Length()) == FullPrevPath)
  672. {
  673. LocalDirView->Path = IncludeTrailingBackslash(LocalDirView->Path) +
  674. FromUnixPath(RemoteDirView->Path.SubString(FullPrevPath.Length() + 1,
  675. RemoteDirView->Path.Length() - FullPrevPath.Length()));
  676. }
  677. else if (FullPrevPath.SubString(1, RemoteDirView->Path.Length()) == RemoteDirView->Path)
  678. {
  679. AnsiString NewLocalPath;
  680. AnsiString LocalPath = ExcludeTrailingBackslash(LocalDirView->Path);
  681. while (!UnixComparePaths(FullPrevPath, RemoteDirView->Path))
  682. {
  683. NewLocalPath = ExcludeTrailingBackslash(ExtractFileDir(LocalPath));
  684. if (NewLocalPath == LocalPath)
  685. {
  686. Abort();
  687. }
  688. LocalPath = NewLocalPath;
  689. FullPrevPath = UnixExtractFilePath(UnixExcludeTrailingBackslash(FullPrevPath));
  690. }
  691. LocalDirView->Path = LocalPath;
  692. }
  693. else
  694. {
  695. Abort();
  696. }
  697. }
  698. FSynchronisingBrowse = false;
  699. }
  700. }
  701. catch(Exception & E)
  702. {
  703. FSynchronisingBrowse = false;
  704. NonVisualDataModule->SynchronizeBrowsingAction->Checked = false;
  705. if (!Application->Terminated)
  706. {
  707. Terminal->DoShowExtendedException(&E);
  708. MessageDialog(LoadStr(SYNC_DIR_BROWSE_ERROR), qtInformation, qaOK, 0);
  709. }
  710. else
  711. {
  712. throw;
  713. }
  714. }
  715. }
  716. //---------------------------------------------------------------------------
  717. void __fastcall TScpCommanderForm::AddEditLink()
  718. {
  719. if (FCurrentSide == osLocal)
  720. {
  721. bool Edit = false;
  722. AnsiString FileName;
  723. AnsiString PointTo;
  724. bool SymbolicLink = true;
  725. if (LocalDirView->ItemFocused)
  726. {
  727. assert(LocalDirView->ItemFocused->Data);
  728. PFileRec FileRec = (PFileRec)LocalDirView->ItemFocused->Data;
  729. Edit = UpperCase(FileRec->FileExt) == "LNK";
  730. if (Edit)
  731. {
  732. AnsiString FullName = LocalDirView->ItemFullFileName(LocalDirView->ItemFocused);
  733. FileName = FullName;//FileRec->FileName;
  734. PointTo = ResolveFileShortCut(FullName, false);
  735. if (PointTo.IsEmpty())
  736. {
  737. throw Exception(FMTLOAD(RESOLVE_SHORTCUT_ERROR, (FullName)));
  738. }
  739. }
  740. else
  741. {
  742. PointTo = FileRec->FileName;
  743. }
  744. }
  745. if (DoSymlinkDialog(FileName, PointTo, osLocal, SymbolicLink, Edit, false))
  746. {
  747. assert(SymbolicLink);
  748. assert(!FileName.IsEmpty());
  749. assert(!PointTo.IsEmpty());
  750. if (ExtractFileDrive(FileName) == "" && FileName[1] != '\\')
  751. {
  752. FileName = IncludeTrailingBackslash(LocalDirView->PathName) + FileName;
  753. }
  754. if (ExtractFileDrive(PointTo) == "" && PointTo[1] != '\\')
  755. {
  756. PointTo = IncludeTrailingBackslash(LocalDirView->PathName) + PointTo;
  757. }
  758. if (ExtractFileExt(FileName) == "")
  759. {
  760. FileName = FileName + ".lnk";
  761. }
  762. if (Edit && !DeleteFile(FileName))
  763. {
  764. throw Exception(FMTLOAD(DELETE_LOCAL_FILE_ERROR, (FileName)));
  765. }
  766. if (!CreateFileShortCut(PointTo, FileName, ""))
  767. {
  768. throw Exception(CREATE_SHORTCUT_ERROR);
  769. }
  770. }
  771. }
  772. else
  773. {
  774. TCustomScpExplorerForm::AddEditLink();
  775. }
  776. }
  777. //---------------------------------------------------------------------------
  778. void __fastcall TScpCommanderForm::DoOpenDirectoryDialog(TOpenDirectoryMode Mode,
  779. TOperationSide Side)
  780. {
  781. if (WinConfiguration->UseLocationProfiles)
  782. {
  783. TStrings * RemoteDirectories = CreateVisitedDirectories(osRemote);
  784. try
  785. {
  786. AnsiString Local = LocalDirView->PathName;
  787. AnsiString Remote = RemoteDirView->PathName;
  788. if (LocationProfilesDialog(Mode, Side, Local, Remote, RemoteDirectories, Terminal))
  789. {
  790. if (!Local.IsEmpty())
  791. {
  792. LocalDirView->Path = Local;
  793. }
  794. if (!Remote.IsEmpty())
  795. {
  796. RemoteDirView->Path = Remote;
  797. }
  798. }
  799. }
  800. __finally
  801. {
  802. delete RemoteDirectories;
  803. }
  804. }
  805. else
  806. {
  807. TCustomScpExplorerForm::DoOpenDirectoryDialog(Mode, Side);
  808. }
  809. }
  810. //---------------------------------------------------------------------------
  811. void __fastcall TScpCommanderForm::LocalDirViewDDTargetHasDropHandler(
  812. TObject * /*Sender*/, TListItem * Item, int & /*Effect*/, bool & DropHandler)
  813. {
  814. // when drop target is not directory, it is probably file type, which have
  815. // associated drop handler (such as ZIP file in WinXP). in this case we
  816. // cannot allow downloading when using shellex.
  817. // ! this check is duplicated in InternalDDDownload() for non-shellex downloads
  818. if ((FDDExtMapFile != NULL) &&
  819. !LocalDirView->ItemIsDirectory(Item))
  820. {
  821. DropHandler = false;
  822. }
  823. }
  824. //---------------------------------------------------------------------------
  825. void __fastcall TScpCommanderForm::LocalFileControlDDDragOver(TObject * /*Sender*/,
  826. int grfKeyState, TPoint & /*Point*/, int & dwEffect)
  827. {
  828. if (IsFileControl(DropSourceControl, osRemote))
  829. {
  830. if (((grfKeyState & (MK_CONTROL | MK_SHIFT)) == 0) ||
  831. (((grfKeyState & (MK_CONTROL | MK_SHIFT)) == MK_SHIFT) &&
  832. !WinConfiguration->DDAllowMoveInit))
  833. {
  834. dwEffect = DROPEFFECT_Copy;
  835. }
  836. }
  837. }
  838. //---------------------------------------------------------------------------
  839. void __fastcall TScpCommanderForm::DDGetTarget(AnsiString & Directory)
  840. {
  841. if (!FDDExtTarget.IsEmpty())
  842. {
  843. Directory = FDDExtTarget;
  844. FDDExtTarget = "";
  845. }
  846. else
  847. {
  848. TCustomScpExplorerForm::DDGetTarget(Directory);
  849. }
  850. }
  851. //---------------------------------------------------------------------------
  852. void __fastcall TScpCommanderForm::DDExtInitDrag(TFileList * FileList,
  853. bool & Created)
  854. {
  855. FDDExtTarget = "";
  856. TCustomScpExplorerForm::DDExtInitDrag(FileList, Created);
  857. }
  858. //---------------------------------------------------------------------------
  859. void __fastcall TScpCommanderForm::LocalFileControlDDFileOperation(
  860. TObject * /*Sender*/, int dwEffect, AnsiString SourcePath,
  861. AnsiString TargetPath, bool & DoOperation)
  862. {
  863. if (IsFileControl(DropSourceControl, osRemote))
  864. {
  865. AnsiString TargetDirectory;
  866. if (InternalDDDownload(TargetDirectory))
  867. {
  868. if (FDDExtMapFile != NULL)
  869. {
  870. FDDExtTarget = TargetDirectory;
  871. }
  872. else
  873. {
  874. assert(FInternalDDDownloadList->Count > 0);
  875. assert(dwEffect == DROPEFFECT_Copy || dwEffect == DROPEFFECT_Move);
  876. TGUICopyParamType CopyParams = GUIConfiguration->CopyParam;
  877. TTransferType TransferType = dwEffect == DROPEFFECT_Copy ? ttCopy : ttMove;
  878. if (FDDMoveSlipped)
  879. {
  880. TransferType = ttMove;
  881. }
  882. if (CopyParamDialog(tdToLocal, TransferType,
  883. false, FInternalDDDownloadList, TargetDirectory, CopyParams,
  884. WinConfiguration->DDTransferConfirmation))
  885. {
  886. int Params =
  887. (TransferType == ttMove ? cpDelete : 0) |
  888. (CopyParams.NewerOnly ? cpNewerOnly : 0);
  889. Terminal->CopyToLocal(FInternalDDDownloadList, TargetDirectory,
  890. &CopyParams, Params);
  891. FInternalDDDownloadList->Clear();
  892. }
  893. }
  894. DoOperation = false;
  895. }
  896. }
  897. }
  898. //---------------------------------------------------------------------------
  899. void __fastcall TScpCommanderForm::RemoteFileControlDDFileOperationExecuted(
  900. TObject * /*Sender*/, int dwEffect, AnsiString /*SourcePath*/,
  901. AnsiString /*TargetPath*/)
  902. {
  903. if ((dwEffect == DROPEFFECT_Move) &&
  904. IsFileControl(DropSourceControl, osLocal))
  905. {
  906. ReloadLocalDirectory();
  907. }
  908. }
  909. //---------------------------------------------------------------------------
  910. void __fastcall TScpCommanderForm::LocalDirViewEnter(TObject * /*Sender*/)
  911. {
  912. SideEnter(osLocal);
  913. }
  914. //---------------------------------------------------------------------------
  915. void __fastcall TScpCommanderForm::LocalDriveViewEnter(TObject * /*Sender*/)
  916. {
  917. MakeNextInTabOrder(LocalDirView, LocalDriveView);
  918. SideEnter(osLocal);
  919. }
  920. //---------------------------------------------------------------------------
  921. void __fastcall TScpCommanderForm::SideEnter(TOperationSide Side)
  922. {
  923. if (FCurrentSide != Side)
  924. {
  925. CommandLineCombo->Items->Clear();
  926. FCommandLineComboPopulated = false;
  927. }
  928. TCustomScpExplorerForm::SideEnter(Side);
  929. UpdateControls();
  930. LocalPathLabel->UpdateStatus();
  931. RemotePathLabel->UpdateStatus();
  932. }
  933. //---------------------------------------------------------------------------
  934. void __fastcall TScpCommanderForm::OpenConsole(AnsiString Command)
  935. {
  936. SaveCommandLine();
  937. try
  938. {
  939. TCustomScpExplorerForm::OpenConsole(Command);
  940. }
  941. __finally
  942. {
  943. FCommandLineComboPopulated = false;
  944. }
  945. }
  946. //---------------------------------------------------------------------------
  947. void __fastcall TScpCommanderForm::CommandLineComboKeyDown(TObject * /*Sender*/,
  948. WORD & Key, TShiftState /*Shift*/)
  949. {
  950. if (Key == VK_RETURN)
  951. {
  952. Key = 0;
  953. ExecuteCommandLine();
  954. }
  955. else if ((Key == VK_ESCAPE) && !CommandLineCombo->DroppedDown)
  956. {
  957. Key = 0;
  958. CommandLineCombo->Text = "";
  959. }
  960. else if ((Key == VK_UP) || (Key == VK_DOWN))
  961. {
  962. CommandLinePopulate();
  963. }
  964. }
  965. //---------------------------------------------------------------------------
  966. void __fastcall TScpCommanderForm::SaveCommandLine()
  967. {
  968. if (FCommandLineComboPopulated)
  969. {
  970. CustomWinConfiguration->History[
  971. FCurrentSide == osRemote ? "Commands" : "LocalCommands"] =
  972. CommandLineCombo->Items;
  973. }
  974. }
  975. //---------------------------------------------------------------------------
  976. void __fastcall TScpCommanderForm::ExecuteCommandLine()
  977. {
  978. if (!CommandLineCombo->Text.Trim().IsEmpty() &&
  979. ((FCurrentSide != osRemote) ||
  980. (Terminal->AllowedAnyCommand(CommandLineCombo->Text))))
  981. {
  982. CommandLinePopulate();
  983. CommandLineCombo->SaveToHistory();
  984. AnsiString Command = CommandLineCombo->Text;
  985. CommandLineCombo->Text = "";
  986. if (FCurrentSide == osRemote)
  987. {
  988. OpenConsole(Command);
  989. }
  990. else
  991. {
  992. AnsiString Program, Params, Dir;
  993. SplitCommand(Command, Program, Params, Dir);
  994. if (!ExecuteShell(Program, Params))
  995. {
  996. throw Exception(FMTLOAD(EXECUTE_APP_ERROR, (Program)));
  997. }
  998. }
  999. }
  1000. }
  1001. //---------------------------------------------------------------------------
  1002. void __fastcall TScpCommanderForm::CommandLineComboDropDown(
  1003. TObject * /*Sender*/)
  1004. {
  1005. CommandLinePopulate();
  1006. }
  1007. //---------------------------------------------------------------------------
  1008. void __fastcall TScpCommanderForm::CommandLinePopulate()
  1009. {
  1010. if (!FCommandLineComboPopulated)
  1011. {
  1012. TStrings * CommandsHistory;
  1013. CommandsHistory = CustomWinConfiguration->History[
  1014. FCurrentSide == osRemote ? "Commands" : "LocalCommands"];
  1015. if ((CommandsHistory != NULL) && (CommandsHistory->Count > 0))
  1016. {
  1017. CommandLineCombo->Items = CommandsHistory;
  1018. }
  1019. else
  1020. {
  1021. CommandLineCombo->Items->Clear();
  1022. }
  1023. FCommandLineComboPopulated = true;
  1024. }
  1025. }
  1026. //---------------------------------------------------------------------------
  1027. void __fastcall TScpCommanderForm::GoToCommandLine()
  1028. {
  1029. ComponentVisible[fcCommandLinePanel] = true;
  1030. if (CommandLineCombo->Enabled)
  1031. {
  1032. CommandLineCombo->SetFocus();
  1033. }
  1034. }
  1035. //---------------------------------------------------------------------------
  1036. void __fastcall TScpCommanderForm::GoToTree()
  1037. {
  1038. if (FCurrentSide == osLocal)
  1039. {
  1040. ComponentVisible[fcLocalTree] = true;
  1041. LocalDriveView->SetFocus();
  1042. }
  1043. else
  1044. {
  1045. TCustomScpExplorerForm::GoToTree();
  1046. }
  1047. }
  1048. //---------------------------------------------------------------------------
  1049. void __fastcall TScpCommanderForm::CommandLineComboEnter(TObject * /*Sender*/)
  1050. {
  1051. KeyPreview = false;
  1052. TPanel * LastPanel = FCurrentSide == osLocal ? LocalPanel : RemotePanel;
  1053. MakeNextInTabOrder(LastPanel, CommandLinePanel);
  1054. }
  1055. //---------------------------------------------------------------------------
  1056. void __fastcall TScpCommanderForm::CommandLineComboExit(TObject * /*Sender*/)
  1057. {
  1058. KeyPreview = true;
  1059. }
  1060. //---------------------------------------------------------------------------
  1061. void __fastcall TScpCommanderForm::PanelExportStore(TOperationSide Side,
  1062. TPanelExport Export, TPanelExportDestination Destination,
  1063. TStringList * ExportData)
  1064. {
  1065. if (Destination == pedCommandLine)
  1066. {
  1067. ComponentVisible[fcCommandLinePanel] = true;
  1068. AnsiString Buf;
  1069. for (int Index = 0; Index < ExportData->Count; Index++)
  1070. {
  1071. Buf += ExportData->Strings[Index] + " ";
  1072. }
  1073. if (CommandLineCombo->Focused())
  1074. {
  1075. CommandLineCombo->SelText = Buf;
  1076. }
  1077. else
  1078. {
  1079. CommandLineCombo->Text = CommandLineCombo->Text + Buf;
  1080. }
  1081. }
  1082. else
  1083. {
  1084. TCustomScpExplorerForm::PanelExportStore(Side, Export, Destination, ExportData);
  1085. }
  1086. }
  1087. //---------------------------------------------------------------------------
  1088. int __fastcall TScpCommanderForm::GetStaticComponentsHeight()
  1089. {
  1090. return TCustomScpExplorerForm::GetStaticComponentsHeight() +
  1091. (CommandLinePanel->Visible ? CommandLinePanel->Height : 0) +
  1092. (ToolbarPanel->Visible ? ToolbarPanel->Height : 0) +
  1093. (StatusBar->Visible ? StatusBar->Height : 0);
  1094. }
  1095. //---------------------------------------------------------------------------
  1096. void __fastcall TScpCommanderForm::Resize()
  1097. {
  1098. TCustomScpExplorerForm::Resize();
  1099. LocalPanelWidth = FLastLocalPanelWidth;
  1100. UpdateControls();
  1101. }
  1102. //---------------------------------------------------------------------------
  1103. void __fastcall TScpCommanderForm::StatusBarDblClick(TObject * /*Sender*/)
  1104. {
  1105. DoFileSystemInfoDialog(Terminal);
  1106. }
  1107. //---------------------------------------------------------------------------
  1108. void __fastcall TScpCommanderForm::LocalFileControlDDMenuPopup(TObject * /*Sender*/,
  1109. HMENU AMenu, IDataObject * /*DataObj*/, int /*AMinCustCmd*/, int /*grfKeyState*/,
  1110. TPoint & /*pt*/)
  1111. {
  1112. if (IsFileControl(DropSourceControl, osRemote) &&
  1113. !WinConfiguration->DDAllowMoveInit)
  1114. {
  1115. // index of copy item
  1116. int Index = GetMenuDefaultItem(AMenu, TRUE, 0);
  1117. assert(Index >= 0);
  1118. AnsiString Caption = Dragdrop_MIMoveStr;
  1119. MENUITEMINFO MI;
  1120. memset(&MI, 0, sizeof(MI));
  1121. MI.cbSize = sizeof(MI);
  1122. MI.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
  1123. MI.fType = MFT_STRING;
  1124. MI.wID = 1 /*DragDrop::CmdMove*/;
  1125. MI.dwTypeData = Caption.c_str();
  1126. MI.cch = Caption.Length();
  1127. MI.fState = MFS_ENABLED;
  1128. InsertMenuItem(AMenu, Index, TRUE, &MI);
  1129. if (FDDMoveSlipped)
  1130. {
  1131. SetMenuDefaultItem(AMenu, Index, TRUE);
  1132. }
  1133. FDDMoveSlipped = false;
  1134. }
  1135. }
  1136. //---------------------------------------------------------------------------
  1137. void __fastcall TScpCommanderForm::PathLabelDblClick(TObject * Sender)
  1138. {
  1139. OpenDirectory(Sender == LocalPathLabel ? osLocal : osRemote);
  1140. }
  1141. //---------------------------------------------------------------------------
  1142. void __fastcall TScpCommanderForm::LocalPathLabelGetStatus(
  1143. TCustomPathLabel * /*Sender*/, bool & Active)
  1144. {
  1145. // this strange form is here to make borland compiler work :-)
  1146. Active = Active || LocalDriveView->Focused();
  1147. }
  1148. //---------------------------------------------------------------------------
  1149. void __fastcall TScpCommanderForm::RemotePathLabelGetStatus(
  1150. TCustomPathLabel * /*Sender*/, bool & Active)
  1151. {
  1152. // this strange form is here to make borland compiler work :-)
  1153. Active = Active || RemoteDriveView->Focused();
  1154. }
  1155. //---------------------------------------------------------------------------