ScpCommander.cpp 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170
  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 resource "*.dfm"
  35. //---------------------------------------------------------------------------
  36. __fastcall TScpCommanderForm::TScpCommanderForm(TComponent* Owner)
  37. : TCustomScpExplorerForm(Owner)
  38. {
  39. FLastDirView = LocalDirView;
  40. FLastLocalPanelWidth = LocalPanelWidth;
  41. FSynchronization = ssStopped;
  42. FSynchronizeDialog = NULL;
  43. FSynchronisingBrowse = false;
  44. FFirstTerminal = true;
  45. FInternalDDDownloadList = new TStringList();
  46. LocalBackButton->DropdownMenu = LocalDirView->BackMenu;
  47. LocalForwardButton->DropdownMenu = LocalDirView->ForwardMenu;
  48. RemoteBackButton->DropdownMenu = RemoteDirView->BackMenu;
  49. RemoteForwardButton->DropdownMenu = RemoteDirView->ForwardMenu;
  50. SavedSessionsButton->OnClick = DropDownButtonMenu;
  51. TopCoolBar->PopupMenu = NonVisualDataModule->CommanderBarPopup;
  52. ToolbarPanel->PopupMenu = TopCoolBar->PopupMenu;
  53. StatusBar->PopupMenu = TopCoolBar->PopupMenu;
  54. QueueCoolBar->PopupMenu = TopCoolBar->PopupMenu;
  55. LocalCoolBar->PopupMenu = NonVisualDataModule->LocalPanelPopup;
  56. LocalPathLabel->PopupMenu = LocalCoolBar->PopupMenu;
  57. LocalStatusBar->PopupMenu = LocalCoolBar->PopupMenu;
  58. RemoteCoolBar->PopupMenu = NonVisualDataModule->RemotePanelPopup;
  59. RemotePathLabel->PopupMenu = RemoteCoolBar->PopupMenu;
  60. RemoteStatusBar->PopupMenu = RemoteCoolBar->PopupMenu;
  61. // set common norton shorcuts to our actions
  62. NonVisualDataModule->CommanderShortcuts();
  63. Splitter->ShowHint = True;
  64. ((TLabel*)Splitter)->OnDblClick = SplitterDblClick;
  65. RemotePathComboBox->TabStop = False;
  66. CommandLineLabel->FocusControl = CommandLineCombo;
  67. CommandLineCombo->Text = "";
  68. FCommandLineComboPopulated = false;
  69. LocalDirView->Font = Screen->IconFont;
  70. }
  71. //---------------------------------------------------------------------------
  72. __fastcall TScpCommanderForm::~TScpCommanderForm()
  73. {
  74. delete FInternalDDDownloadList;
  75. }
  76. //---------------------------------------------------------------------------
  77. void __fastcall TScpCommanderForm::RestoreFormParams()
  78. {
  79. assert(WinConfiguration);
  80. TCustomScpExplorerForm::RestoreFormParams();
  81. WinConfiguration->RestoreForm(WinConfiguration->ScpCommander.WindowParams, this);
  82. }
  83. //---------------------------------------------------------------------------
  84. void __fastcall TScpCommanderForm::RestoreParams()
  85. {
  86. assert(Configuration);
  87. // called later once again after menu font is updated (see FormShow)
  88. SetCoolBandsMinWidth(TopCoolBar);
  89. SetCoolBandsMinWidth(LocalCoolBar);
  90. SetCoolBandsMinWidth(RemoteCoolBar);
  91. // IDE often looses this link
  92. LocalDirView->HeaderImages = NonVisualDataModule->ArrowImages;
  93. TCustomScpExplorerForm::RestoreParams();
  94. LocalPanelWidth = WinConfiguration->ScpCommander.LocalPanelWidth;
  95. LoadCoolbarLayoutStr(TopCoolBar, WinConfiguration->ScpCommander.CoolBarLayout);
  96. StatusBar->Visible = WinConfiguration->ScpCommander.StatusBar;
  97. ToolbarPanel->Visible = WinConfiguration->ScpCommander.ToolBar;
  98. CommandLinePanel->Visible = WinConfiguration->ScpCommander.CommandLine;
  99. FDirViewToSelect = (WinConfiguration->ScpCommander.CurrentPanel == osLocal ?
  100. (TCustomDirView *)LocalDirView : (TCustomDirView *)RemoteDirView);
  101. #define RESTORE_PANEL_PARAMS(PANEL) \
  102. PANEL ## DirView->ColProperties->ParamsStr = WinConfiguration->ScpCommander.PANEL ## Panel.DirViewParams; \
  103. PANEL ## StatusBar->Visible = WinConfiguration->ScpCommander.PANEL ## Panel.StatusBar; \
  104. LoadCoolbarLayoutStr(PANEL ## CoolBar, WinConfiguration->ScpCommander.PANEL ## Panel.CoolBarLayout)
  105. RESTORE_PANEL_PARAMS(Local);
  106. RESTORE_PANEL_PARAMS(Remote);
  107. #undef RESTORE_PANEL_PARAMS
  108. NonVisualDataModule->SynchronizeBrowsingAction->Checked = WinConfiguration->ScpCommander.SynchronizeBrowsing;
  109. }
  110. //---------------------------------------------------------------------------
  111. void __fastcall TScpCommanderForm::StoreParams()
  112. {
  113. assert(WinConfiguration);
  114. WinConfiguration->BeginUpdate();
  115. try
  116. {
  117. WinConfiguration->ScpCommander.CoolBarLayout = GetCoolbarLayoutStr(TopCoolBar);
  118. WinConfiguration->ScpCommander.LocalPanelWidth = LocalPanelWidth;
  119. WinConfiguration->ScpCommander.StatusBar = StatusBar->Visible;
  120. WinConfiguration->ScpCommander.ToolBar = ToolbarPanel->Visible;
  121. WinConfiguration->ScpCommander.CommandLine = CommandLinePanel->Visible;
  122. SaveCommandLine();
  123. WinConfiguration->ScpCommander.CurrentPanel =
  124. ((FLastDirView == LocalDirView) ? osLocal : osRemote);
  125. #define STORE_PANEL_PARAMS(PANEL) \
  126. WinConfiguration->ScpCommander.PANEL ## Panel.DirViewParams = PANEL ## DirView->ColProperties->ParamsStr; \
  127. WinConfiguration->ScpCommander.PANEL ## Panel.StatusBar = PANEL ## StatusBar->Visible; \
  128. WinConfiguration->ScpCommander.PANEL ## Panel.CoolBarLayout = GetCoolbarLayoutStr(PANEL ## CoolBar)
  129. STORE_PANEL_PARAMS(Local);
  130. STORE_PANEL_PARAMS(Remote);
  131. #undef RESTORE_PANEL_PARAMS
  132. WinConfiguration->ScpCommander.WindowParams = WinConfiguration->StoreForm(this);;
  133. WinConfiguration->ScpCommander.SynchronizeBrowsing = NonVisualDataModule->SynchronizeBrowsingAction->Checked;
  134. TCustomScpExplorerForm::StoreParams();
  135. }
  136. __finally
  137. {
  138. WinConfiguration->EndUpdate();
  139. }
  140. }
  141. //---------------------------------------------------------------------------
  142. void __fastcall TScpCommanderForm::UpdateSessionData(TSessionData * Data)
  143. {
  144. assert(Terminal && Terminal->SessionData);
  145. if (!Data)
  146. {
  147. Data = Terminal->SessionData;
  148. }
  149. TCustomScpExplorerForm::UpdateSessionData(Data);
  150. assert(LocalDirView);
  151. Data->LocalDirectory = LocalDirView->PathName;
  152. }
  153. //---------------------------------------------------------------------------
  154. bool __fastcall TScpCommanderForm::InternalDDDownload(AnsiString & TargetDirectory)
  155. {
  156. bool Result = false;
  157. if (LocalDirView->DropTarget)
  158. {
  159. // when drop target is not directory, it is probably file type, which have
  160. // associated drop handler (such as ZIP file in WinXP). in this case we
  161. // must leave drop handling to destination application.
  162. // ! this check is duplicated in LocalDirViewDDTargetHasDropHandler()
  163. // for shellex downloads
  164. if (LocalDirView->ItemIsDirectory(LocalDirView->DropTarget))
  165. {
  166. TargetDirectory = LocalDirView->ItemFullFileName(LocalDirView->DropTarget);
  167. Result = true;
  168. }
  169. }
  170. else
  171. {
  172. TargetDirectory = IncludeTrailingBackslash(LocalDirView->Path);
  173. Result = true;
  174. }
  175. return Result;
  176. }
  177. //---------------------------------------------------------------------------
  178. bool __fastcall TScpCommanderForm::CopyParamDialog(TTransferDirection Direction,
  179. TTransferType Type, bool DragDrop, TStrings * FileList, AnsiString & TargetDirectory,
  180. TGUICopyParamType & CopyParam, bool Confirm)
  181. {
  182. bool Result = false;
  183. if (DragDrop && (Direction == tdToLocal) && (FDDTargetDirView == LocalDirView))
  184. {
  185. Result = InternalDDDownload(TargetDirectory);
  186. if (Result)
  187. {
  188. assert(FileList->Count > 0);
  189. FInternalDDDownloadList->Assign(FileList);
  190. }
  191. }
  192. else if (!DragDrop && TargetDirectory.IsEmpty())
  193. {
  194. if (Direction == tdToLocal)
  195. {
  196. TargetDirectory = IncludeTrailingBackslash(LocalDirView->Path);
  197. }
  198. else
  199. {
  200. TargetDirectory = UnixIncludeTrailingBackslash(RemoteDirView->Path);
  201. }
  202. }
  203. if (!Result)
  204. {
  205. Result = TCustomScpExplorerForm::CopyParamDialog(Direction, Type, DragDrop,
  206. FileList, TargetDirectory, CopyParam, Confirm);
  207. }
  208. return Result;
  209. }
  210. //---------------------------------------------------------------------------
  211. void __fastcall TScpCommanderForm::DoShow()
  212. {
  213. TCustomScpExplorerForm::DoShow();
  214. assert(FDirViewToSelect);
  215. FDirViewToSelect->SetFocus();
  216. // called for second time after menu font was updated (see also RestoreParams)
  217. SetCoolBandsMinWidth(TopCoolBar);
  218. SetCoolBandsMinWidth(LocalCoolBar);
  219. SetCoolBandsMinWidth(RemoteCoolBar);
  220. UpdateControls();
  221. }
  222. //---------------------------------------------------------------------------
  223. Boolean __fastcall TScpCommanderForm::AllowedAction(TAction * Action, TActionAllowed Allowed)
  224. {
  225. #define FLAG ((TActionFlag)(Action->Tag))
  226. return
  227. // always require Commander flag
  228. (FLAG & afCommander) &&
  229. // if action is execution or update, we don't require any other flag
  230. // if we check for shortcut, we require proper dirview to be selected
  231. ((Allowed != aaShortCut) ||
  232. ((FLAG & afLocal) && (FLastDirView == LocalDirView)) ||
  233. ((FLAG & afRemote) && (FLastDirView == RemoteDirView))
  234. );
  235. #undef FLAG
  236. }
  237. //---------------------------------------------------------------------------
  238. TCustomDirView * __fastcall TScpCommanderForm::DirView(TOperationSide Side)
  239. {
  240. switch (Side) {
  241. case osCurrent: return FLastDirView;
  242. case osLocal: return LocalDirView;
  243. case osRemote: return RemoteDirView;
  244. default: assert(false); return NULL;
  245. }
  246. }
  247. //---------------------------------------------------------------------------
  248. TOperationSide __fastcall TScpCommanderForm::GetSide(TOperationSide Side)
  249. {
  250. if (Side == osCurrent)
  251. {
  252. if (FLastDirView == RemoteDirView)
  253. {
  254. Side = osRemote;
  255. }
  256. else
  257. {
  258. assert(FLastDirView);
  259. Side = osLocal;
  260. }
  261. }
  262. return TCustomScpExplorerForm::GetSide(Side);
  263. }
  264. //---------------------------------------------------------------------------
  265. void __fastcall TScpCommanderForm::TerminalChanged()
  266. {
  267. if (Terminal)
  268. {
  269. bool WasSynchronisingBrowsing = NonVisualDataModule->SynchronizeBrowsingAction->Checked;
  270. NonVisualDataModule->SynchronizeBrowsingAction->Checked = false;
  271. TCustomScpExplorerForm::TerminalChanged();
  272. if (FFirstTerminal || !WinConfiguration->ScpCommander.PreserveLocalDirectory)
  273. {
  274. AnsiString LocalDirectory = Terminal->SessionData->LocalDirectory;
  275. bool DocumentsDir = LocalDirectory.IsEmpty();
  276. if (!DocumentsDir)
  277. {
  278. try
  279. {
  280. LocalDirView->Path = LocalDirectory;
  281. }
  282. catch(Exception & E)
  283. {
  284. DocumentsDir = true;
  285. Terminal->DoShowExtendedException(&E);
  286. }
  287. }
  288. if (DocumentsDir)
  289. {
  290. try
  291. {
  292. LocalDirView->HomeDirectory = "";
  293. LocalDirView->ExecuteHomeDirectory();
  294. }
  295. catch(Exception & E)
  296. {
  297. Terminal->DoShowExtendedException(&E);
  298. LocalDirView->Path = ExtractFilePath(Application->ExeName);
  299. }
  300. }
  301. if (WinConfiguration->DefaultDirIsHome &&
  302. !Terminal->SessionData->UpdateDirectories)
  303. {
  304. LocalDirView->HomeDirectory = LocalDirectory;
  305. }
  306. }
  307. FFirstTerminal = false;
  308. if (WasSynchronisingBrowsing &&
  309. SameText(ExtractFileName(LocalDirView->PathName),
  310. UnixExtractFileName(RemoteDirView->PathName)))
  311. {
  312. NonVisualDataModule->SynchronizeBrowsingAction->Checked = true;
  313. }
  314. }
  315. else
  316. {
  317. TCustomScpExplorerForm::TerminalChanged();
  318. }
  319. }
  320. //---------------------------------------------------------------------------
  321. void __fastcall TScpCommanderForm::ConfigurationChanged()
  322. {
  323. TCustomScpExplorerForm::ConfigurationChanged();
  324. if (WinConfiguration->DefaultDirIsHome && Terminal)
  325. {
  326. LocalDirView->HomeDirectory = Terminal->SessionData->LocalDirectory;
  327. }
  328. else
  329. {
  330. LocalDirView->HomeDirectory = "";
  331. }
  332. LocalDirView->DimmHiddenFiles = WinConfiguration->DimmHiddenFiles;
  333. LocalDirView->ShowHiddenFiles = WinConfiguration->ShowHiddenFiles;
  334. LocalDirView->NortonLike = !WinConfiguration->ScpCommander.ExplorerStyleSelection;
  335. RemoteDirView->NortonLike = !WinConfiguration->ScpCommander.ExplorerStyleSelection;
  336. LocalDirView->DragDropFilesEx->ShellExtensions->DropHandler =
  337. !WinConfiguration->DDExtEnabled;
  338. }
  339. //---------------------------------------------------------------------------
  340. void __fastcall TScpCommanderForm::SetLocalPanelWidth(float value)
  341. {
  342. float Total = LocalPanel->Width + RemotePanel->Width;
  343. FLocalPanelWidth = value;
  344. if (value * Total != LocalPanel->Width)
  345. {
  346. LocalPanel->Width = value * Total;
  347. UpdateControls();
  348. }
  349. }
  350. //---------------------------------------------------------------------------
  351. float __fastcall TScpCommanderForm::GetLocalPanelWidth()
  352. {
  353. return FLocalPanelWidth;
  354. }
  355. //---------------------------------------------------------------------------
  356. void __fastcall TScpCommanderForm::SplitterMoved(TObject * /*Sender*/)
  357. {
  358. float Local = LocalPanel->Width;
  359. float Total = LocalPanel->Width + RemotePanel->Width;
  360. FLocalPanelWidth = Local / Total;
  361. FLastLocalPanelWidth = LocalPanelWidth;
  362. UpdateControls();
  363. }
  364. //---------------------------------------------------------------------------
  365. void __fastcall TScpCommanderForm::SplitterCanResize(TObject * /*Sender*/,
  366. int &NewSize, bool & /*Accept*/)
  367. {
  368. // When splitter is drag so far to right, that width contraint of remote panel would
  369. // be violated, it doesn't stop, but extend form width.
  370. // Following prevents this behaviour.
  371. if (ClientWidth - NewSize - Splitter->Width < RemotePanel->Constraints->MinWidth)
  372. NewSize = (ClientWidth - RemotePanel->Constraints->MinWidth - Splitter->Width);
  373. }
  374. //---------------------------------------------------------------------------
  375. void __fastcall TScpCommanderForm::SplitterDblClick(TObject * /*Sender*/)
  376. {
  377. LocalPanelWidth = 0.5;
  378. }
  379. //---------------------------------------------------------------------------
  380. void __fastcall TScpCommanderForm::UpdateControls()
  381. {
  382. Splitter->Hint = FormatFloat("0%|X", LocalPanelWidth*100);
  383. if (FLastDirView != NULL)
  384. {
  385. CommandLineLabel->UnixPath = (FLastDirView == RemoteDirView);
  386. CommandLineLabel->Caption = FLastDirView->PathName;
  387. CommandLinePromptLabel->Caption =
  388. (FLastDirView == RemoteDirView) ? "$" : ">";
  389. EnableControl(CommandLineCombo,
  390. (FLastDirView == LocalDirView) || Terminal->IsCapable[fcAnyCommand]);
  391. }
  392. }
  393. //---------------------------------------------------------------------------
  394. void __fastcall TScpCommanderForm::ChangePath(TOperationSide Side)
  395. {
  396. assert((Side == osLocal) || (Side == osRemote));
  397. TCustomPathComboBox * PathComboBox;
  398. if (Side == osLocal) PathComboBox = LocalPathComboBox;
  399. else PathComboBox = RemotePathComboBox;
  400. assert(PathComboBox);
  401. PathComboBox->SetFocus();
  402. PathComboBox->DroppedDown = True;
  403. }
  404. //---------------------------------------------------------------------------
  405. void __fastcall TScpCommanderForm::PathComboBoxCloseUp(TObject * /*Sender*/,
  406. bool /*Canceled*/)
  407. {
  408. assert(FLastDirView);
  409. FLastDirView->SetFocus();
  410. }
  411. //---------------------------------------------------------------------------
  412. void __fastcall TScpCommanderForm::SessionComboCloseUp(TObject *Sender)
  413. {
  414. PathComboBoxCloseUp(Sender, false);
  415. }
  416. //---------------------------------------------------------------------------
  417. TControl * __fastcall TScpCommanderForm::GetComponent(Byte Component)
  418. {
  419. switch (Component) {
  420. case fcToolBar: return ToolbarPanel;
  421. case fcStatusBar: return StatusBar;
  422. case fcLocalCoolBar: return LocalCoolBar;
  423. case fcLocalStatusBar: return LocalStatusBar;
  424. case fcRemoteCoolBar: return RemoteCoolBar;
  425. case fcRemoteStatusBar: return RemoteStatusBar;
  426. case fcSessionCombo: return SessionCombo;
  427. case fcMenuToolBar: return MenuToolBar;
  428. case fcCommandLinePanel: return CommandLinePanel;
  429. default: return TCustomScpExplorerForm::GetComponent(Component);
  430. }
  431. }
  432. //---------------------------------------------------------------------------
  433. void __fastcall TScpCommanderForm::FixControlsPlacement()
  434. {
  435. TCustomScpExplorerForm::FixControlsPlacement();
  436. TControl * ControlsOrder[] =
  437. { CommandLinePanel, QueueSplitter, QueuePanel, ToolbarPanel, StatusBar };
  438. SetControlsOrder(ControlsOrder, LENOF(ControlsOrder));
  439. if (LocalDirView->ItemFocused != NULL)
  440. {
  441. LocalDirView->ItemFocused->MakeVisible(false);
  442. }
  443. }
  444. //---------------------------------------------------------------------------
  445. bool __fastcall TScpCommanderForm::GetHasDirView(TOperationSide Side)
  446. {
  447. return TCustomScpExplorerForm::GetHasDirView(Side) || (Side == osLocal);
  448. }
  449. //---------------------------------------------------------------------------
  450. void __fastcall TScpCommanderForm::CompareDirectories()
  451. {
  452. LocalDirView->CompareFiles(RemoteDirView, false,
  453. WinConfiguration->ScpCommander.CompareCriterias());
  454. RemoteDirView->CompareFiles(LocalDirView, false,
  455. WinConfiguration->ScpCommander.CompareCriterias());
  456. if (LocalDirView->SelCount + RemoteDirView->SelCount == 0)
  457. {
  458. MessageDialog(LoadStr(COMPARE_NO_DIFFERENCES), qtInformation, qaOK, 0);
  459. }
  460. }
  461. //---------------------------------------------------------------------------
  462. void __fastcall TScpCommanderForm::SynchronizeDirectories()
  463. {
  464. TSynchronizeParamType Params;
  465. Params.CopyParams = GUIConfiguration->CopyParam;
  466. Params.AllowTransferMode = Terminal->IsCapable[fcTextMode];
  467. if (!Params.AllowTransferMode)
  468. {
  469. Params.CopyParams.TransferMode = tmBinary;
  470. }
  471. Params.LocalDirectory = LocalDirView->PathName;
  472. Params.RemoteDirectory = RemoteDirView->PathName;
  473. DoSynchronizeDialog(Params, SynchronizeStartStop);
  474. }
  475. //---------------------------------------------------------------------------
  476. void __fastcall TScpCommanderForm::SynchronizeStartStop(System::TObject* Sender,
  477. bool Start, TSynchronizeParamType Params)
  478. {
  479. FSynchronization = (Start ? ssWaiting : ssStopped);
  480. if (Start)
  481. {
  482. FSynchronizeDialog = (TSynchronizeDialog *)Sender;
  483. FSynchronizeParams = Params;
  484. SynchronizeNow();
  485. }
  486. else
  487. {
  488. FSynchronizeDialog = NULL;
  489. }
  490. }
  491. //---------------------------------------------------------------------------
  492. void __fastcall TScpCommanderForm::FullSynchronizeDirectories()
  493. {
  494. AnsiString LocalDirectory = LocalDirView->PathName;
  495. AnsiString RemoteDirectory = RemoteDirView->PathName;
  496. TSynchronizeMode Mode = (FLastDirView == LocalDirView) ? smRemote : smLocal;
  497. DoFullSynchronizeDirectories(LocalDirectory, RemoteDirectory, Mode);
  498. }
  499. //---------------------------------------------------------------------------
  500. void __fastcall TScpCommanderForm::LocalDirViewChangeDetected(
  501. TObject * /*Sender*/)
  502. {
  503. switch (FSynchronization) {
  504. case ssWaiting: SynchronizeNow(); break;
  505. case ssSynchronizing: FSynchronization = ssSynchronize; break;
  506. }
  507. }
  508. //---------------------------------------------------------------------------
  509. void __fastcall TScpCommanderForm::SynchronizeNow()
  510. {
  511. try
  512. {
  513. TStrings * ChangedFiles;
  514. FSynchronization = ssSynchronize;
  515. try
  516. {
  517. // repeat until there is any change pending (see ::LocalDirViewChangeDetected)
  518. while (FSynchronization == ssSynchronize)
  519. {
  520. FSynchronization = ssSynchronizing;
  521. assert(FSynchronizeDialog);
  522. ChangedFiles = LocalDirView->CreateChangedFileList(
  523. RemoteDirView, true, FSynchronizeDialog->ExistingOnly,
  524. WinConfiguration->ScpCommander.CompareCriterias());
  525. Terminal->ExceptionOnFail = true;
  526. try
  527. {
  528. if (ChangedFiles->Count > 0)
  529. {
  530. Terminal->CopyToRemote(ChangedFiles, FSynchronizeParams.RemoteDirectory,
  531. &FSynchronizeParams.CopyParams, 0);
  532. }
  533. }
  534. __finally
  535. {
  536. delete ChangedFiles;
  537. Terminal->ExceptionOnFail = false;
  538. }
  539. }
  540. }
  541. __finally
  542. {
  543. FSynchronization = ssWaiting;
  544. }
  545. }
  546. catch (EFatal & E)
  547. {
  548. throw;
  549. }
  550. catch(Exception & E)
  551. {
  552. assert(FSynchronizeDialog);
  553. FSynchronizeDialog->Stop();
  554. Terminal->DoShowExtendedException(&E);
  555. }
  556. }
  557. //---------------------------------------------------------------------------
  558. void __fastcall TScpCommanderForm::DoOperationFinished(
  559. ::TFileOperation Operation, TOperationSide Side,
  560. bool DragDrop, const AnsiString FileName, bool Success,
  561. bool & DisconnectWhenFinished)
  562. {
  563. if (FSynchronization == ssStopped)
  564. {
  565. TCustomScpExplorerForm::DoOperationFinished(Operation, Side, DragDrop,
  566. FileName, Success, DisconnectWhenFinished);
  567. }
  568. }
  569. //---------------------------------------------------------------------------
  570. void __fastcall TScpCommanderForm::ExploreLocalDirectory()
  571. {
  572. if ((int)ShellExecute(Application->Handle, "explore",
  573. (char*)LocalDirView->Path.data(), NULL, NULL, SW_SHOWNORMAL) <= 32)
  574. {
  575. throw Exception(FORMAT(EXPLORE_LOCAL_DIR_ERROR, (LocalDirView->Path)));
  576. }
  577. }
  578. //---------------------------------------------------------------------------
  579. void __fastcall TScpCommanderForm::LocalDirViewExecFile(TObject *Sender,
  580. TListItem *Item, bool &AllowExec)
  581. {
  582. assert(Item);
  583. if ((UpperCase(PFileRec(Item->Data)->FileExt) == "LNK") &&
  584. DirectoryExists(ResolveFileShortCut(LocalDirView->ItemFullFileName(Item), true)))
  585. {
  586. AllowExec = true;
  587. }
  588. else
  589. {
  590. DoDirViewExecFile(Sender, Item, AllowExec);
  591. }
  592. }
  593. //---------------------------------------------------------------------------
  594. void __fastcall TScpCommanderForm::LocalDirViewDDDragEnter(TObject *Sender,
  595. IDataObject *DataObj, int grfKeyState, TPoint &Point, int &dwEffect,
  596. bool &Accept)
  597. {
  598. // LocalDirViewDDDragEnter is duplication of
  599. // TCustomScpExplorerForm::DirViewDDDragEnter, but it differs in
  600. // literal type of 'DataObj' parameter.Actual type is however same
  601. DirViewDDDragEnter(Sender, DataObj, grfKeyState, Point, dwEffect, Accept);
  602. }
  603. //---------------------------------------------------------------------------
  604. void __fastcall TScpCommanderForm::FileOperationProgress(
  605. TFileOperationProgressType & ProgressData, TCancelStatus & Cancel)
  606. {
  607. // Heuristic: When operation finishes and DD targed is local dir view,
  608. // we suppose that drag&drop download finished, so local dir view should be
  609. // reloaded
  610. if (!ProgressData.InProgress && FProgressForm &&
  611. (FDDTargetDirView == LocalDirView))
  612. {
  613. LocalDirView->ReloadDirectory();
  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 (FLastDirView == LocalDirView)
  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::LocalDirViewDDDragOver(TObject * /*Sender*/,
  826. int grfKeyState, TPoint & /*Point*/, int & dwEffect)
  827. {
  828. if (DropSourceControl == RemoteDirView)
  829. {
  830. if (((grfKeyState & (MK_CONTROL | MK_SHIFT)) == 0) ||
  831. (((grfKeyState & (MK_CONTROL | MK_SHIFT)) == MK_SHIFT) &&
  832. !RemoteDirView->DDAllowMove))
  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::LocalDirViewDDFileOperation(
  860. TObject * /*Sender*/, int dwEffect, AnsiString SourcePath,
  861. AnsiString TargetPath, bool & DoOperation)
  862. {
  863. if (DropSourceControl == RemoteDirView)
  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. Terminal->CopyToLocal(FInternalDDDownloadList, TargetDirectory, &CopyParams,
  887. (TransferType == ttMove ? cpDelete : 0));
  888. FInternalDDDownloadList->Clear();
  889. }
  890. }
  891. DoOperation = false;
  892. }
  893. }
  894. }
  895. //---------------------------------------------------------------------------
  896. void __fastcall TScpCommanderForm::RemoteDirViewDDFileOperationExecuted(
  897. TObject * /*Sender*/, int dwEffect, AnsiString /*SourcePath*/,
  898. AnsiString /*TargetPath*/)
  899. {
  900. if ((dwEffect == DROPEFFECT_Move) && (DropSourceControl == LocalDirView))
  901. {
  902. LocalDirView->Reload(true);
  903. }
  904. }
  905. //---------------------------------------------------------------------------
  906. void __fastcall TScpCommanderForm::DoDirViewEnter(TCustomDirView * DirView)
  907. {
  908. if (FLastDirView != DirView)
  909. {
  910. CommandLineCombo->Items->Clear();
  911. FCommandLineComboPopulated = false;
  912. }
  913. TCustomScpExplorerForm::DoDirViewEnter(DirView);
  914. UpdateControls();
  915. }
  916. //---------------------------------------------------------------------------
  917. void __fastcall TScpCommanderForm::OpenConsole(AnsiString Command)
  918. {
  919. SaveCommandLine();
  920. try
  921. {
  922. TCustomScpExplorerForm::OpenConsole(Command);
  923. }
  924. __finally
  925. {
  926. FCommandLineComboPopulated = false;
  927. }
  928. }
  929. //---------------------------------------------------------------------------
  930. void __fastcall TScpCommanderForm::CommandLineComboKeyDown(TObject * /*Sender*/,
  931. WORD & Key, TShiftState /*Shift*/)
  932. {
  933. if (Key == VK_RETURN)
  934. {
  935. Key = 0;
  936. ExecuteCommandLine();
  937. }
  938. else if ((Key == VK_ESCAPE) && !CommandLineCombo->DroppedDown)
  939. {
  940. Key = 0;
  941. CommandLineCombo->Text = "";
  942. }
  943. else if ((Key == VK_UP) || (Key == VK_DOWN))
  944. {
  945. CommandLinePopulate();
  946. }
  947. }
  948. //---------------------------------------------------------------------------
  949. void __fastcall TScpCommanderForm::SaveCommandLine()
  950. {
  951. if (FCommandLineComboPopulated)
  952. {
  953. CustomWinConfiguration->History[
  954. FLastDirView == RemoteDirView ? "Commands" : "LocalCommands"] =
  955. CommandLineCombo->Items;
  956. }
  957. }
  958. //---------------------------------------------------------------------------
  959. void __fastcall TScpCommanderForm::ExecuteCommandLine()
  960. {
  961. if (!CommandLineCombo->Text.Trim().IsEmpty() &&
  962. ((FLastDirView != RemoteDirView) ||
  963. (Terminal->AllowedAnyCommand(CommandLineCombo->Text))))
  964. {
  965. CommandLinePopulate();
  966. CommandLineCombo->SaveToHistory();
  967. AnsiString Command = CommandLineCombo->Text;
  968. CommandLineCombo->Text = "";
  969. if (FLastDirView == RemoteDirView)
  970. {
  971. OpenConsole(Command);
  972. }
  973. else
  974. {
  975. AnsiString Program, Params, Dir;
  976. SplitCommand(Command, Program, Params, Dir);
  977. if (!ExecuteShell(Program, Params))
  978. {
  979. throw Exception(FMTLOAD(EXECUTE_APP_ERROR, (Program)));
  980. }
  981. }
  982. }
  983. }
  984. //---------------------------------------------------------------------------
  985. void __fastcall TScpCommanderForm::CommandLineComboDropDown(
  986. TObject * /*Sender*/)
  987. {
  988. CommandLinePopulate();
  989. }
  990. //---------------------------------------------------------------------------
  991. void __fastcall TScpCommanderForm::CommandLinePopulate()
  992. {
  993. if (!FCommandLineComboPopulated)
  994. {
  995. TStrings * CommandsHistory;
  996. CommandsHistory = CustomWinConfiguration->History[
  997. FLastDirView == RemoteDirView ? "Commands" : "LocalCommands"];
  998. if ((CommandsHistory != NULL) && (CommandsHistory->Count > 0))
  999. {
  1000. CommandLineCombo->Items = CommandsHistory;
  1001. }
  1002. else
  1003. {
  1004. CommandLineCombo->Items->Clear();
  1005. }
  1006. FCommandLineComboPopulated = true;
  1007. }
  1008. }
  1009. //---------------------------------------------------------------------------
  1010. void __fastcall TScpCommanderForm::GoToCommandLine()
  1011. {
  1012. ComponentVisible[fcCommandLinePanel] = true;
  1013. if (CommandLineCombo->Enabled)
  1014. {
  1015. CommandLineCombo->SetFocus();
  1016. }
  1017. }
  1018. //---------------------------------------------------------------------------
  1019. void __fastcall TScpCommanderForm::CommandLineComboEnter(TObject * /*Sender*/)
  1020. {
  1021. KeyPreview = false;
  1022. TPanel * LastPanel = FLastDirView == LocalDirView ? LocalPanel : RemotePanel;
  1023. if (CommandLinePanel->TabOrder > LastPanel->TabOrder)
  1024. {
  1025. CommandLinePanel->TabOrder = LastPanel->TabOrder;
  1026. }
  1027. else if (CommandLinePanel->TabOrder < LastPanel->TabOrder - 1)
  1028. {
  1029. CommandLinePanel->TabOrder = static_cast<TTabOrder>(LastPanel->TabOrder - 1);
  1030. }
  1031. }
  1032. //---------------------------------------------------------------------------
  1033. void __fastcall TScpCommanderForm::CommandLineComboExit(TObject * /*Sender*/)
  1034. {
  1035. KeyPreview = true;
  1036. }
  1037. //---------------------------------------------------------------------------
  1038. void __fastcall TScpCommanderForm::PanelExportStore(TOperationSide Side,
  1039. TPanelExport Export, TPanelExportDestination Destination,
  1040. TStringList * ExportData)
  1041. {
  1042. if (Destination == pedCommandLine)
  1043. {
  1044. ComponentVisible[fcCommandLinePanel] = true;
  1045. AnsiString Buf;
  1046. for (int Index = 0; Index < ExportData->Count; Index++)
  1047. {
  1048. Buf += ExportData->Strings[Index] + " ";
  1049. }
  1050. if (CommandLineCombo->Focused())
  1051. {
  1052. CommandLineCombo->SelText = Buf;
  1053. }
  1054. else
  1055. {
  1056. CommandLineCombo->Text = CommandLineCombo->Text + Buf;
  1057. }
  1058. }
  1059. else
  1060. {
  1061. TCustomScpExplorerForm::PanelExportStore(Side, Export, Destination, ExportData);
  1062. }
  1063. }
  1064. //---------------------------------------------------------------------------
  1065. int __fastcall TScpCommanderForm::GetStaticComponentsHeight()
  1066. {
  1067. return TCustomScpExplorerForm::GetStaticComponentsHeight() +
  1068. (CommandLinePanel->Visible ? CommandLinePanel->Height : 0) +
  1069. (ToolbarPanel->Visible ? ToolbarPanel->Height : 0) +
  1070. (StatusBar->Visible ? StatusBar->Height : 0);
  1071. }
  1072. //---------------------------------------------------------------------------
  1073. void __fastcall TScpCommanderForm::Resize()
  1074. {
  1075. TCustomScpExplorerForm::Resize();
  1076. LocalPanelWidth = FLastLocalPanelWidth;
  1077. UpdateControls();
  1078. }
  1079. //---------------------------------------------------------------------------
  1080. void __fastcall TScpCommanderForm::StatusBarDblClick(TObject * /*Sender*/)
  1081. {
  1082. DoFileSystemInfoDialog(Terminal);
  1083. }
  1084. //---------------------------------------------------------------------------
  1085. void __fastcall TScpCommanderForm::LocalDirViewDDMenuPopup(TObject * /*Sender*/,
  1086. HMENU AMenu, IDataObject * /*DataObj*/, int /*AMinCustCmd*/, int /*grfKeyState*/,
  1087. TPoint & /*pt*/)
  1088. {
  1089. if ((DropSourceControl == RemoteDirView) &&
  1090. !RemoteDirView->DDAllowMove)
  1091. {
  1092. // index of copy item
  1093. int Index = GetMenuDefaultItem(AMenu, TRUE, 0);
  1094. assert(Index >= 0);
  1095. AnsiString Caption = Dragdrop_MIMoveStr;
  1096. MENUITEMINFO MI;
  1097. memset(&MI, 0, sizeof(MI));
  1098. MI.cbSize = sizeof(MI);
  1099. MI.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
  1100. MI.fType = MFT_STRING;
  1101. MI.wID = 1 /*DragDrop::CmdMove*/;
  1102. MI.dwTypeData = Caption.c_str();
  1103. MI.cch = Caption.Length();
  1104. MI.fState = MFS_ENABLED;
  1105. InsertMenuItem(AMenu, Index, TRUE, &MI);
  1106. if (FDDMoveSlipped)
  1107. {
  1108. SetMenuDefaultItem(AMenu, Index, TRUE);
  1109. }
  1110. FDDMoveSlipped = false;
  1111. }
  1112. }
  1113. //---------------------------------------------------------------------------