| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850 | //---------------------------------------------------------------------------#include <vcl.h>#pragma hdrstop#include "NonVisual.h"#include <Common.h>#include <CoreMain.h>#include <TextsWin.h>#include <Tools.h>#include <Setup.h>#include <Log.h>#include <Interface.h>#include "WinConfiguration.h"#include "TerminalManager.h"#include "TBX.hpp"#include "VCLCommon.h"#include <HistoryComboBox.hpp>//---------------------------------------------------------------------------#pragma package(smart_init)#pragma link "TB2Item"#pragma link "TBX"#pragma link "TB2ExtItems"#pragma link "TBXExtItems"#pragma link "TBXToolPals"#ifndef NO_RESOURCES#pragma resource "*.dfm"#endifTNonVisualDataModule *NonVisualDataModule;//---------------------------------------------------------------------------#define SCPCOMMANDER ((TScpCommanderForm *)ScpExplorer)#define UPDEX(HandleAction, Condition, OtherEnabled, OtherDisabled) if (Action == HandleAction) { \  ((TCustomAction *)Action)->Enabled = (Condition); \  if (((TCustomAction *)Action)->Enabled) { OtherEnabled; } else { OtherDisabled; }; \  Handled = true; } else#define UPDEX1(HandleAction, Condition, Other) UPDEX(HandleAction, Condition, Other, Other)#define UPD(HandleAction, Condition) if (Action == HandleAction) { \  ((TCustomAction *)Action)->Enabled = (Condition); Handled = true; } else#define UPDFUNC(HandleAction, Function) if (Action == HandleAction) { Function; Handled = true; } else#define EXE(HandleAction, Command) if (Action == HandleAction) { \  Command; Handled = true; } else#define UPDACT(HandleAction, Command) \  EXE(HandleAction, ((TCustomAction *)Action)->Enabled = true; Command)#define UPDCOMP(COMP) if (Action == COMP ## Action) { COMP ## Action->Enabled = true; \  COMP ## Action->Checked = ScpExplorer->ComponentVisible[fc ## COMP]; Handled = true; } else#define EXECOMP(COMP) EXE(COMP ## Action, \  ScpExplorer->ComponentVisible[fc ## COMP] = !ScpExplorer->ComponentVisible[fc ## COMP] )#define COLPROPS(SIDE) \  ((TCustomDirViewColProperties*)ScpExplorer->DirView(os ## SIDE)->ColProperties)#define UPDSORT(SIDE, PREFIX, COL) if (Action == SIDE ## SortBy ## COL ## Action) { \  SIDE ## SortBy ## COL ## Action->Enabled = true; Handled = true; \  SIDE ## SortBy ## COL ## Action->Checked = (COLPROPS(SIDE)->SortColumn == PREFIX ## COL); } else#define EXESORT(SIDE, PREFIX, COL) EXE(SIDE ## SortBy ## COL ## Action, \    if (COLPROPS(SIDE)->SortColumn == PREFIX ## COL) \      COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; \    else COLPROPS(SIDE)->SortColumn = PREFIX ## COL )#define UPDSORTA(SIDE) if (Action == SIDE ## SortAscendingAction) { \  SIDE ## SortAscendingAction->Enabled = true; Handled = true; \  SIDE ## SortAscendingAction->Checked = COLPROPS(SIDE)->SortAscending; } else#define EXESORTA(SIDE) EXE(SIDE ## SortAscendingAction, \  COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; )#define UPDSORTC(LPREFIX, LCOL, RPREFIX, RCOL) if (Action == CurrentSortBy ## RCOL ## Action) { \  CurrentSortBy ## RCOL ## Action->Enabled = ScpExplorer->AllowedAction((TAction *)Action, aaShortCut); \  if (CurrentSortBy ## RCOL ## Action->Enabled) { \    if (ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) \         CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == RPREFIX ## RCOL); \    else CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == LPREFIX ## LCOL); \  } else CurrentSortBy ## RCOL ## Action->Checked =  false; Handled = true; } else#define EXESORTC(COL, LCOL, RCOL) \  EXE(CurrentSortBy ## COL ## Action, \    Integer NewSortCol = \      ((ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) ? RCOL : LCOL); \    if (COLPROPS(Current)->SortColumn == NewSortCol) \      COLPROPS(Current)->SortAscending = !COLPROPS(Current)->SortAscending; \    else COLPROPS(Current)->SortColumn = NewSortCol \  )#define UPDSHCOL(SIDE, PREFIX, COL) \  EXE(ShowHide ## SIDE ## COL ## ColumnAction, \    ShowHide ## SIDE ## COL ## ColumnAction->Checked = COLPROPS(SIDE)->Visible[PREFIX ## COL])#define EXESHCOL(SIDE, PREFIX, COL) \  EXE(ShowHide ## SIDE ## COL ## ColumnAction, \    COLPROPS(SIDE)->Visible[PREFIX ## COL] = !COLPROPS(SIDE)->Visible[PREFIX ## COL])//---------------------------------------------------------------------------__fastcall TNonVisualDataModule::TNonVisualDataModule(TComponent* Owner)        : TDataModule(Owner){  FListColumn = NULL;  FSessionIdleTimerExecuting = false;  FBusy = 0;  QueueSpeedComboBoxItem(QueuePopupSpeedComboBoxItem);}//---------------------------------------------------------------------------__fastcall TNonVisualDataModule::~TNonVisualDataModule(){}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::LogActionsUpdate(      TBasicAction *Action, bool &Handled){  TLogMemo * LogMemo = TTerminalManager::Instance()->LogMemo;  bool ValidLogMemo = LogMemo && LogMemo->Parent;  UPD(LogClearAction, ValidLogMemo && LogMemo->Lines->Count)  // removed potentially CPU intensive check for "all selected already"  UPD(LogSelectAllAction2, ValidLogMemo && LogMemo->Lines->Count)  UPD(LogCopyAction, ValidLogMemo && LogMemo->SelLength)  UPD(LogPreferencesAction2, true)  ;}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::LogActionsExecute(      TBasicAction *Action, bool &Handled){  {    TAutoNestingCounter Counter(FBusy);    TLogMemo * LogMemo = TTerminalManager::Instance()->LogMemo;    DebugAssert(LogMemo && LogMemo->Parent);    EXE(LogClearAction, LogMemo->SessionLog->Clear())    EXE(LogSelectAllAction2, LogMemo->SelectAll())    EXE(LogCopyAction, LogMemo->CopyToClipboard())    EXE(LogPreferencesAction2, PreferencesDialog(pmLogging));    ;  }  DoIdle();}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(      TBasicAction *Action, bool &Handled){  if (!ScpExplorer || !ScpExplorer->AllowedAction((TAction *)Action, aaUpdate))  {    ((TAction *)Action)->Enabled = false;    Handled = true;    return;  }  void * Param;  #define HasTerminal (ScpExplorer->Terminal != NULL)  // CURRENT DIRVIEW  #define EnabledSelectedOperation (ScpExplorer->EnableSelectedOperation[osCurrent])  #define EnabledFocusedOperation (ScpExplorer->EnableFocusedOperation[osCurrent])  #define EnabledSelectedFileOperation (ScpExplorer->EnableSelectedFileOperation[osCurrent])  #define EnabledFocusedFileOperation (ScpExplorer->EnableFocusedFileOperation[osCurrent])  #define EnabledLocalSelectedOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableSelectedOperation[osLocal])  #define EnabledLocalFocusedOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableFocusedOperation[osLocal])  #define EnabledLocalSelectedFileOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableSelectedFileOperation[osLocal])  #define EnabledRemoteSelectedOperation (ScpExplorer->EnableSelectedOperation[osRemote])  #define EnabledRemoteFocusedOperation (ScpExplorer->EnableFocusedOperation[osRemote])  #define EnabledRemoteSelectedFileOperation (ScpExplorer->EnableSelectedFileOperation[osRemote])  // focused operation  UPD(CurrentDeleteFocusedAction, EnabledFocusedOperation)  UPD(CurrentPropertiesFocusedAction, EnabledFocusedOperation)  UPD(CurrentEditFocusedAction, EnabledFocusedFileOperation &&    !WinConfiguration->DisableOpenEdit)  UPD(CurrentSystemMenuFocusedAction, EnabledFocusedOperation)  UPD(CurrentEditWithFocusedAction, EnabledFocusedFileOperation &&    !WinConfiguration->DisableOpenEdit)  UPD(CurrentEditInternalFocusedAction, EnabledFocusedFileOperation &&    !WinConfiguration->DisableOpenEdit)  // file operation  UPD(CurrentRenameAction, EnabledFocusedOperation &&    ((ScpExplorer->HasDirView[osLocal] && DirView(osLocal) == DirView(osCurrent)) ||      ScpExplorer->Terminal->IsCapable[fcRename]))  UPD(CurrentEditAction, EnabledSelectedFileOperation &&    !WinConfiguration->DisableOpenEdit)  UPD(CurrentEditInternalAction, EnabledSelectedFileOperation &&    !WinConfiguration->DisableOpenEdit)  UPD(CurrentEditWithAction, EnabledSelectedFileOperation &&    !WinConfiguration->DisableOpenEdit)  UPD(CurrentOpenAction, EnabledFocusedOperation &&    !WinConfiguration->DisableOpenEdit)  UPDEX1(CurrentAddEditLinkContextAction, ScpExplorer->CanAddEditLink(osCurrent),    ((TAction *)Action)->Visible = ScpExplorer->LinkFocused())  UPD(NewLinkAction, ScpExplorer->CanAddEditLink(osCurrent))  // selected operation  UPD(CurrentDeleteAction, EnabledSelectedOperation)  UPD(CurrentDeleteAlternativeAction, EnabledSelectedOperation)  UPD(CurrentPropertiesAction, EnabledSelectedOperation)  UPD(RemoteMoveToAction, EnabledSelectedOperation &&    (DirView(osRemote) == DirView(osCurrent)) &&    ScpExplorer->Terminal->IsCapable[fcRemoteMove])  UPD(RemoteCopyToAction, EnabledSelectedOperation &&    (DirView(osRemote) == DirView(osCurrent)))  UPD(FileListToCommandLineAction, EnabledSelectedOperation)  UPD(FileListToClipboardAction, EnabledSelectedOperation)  UPD(FullFileListToClipboardAction, EnabledSelectedOperation)  UPD(FileGenerateUrlAction2, EnabledSelectedOperation && (DirView(osRemote) == DirView(osCurrent)))  UPD(FileListFromClipboardAction, IsFormatInClipboard(CF_TEXT))  UPD(CurrentAddEditLinkAction, ScpExplorer->CanAddEditLink(osCurrent))  UPD(LockAction,    EnabledSelectedOperation && (DirView(osRemote) == DirView(osCurrent)) &&    ScpExplorer->Terminal->IsCapable[fcLocking])  UPD(UnlockAction,    EnabledSelectedOperation && (DirView(osRemote) == DirView(osCurrent)) &&    ScpExplorer->Terminal->IsCapable[fcLocking])  // local selected operation  UPD(LocalCopyAction, HasTerminal && EnabledLocalSelectedOperation)  UPD(LocalCopyQueueAction, HasTerminal && EnabledLocalSelectedOperation)  UPD(LocalCopyNonQueueAction, HasTerminal && EnabledLocalSelectedOperation)  UPD(LocalRenameAction, EnabledLocalSelectedOperation)  UPD(LocalEditAction, EnabledLocalSelectedFileOperation && !WinConfiguration->DisableOpenEdit)  UPD(LocalMoveAction, HasTerminal && EnabledLocalSelectedOperation)  UPD(LocalCreateDirAction, true)  UPD(LocalDeleteAction, EnabledLocalSelectedOperation)  UPD(LocalPropertiesAction, EnabledLocalSelectedOperation)  UPD(LocalAddEditLinkAction, ScpExplorer->CanAddEditLink(osLocal))  // local focused operation  UPD(LocalCopyFocusedAction, HasTerminal && EnabledLocalFocusedOperation)  UPD(LocalCopyFocusedQueueAction, HasTerminal && EnabledLocalFocusedOperation)  UPD(LocalCopyFocusedNonQueueAction, HasTerminal && EnabledLocalFocusedOperation)  UPD(LocalMoveFocusedAction, HasTerminal && EnabledLocalFocusedOperation)  // remote selected operation  UPD(RemoteCopyAction, EnabledRemoteSelectedOperation)  UPD(RemoteCopyQueueAction, EnabledRemoteSelectedOperation)  UPD(RemoteCopyNonQueueAction, EnabledRemoteSelectedOperation)  UPD(RemoteRenameAction, EnabledRemoteSelectedOperation &&    ScpExplorer->Terminal->IsCapable[fcRename])  UPD(RemoteEditAction, EnabledRemoteSelectedFileOperation && !WinConfiguration->DisableOpenEdit)  UPD(RemoteMoveAction, EnabledRemoteSelectedOperation)  UPD(RemoteCreateDirAction, DirViewEnabled(osRemote))  UPD(RemoteDeleteAction, EnabledRemoteSelectedOperation)  UPD(RemotePropertiesAction, EnabledRemoteSelectedOperation)  UPD(RemoteAddEditLinkAction, ScpExplorer->CanAddEditLink(osRemote))  // remote focused operation  UPD(RemoteCopyFocusedAction, EnabledRemoteFocusedOperation)  UPD(RemoteCopyFocusedQueueAction, EnabledRemoteFocusedOperation)  UPD(RemoteCopyFocusedNonQueueAction, EnabledRemoteFocusedOperation)  UPD(RemoteMoveFocusedAction, EnabledRemoteFocusedOperation)  UPD(RemoteMoveToFocusedAction, EnabledFocusedOperation &&    (DirView(osRemote) == DirView(osCurrent)) &&    ScpExplorer->Terminal->IsCapable[fcRemoteMove])  UPD(RemoteCopyToFocusedAction, EnabledFocusedOperation &&    DirView(osRemote) == DirView(osCurrent))  // directory  UPD(CurrentCreateDirAction, DirViewEnabled(osCurrent))  UPD(NewDirAction, DirViewEnabled(osCurrent))  UPD(RemoteFindFilesAction, DirViewEnabled(osRemote))  // selection  UPD(SelectOneAction, DirView(osCurrent)->FilesCount)  UPD(SelectAction, DirView(osCurrent)->FilesCount)  UPD(UnselectAction, DirView(osCurrent)->SelCount)  UPD(SelectAllAction, DirView(osCurrent)->FilesCount)  UPD(InvertSelectionAction, DirView(osCurrent)->FilesCount)  UPD(ClearSelectionAction, DirView(osCurrent)->SelCount)  UPD(RestoreSelectionAction, DirView(osCurrent)->SelectedNamesSaved)  UPD(SelectSameExtAction, EnabledFocusedFileOperation)  UPD(UnselectSameExtAction, EnabledFocusedFileOperation)  UPD(PasteAction2, ScpExplorer->CanPasteFromClipBoard())  UPD(LocalSelectAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->FilesCount)  UPD(LocalUnselectAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->SelCount)  UPD(LocalSelectAllAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->FilesCount)  UPD(RemoteSelectAction, DirView(osRemote)->FilesCount)  UPD(RemoteUnselectAction, DirView(osRemote)->SelCount)  UPD(RemoteSelectAllAction, DirView(osRemote)->FilesCount)  //style  UPDACT(CurrentCycleStyleAction,    CurrentCycleStyleAction->ImageIndex = 8 + (DirView(osCurrent)->ViewStyle + 1) % 4)  #define STYLEACTION(Style) UPDACT(Current ## Style ## Action, \    Current ## Style ## Action->Checked = (DirView(osCurrent)->ViewStyle == vs ## Style))  STYLEACTION(Icon)  STYLEACTION(SmallIcon)  STYLEACTION(List)  STYLEACTION(Report)  #undef STYLEACTION  // REMOTE+LOCAL  // back/forward  #define HISTORYACTION(SIDE, DIRECTION, HINTFMT, DELTA) \    UPDEX(SIDE ## DIRECTION ## Action, DirViewEnabled(os ## SIDE) && (DirView(os ## SIDE)->DIRECTION ## Count > 0), \    SIDE ## DIRECTION ## Action->Hint = FMTLOAD(HINTFMT, (DirView(os ## SIDE)->HistoryPath[DELTA])), \    SIDE ## DIRECTION ## Action->Hint = L"")  HISTORYACTION(Local, Back, EXPLORER_BACK_HINT, -1)  HISTORYACTION(Local, Forward, EXPLORER_FORWARD_HINT, 1)  HISTORYACTION(Remote, Back, EXPLORER_BACK_HINT, -1)  HISTORYACTION(Remote, Forward, EXPLORER_FORWARD_HINT, 1)  #undef HISTORYACTION  #define PANEL_ACTIONS(SIDE) \    UPD(SIDE ## ParentDirAction, DirViewEnabled(os ## SIDE) && !DirView(os ## SIDE)->IsRoot) \    UPD(SIDE ## RootDirAction, DirViewEnabled(os ## SIDE) &&!DirView(os ## SIDE)->IsRoot) \    UPD(SIDE ## HomeDirAction, DirViewEnabled(os ## SIDE)) \    UPD(SIDE ## RefreshAction, DirViewEnabled(os ## SIDE) && DirView(os ## SIDE)->DirOK) \    UPD(SIDE ## OpenDirAction, DirViewEnabled(os ## SIDE)) \    UPD(SIDE ## ChangePathAction, DirViewEnabled(os ## SIDE)) \    UPD(SIDE ## AddBookmarkAction, DirViewEnabled(os ## SIDE)) \    UPD(SIDE ## PathToClipboardAction, DirViewEnabled(os ## SIDE)) \    UPDEX1(SIDE ## FilterAction, DirViewEnabled(os ## SIDE), ((TAction *)Action)->Checked = !DirView(os ## SIDE)->Mask.IsEmpty())  PANEL_ACTIONS(Local)  PANEL_ACTIONS(Remote)  #undef PANEL_ACTIONS  UPD(LocalExploreDirectoryAction, true)  // HELP  UPD(AboutAction, true)  UPD(HomepageAction, true)  UPD(HistoryPageAction, true)  UPD(TableOfContentsAction, true)  UPD(ForumPageAction, true)  UPDACT(CheckForUpdatesAction, ShowUpdatesUpdate())  UPD(UpdatesPreferencesAction, true)  UPD(DonatePageAction, true)  UPD(DownloadPageAction, true)  UPD(TipsAction, true)  // VIEW  UPDCOMP(SessionsTabs)  UPDCOMP(StatusBar)  UPDCOMP(ToolBar2)  UPDCOMP(LocalStatusBar)  UPDCOMP(RemoteStatusBar)  UPDCOMP(CommandLinePanel)  UPDCOMP(RemoteTree)  UPDCOMP(LocalTree)  UPDCOMP(ExplorerMenuBand)  UPDCOMP(ExplorerAddressBand)  UPDCOMP(ExplorerToolbarBand)  UPDCOMP(ExplorerSelectionBand)  UPDCOMP(ExplorerSessionBand)  UPDCOMP(ExplorerPreferencesBand)  UPDCOMP(ExplorerSortBand)  UPDCOMP(ExplorerUpdatesBand)  UPDCOMP(ExplorerTransferBand)  UPDCOMP(ExplorerCustomCommandsBand)  UPDCOMP(CommanderMenuBand)  UPDCOMP(CommanderSessionBand)  UPDCOMP(CommanderPreferencesBand)  UPDCOMP(CommanderSortBand)  UPDCOMP(CommanderCommandsBand)  UPDCOMP(CommanderUpdatesBand)  UPDCOMP(CommanderTransferBand)  UPDCOMP(CommanderCustomCommandsBand)  UPDCOMP(CommanderLocalHistoryBand)  UPDCOMP(CommanderLocalNavigationBand)  UPDCOMP(CommanderLocalFileBand)  UPDCOMP(CommanderLocalSelectionBand)  UPDCOMP(CommanderRemoteHistoryBand)  UPDCOMP(CommanderRemoteNavigationBand)  UPDCOMP(CommanderRemoteFileBand)  UPDCOMP(CommanderRemoteSelectionBand)  UPD(GoToCommandLineAction, true)  UPD(GoToTreeAction, true)  UPDEX(ViewLogAction, Configuration->Logging && HasTerminal,    ViewLogAction->Checked = (WinConfiguration->LogView == lvWindow),    ViewLogAction->Checked = false )  UPDEX(ShowHiddenFilesAction, true,    ShowHiddenFilesAction->Checked = WinConfiguration->ShowHiddenFiles, )  UPDEX(FormatSizeBytesNoneAction, true,    FormatSizeBytesNoneAction->Checked = (WinConfiguration->FormatSizeBytes == fbNone), )  UPDEX(FormatSizeBytesKilobytesAction, true,    FormatSizeBytesKilobytesAction->Checked = (WinConfiguration->FormatSizeBytes == fbKilobytes), )  UPDEX(FormatSizeBytesShortAction, true,    FormatSizeBytesShortAction->Checked = (WinConfiguration->FormatSizeBytes == fbShort), )  UPDEX(AutoReadDirectoryAfterOpAction, true,    AutoReadDirectoryAfterOpAction->Checked = Configuration->AutoReadDirectoryAfterOp, )  UPD(PreferencesAction, true)  UPD(PresetsPreferencesAction, true)  UPDEX(LockToolbarsAction, true,    LockToolbarsAction->Checked = WinConfiguration->LockToolbars, )  UPDEX(SelectiveToolbarTextAction, true,    SelectiveToolbarTextAction->Checked = WinConfiguration->SelectiveToolbarText, )  UPDCOMP(CustomCommandsBand)  UPD(ColorMenuAction, HasTerminal)  UPD(GoToAddressAction, true)  // SORT  UPDSORTA(Local)  UPDSORT(Local, dv, Name)  UPDSORT(Local, dv, Ext)  UPDSORT(Local, dv, Size)  UPDSORT(Local, dv, Type)  UPDSORT(Local, dv, Changed)  UPDSORT(Local, dv, Attr)  UPDSORTA(Remote)  UPDSORT(Remote, uv, Name)  UPDSORT(Remote, uv, Ext)  UPDSORT(Remote, uv, Size)  UPDSORT(Remote, uv, Changed)  UPDSORT(Remote, uv, Rights)  UPDSORT(Remote, uv, Owner)  UPDSORT(Remote, uv, Group)  UPDSORT(Remote, uv, Type)  UPDSORTA(Current)  UPDSORTC(dv, Name, uv, Name)  UPDSORTC(dv, Ext, uv, Ext)  UPDSORTC(dv, Size, uv, Size)  UPDSORTC(dv, Type, uv, Type)  UPDSORTC(dv, Changed, uv, Changed)  UPDSORTC(dv, Attr, uv, Rights)  UPDSORTC(dv, Name, uv, Owner)  UPDSORTC(dv, Name, uv, Group)  #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))  UPDEX(SortColumnAscendingAction, (ListColumn != NULL), SortColumnAscendingAction->Checked =    (COLVIEWPROPS->SortColumn == ListColumn->Index) && COLVIEWPROPS->SortAscending, /*DebugFail()*/  )  UPDEX(SortColumnDescendingAction, (ListColumn != NULL), SortColumnDescendingAction->Checked =    (COLVIEWPROPS->SortColumn == ListColumn->Index) && !COLVIEWPROPS->SortAscending, /*DebugFail()*/ )  #undef COLVIEWPROPS  // SHOW/HIDE COLUMN  UPDSHCOL(Local, dv, Name)  UPDSHCOL(Local, dv, Ext)  UPDSHCOL(Local, dv, Size)  UPDSHCOL(Local, dv, Type)  UPDSHCOL(Local, dv, Changed)  UPDSHCOL(Local, dv, Attr)  UPDSHCOL(Remote, uv, Name)  UPDSHCOL(Remote, uv, Ext)  UPDSHCOL(Remote, uv, Size)  UPDSHCOL(Remote, uv, Changed)  UPDSHCOL(Remote, uv, Rights)  UPDSHCOL(Remote, uv, Owner)  UPDSHCOL(Remote, uv, Group)  UPDSHCOL(Remote, uv, LinkTarget)  UPDSHCOL(Remote, uv, Type)  UPD(HideColumnAction, (ListColumn != NULL))  UPD(BestFitColumnAction, (ListColumn != NULL))  // SESSION  UPD(NewSessionAction, true)  UPD(SiteManagerAction, true)  UPD(DuplicateSessionAction, HasTerminal)  UPD(CloseSessionAction, HasTerminal)  UPD(SavedSessionsAction2, true)  UPD(WorkspacesAction, StoredSessions->HasAnyWorkspace())  UPD(OpenedSessionsAction, HasTerminal)  UPD(SaveCurrentSessionAction2, HasTerminal)  UPD(SaveWorkspaceAction, HasTerminal)  // COMMAND  UPD(CompareDirectoriesAction, HasTerminal)  UPD(SynchronizeAction, HasTerminal)  UPD(FullSynchronizeAction, HasTerminal)  UPD(ConsoleAction, ScpExplorer->CanConsole())  UPD(PuttyAction, HasTerminal && TTerminalManager::Instance()->CanOpenInPutty())  UPD(SynchronizeBrowsingAction, HasTerminal)  UPD(CloseApplicationAction, true)  UPD(FileSystemInfoAction, HasTerminal)  UPD(SessionGenerateUrlAction2, HasTerminal)  UPD(ClearCachesAction, HasTerminal && !ScpExplorer->Terminal->AreCachesEmpty)  UPD(NewFileAction, DirViewEnabled(osCurrent) && !WinConfiguration->DisableOpenEdit)  UPD(EditorListCustomizeAction, true)  // CUSTOM COMMANDS  UPD(CustomCommandsFileAction, true)  UPD(CustomCommandsNonFileAction, true)  UPD(CustomCommandsEnterAction, true)  UPD(CustomCommandsEnterFocusedAction, true)  UPDFUNC(CustomCommandsLastAction, CustomCommandsLastUpdate(CustomCommandsLastAction))  UPDFUNC(CustomCommandsLastFocusedAction, CustomCommandsLastUpdate(CustomCommandsLastFocusedAction))  UPD(CustomCommandsCustomizeAction, true)  // QUEUE  UPDEX(QueueEnableAction, HasTerminal, ((TAction *)Action)->Checked = ScpExplorer->GetQueueEnabled(), )  #define UPDQUEUE(OPERATION) UPD(Queue ## OPERATION ## Action, \    ScpExplorer->AllowQueueOperation(qo ## OPERATION))  UPDQUEUE(GoTo)  UPDQUEUE(Preferences)  UPDEX(QueueItemQueryAction, ScpExplorer->AllowQueueOperation(qoItemQuery),    ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)  UPDEX(QueueItemErrorAction, ScpExplorer->AllowQueueOperation(qoItemError),    ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)  UPDEX(QueueItemPromptAction, ScpExplorer->AllowQueueOperation(qoItemPrompt),    ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)  UPDQUEUE(ItemDelete)  UPDEX(QueueItemExecuteAction, ScpExplorer->AllowQueueOperation(qoItemExecute),    ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible =      !ScpExplorer->AllowQueueOperation(qoItemPause) &&      !ScpExplorer->AllowQueueOperation(qoItemResume))  UPDEX(QueueItemPauseAction, ScpExplorer->AllowQueueOperation(qoItemPause),    ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)  UPDEX(QueueItemResumeAction, ScpExplorer->AllowQueueOperation(qoItemResume),    ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)  UPDQUEUE(ItemUp)  UPDQUEUE(ItemDown)  UPDQUEUE(PauseAll)  UPDQUEUE(ResumeAll)  UPDQUEUE(DeleteAll)  UPDQUEUE(DeleteAllDone)  #undef UPDQUEUE  UPDEX(QueueItemSpeedAction, ScpExplorer->AllowQueueOperation(qoItemSpeed, &Param),    QueueItemSpeedAction->Text = SetSpeedLimit(reinterpret_cast<unsigned long>(Param)),    QueueItemSpeedAction->Text = L"")  UPDACT(QueueToggleShowAction,    ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueView])  #define QUEUEACTION(SHOW) UPDACT(Queue ## SHOW ## Action, \    ((TAction *)Action)->Checked = WinConfiguration->QueueView.Show == qv ## SHOW)  QUEUEACTION(Show)  QUEUEACTION(HideWhenEmpty)  QUEUEACTION(Hide)  #undef QUEUEACTION  UPDEX1(QueueCycleOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty),    QueueCycleOnceEmptyAction->ImageIndex = CurrentQueueOnceEmptyAction()->ImageIndex;    QueueCycleOnceEmptyAction->Checked = !QueueIdleOnceEmptyAction->Checked)  UPD(QueueIdleOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))  UPD(QueueDisconnectOnceEmptyAction2, ScpExplorer->AllowQueueOperation(qoOnceEmpty))  UPD(QueueSuspendOnceEmptyAction2, ScpExplorer->AllowQueueOperation(qoOnceEmpty))  UPD(QueueShutDownOnceEmptyAction2, ScpExplorer->AllowQueueOperation(qoOnceEmpty))  UPDCOMP(CommanderPreferencesBand)  UPDACT(QueueToolbarAction,    ((TAction *)Action)->Enabled = ScpExplorer->ComponentVisible[fcQueueView];    ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueToolbar])  ;}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::ExplorerActionsExecute(      TBasicAction *Action, bool &Handled){  DebugAssert(ScpExplorer);  if (!ScpExplorer->AllowedAction((TAction *)Action, aaExecute))  {    Handled = true;    return;  }  ScpExplorer->BeforeAction();  unsigned int ShortCutFlag = FLAGMASK((Action->ActionComponent == NULL), cocShortCutHint);  {    TAutoNestingCounter Counter(FBusy);    // focused operation    EXE(CurrentDeleteFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, true))    EXE(CurrentPropertiesFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, true))    EXE(CurrentEditFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, true))    EXE(CurrentSystemMenuFocusedAction, ScpExplorer->DisplaySystemContextMenu())    EXE(CurrentEditWithFocusedAction, ScpExplorer->ExecuteCurrentFileWith(true))    EXE(CurrentEditInternalFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, true))    // operation    EXE(CurrentEditAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, false))    EXE(CurrentEditInternalAction, ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, false))    EXE(CurrentEditWithAction, ScpExplorer->ExecuteCurrentFileWith(false))    EXE(CurrentOpenAction, ScpExplorer->ExecuteCurrentFile())    EXE(CurrentAddEditLinkAction, ScpExplorer->AddEditLink(osCurrent, false))    EXE(CurrentAddEditLinkContextAction, ScpExplorer->AddEditLink(osCurrent, false))    EXE(NewLinkAction, ScpExplorer->AddEditLink(osCurrent, true))    EXE(CurrentRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osCurrent, false))    EXE(CurrentDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false))    EXE(CurrentDeleteAlternativeAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false, false, (void*)true))    EXE(CurrentPropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, false))    EXE(FileListToCommandLineAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedCommandLine))    EXE(FileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedClipboard))    EXE(FullFileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFullFileList, pedClipboard))    EXE(FileGenerateUrlAction2, ScpExplorer->FileGenerateUrl())    EXE(FileListFromClipboardAction, ScpExplorer->FileListFromClipboard())    EXE(LockAction, ScpExplorer->ExecuteFileOperationCommand(foLock, osCurrent, false))    EXE(UnlockAction, ScpExplorer->ExecuteFileOperationCommand(foUnlock, osCurrent, false))    // local selected operation    EXE(LocalCopyAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, false, ShortCutFlag))    EXE(LocalCopyQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, false, cocQueue))    EXE(LocalCopyNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, false, cocNonQueue))    EXE(LocalRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osLocal, false))    EXE(LocalEditAction, ScpExplorer->ExecuteFile(osLocal, efDefaultEditor, NULL, true, false))    EXE(LocalMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, false))    EXE(LocalCreateDirAction, ScpExplorer->CreateDirectory(osLocal))    EXE(LocalDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osLocal, false))    EXE(LocalPropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osLocal, false))    EXE(LocalAddEditLinkAction, ScpExplorer->AddEditLink(osLocal, false))    // local focused operation    EXE(LocalCopyFocusedAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, true, ShortCutFlag))    EXE(LocalCopyFocusedQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, true, cocQueue))    EXE(LocalCopyFocusedNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, true, cocNonQueue))    EXE(LocalMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, true))    // remote selected operation    EXE(RemoteCopyAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, false, ShortCutFlag))    EXE(RemoteCopyQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, false, cocQueue))    EXE(RemoteCopyNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, false, cocNonQueue))    EXE(RemoteRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osRemote, false))    EXE(RemoteEditAction, ScpExplorer->ExecuteFile(osRemote, efDefaultEditor, NULL, true, false))    EXE(RemoteMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, false))    EXE(RemoteCreateDirAction, ScpExplorer->CreateDirectory(osRemote))    EXE(RemoteDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osRemote, false))    EXE(RemotePropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osRemote, false))    EXE(RemoteMoveToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, false))    EXE(RemoteCopyToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, false))    EXE(RemoteAddEditLinkAction, ScpExplorer->AddEditLink(osRemote, false))    // remote focused operation    EXE(RemoteCopyFocusedAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, true, ShortCutFlag))    EXE(RemoteCopyFocusedQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, true, cocQueue))    EXE(RemoteCopyFocusedNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, true, cocNonQueue))    EXE(RemoteMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, true))    EXE(RemoteMoveToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, true))    EXE(RemoteCopyToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, true))    // directory    EXE(CurrentCreateDirAction, ScpExplorer->CreateDirectory(osCurrent))    EXE(NewDirAction, ScpExplorer->CreateDirectory(osCurrent))    EXE(RemoteFindFilesAction, ScpExplorer->RemoteFindFiles())    //selection    EXE(SelectOneAction, DirView(osCurrent)->SelectCurrentItem(DirView(osCurrent)->NortonLike))    EXE(SelectAction, DirView(osCurrent)->DoSelectByMask(true))    EXE(UnselectAction, DirView(osCurrent)->DoSelectByMask(false))    EXE(SelectAllAction, DirView(osCurrent)->SelectAll(smAll))    EXE(InvertSelectionAction, DirView(osCurrent)->SelectAll(smInvert))    EXE(ClearSelectionAction, DirView(osCurrent)->SelectAll(smNone))    EXE(RestoreSelectionAction, DirView(osCurrent)->RestoreSelectedNames())    EXE(SelectSameExtAction, ScpExplorer->SelectSameExt(true))    EXE(UnselectSameExtAction, ScpExplorer->SelectSameExt(false))    EXE(LocalSelectAction, DirView(osLocal)->DoSelectByMask(true))    EXE(LocalUnselectAction, DirView(osLocal)->DoSelectByMask(false))    EXE(LocalSelectAllAction, DirView(osLocal)->SelectAll(smAll))    EXE(RemoteSelectAction, DirView(osRemote)->DoSelectByMask(true))    EXE(RemoteUnselectAction, DirView(osRemote)->DoSelectByMask(false))    EXE(RemoteSelectAllAction, DirView(osRemote)->SelectAll(smAll))    EXE(PasteAction2, ScpExplorer->PasteFromClipBoard())    // style    EXE(CurrentCycleStyleAction,      if (DirView(osCurrent)->ViewStyle == vsReport) DirView(osCurrent)->ViewStyle = vsIcon;        else DirView(osCurrent)->ViewStyle = (TViewStyle)(DirView(osCurrent)->ViewStyle + 1);    )    #define STYLEACTION(Style) EXE(Current ## Style ## Action, \      DirView(osCurrent)->ViewStyle = vs ## Style)    STYLEACTION(Icon)    STYLEACTION(SmallIcon)    STYLEACTION(List)    STYLEACTION(Report)    #undef STYLEACTION    #define PANEL_ACTIONS(SIDE) \      EXE(SIDE ## BackAction, ScpExplorer->HistoryGo(os ## SIDE, -1)) \      EXE(SIDE ## ForwardAction, ScpExplorer->HistoryGo(os ## SIDE, 1)) \      EXE(SIDE ## ParentDirAction, DirView(os ## SIDE)->ExecuteParentDirectory()) \      EXE(SIDE ## RootDirAction, DirView(os ## SIDE)->ExecuteRootDirectory()) \      EXE(SIDE ## HomeDirAction, ScpExplorer->HomeDirectory(os ## SIDE)) \      EXE(SIDE ## RefreshAction, DirView(os ## SIDE)->ReloadDirectory()) \      EXE(SIDE ## OpenDirAction, ScpExplorer->OpenDirectory(os ## SIDE)) \      EXE(SIDE ## ChangePathAction, ScpExplorer->ChangePath(os ## SIDE)) \      EXE(SIDE ## AddBookmarkAction, ScpExplorer->AddBookmark(os ## SIDE)) \      EXE(SIDE ## PathToClipboardAction, ScpExplorer->PanelExport(os ## SIDE, pePath, pedClipboard)) \      EXE(SIDE ## FilterAction, ScpExplorer->Filter(os ## SIDE))    PANEL_ACTIONS(Local)    PANEL_ACTIONS(Remote)    #undef PANEL_ACTIONS    EXE(LocalExploreDirectoryAction, ScpExplorer->ExploreLocalDirectory())    //HELP    EXE(AboutAction, DoAboutDialog(Configuration))    EXE(HomepageAction, OpenBrowser(LoadStr(HOMEPAGE_URL)))    EXE(HistoryPageAction, OpenBrowser(LoadStr(HISTORY_URL)))    EXE(TableOfContentsAction, Application->HelpSystem->ShowTableOfContents())    EXE(ForumPageAction, OpenBrowser(LoadStr(FORUM_URL)))    EXE(CheckForUpdatesAction, CheckForUpdates(false))    EXE(UpdatesPreferencesAction, PreferencesDialog(pmUpdates))    EXE(DonatePageAction, OpenBrowser(LoadStr(DONATE_URL)))    EXE(DownloadPageAction, OpenBrowser(LoadStr(DOWNLOAD_URL)))    EXE(TipsAction, ShowTips())    // VIEW    EXECOMP(SessionsTabs)    EXECOMP(StatusBar)    EXECOMP(ToolBar2)    EXECOMP(LocalStatusBar)    EXECOMP(RemoteStatusBar)    EXECOMP(ExplorerMenuBand)    EXECOMP(ExplorerAddressBand)    EXECOMP(ExplorerToolbarBand)    EXECOMP(ExplorerSelectionBand)    EXECOMP(ExplorerSessionBand)    EXECOMP(ExplorerPreferencesBand)    EXECOMP(ExplorerSortBand)    EXECOMP(ExplorerUpdatesBand)    EXECOMP(ExplorerTransferBand)    EXECOMP(ExplorerCustomCommandsBand)    EXECOMP(CommanderMenuBand)    EXECOMP(CommanderSessionBand)    EXECOMP(CommanderPreferencesBand)    EXECOMP(CommanderSortBand)    EXECOMP(CommanderCommandsBand)    EXECOMP(CommanderUpdatesBand)    EXECOMP(CommanderTransferBand)    EXECOMP(CommanderCustomCommandsBand)    EXECOMP(CommanderLocalHistoryBand)    EXECOMP(CommanderLocalNavigationBand)    EXECOMP(CommanderLocalFileBand)    EXECOMP(CommanderLocalSelectionBand)    EXECOMP(CommanderRemoteHistoryBand)    EXECOMP(CommanderRemoteNavigationBand)    EXECOMP(CommanderRemoteFileBand)    EXECOMP(CommanderRemoteSelectionBand)    EXECOMP(CommandLinePanel)    EXECOMP(RemoteTree)    EXECOMP(LocalTree)    EXE(GoToCommandLineAction, ScpExplorer->GoToCommandLine())    EXE(GoToTreeAction, ScpExplorer->GoToTree())    EXE(ViewLogAction, WinConfiguration->LogView =      (WinConfiguration->LogView == lvNone ? lvWindow : lvNone) )    EXE(ShowHiddenFilesAction, ScpExplorer->ToggleShowHiddenFiles())    EXE(FormatSizeBytesNoneAction, ScpExplorer->SetFormatSizeBytes(fbNone))    EXE(FormatSizeBytesKilobytesAction, ScpExplorer->SetFormatSizeBytes(fbKilobytes))    EXE(FormatSizeBytesShortAction, ScpExplorer->SetFormatSizeBytes(fbShort))    EXE(AutoReadDirectoryAfterOpAction, ScpExplorer->ToggleAutoReadDirectoryAfterOp())    EXE(PreferencesAction, PreferencesDialog(::pmDefault) )    EXE(PresetsPreferencesAction, PreferencesDialog(pmPresets) )    EXE(LockToolbarsAction, WinConfiguration->LockToolbars = !WinConfiguration->LockToolbars)    EXE(SelectiveToolbarTextAction, WinConfiguration->SelectiveToolbarText = !WinConfiguration->SelectiveToolbarText)    EXECOMP(CustomCommandsBand)    EXE(ColorMenuAction, CreateSessionColorMenu(ColorMenuAction))    EXE(GoToAddressAction, ScpExplorer->GoToAddress())    #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))    // SORT    EXESORTA(Local)    EXESORT(Local, dv, Name)    EXESORT(Local, dv, Ext)    EXESORT(Local, dv, Size)    EXESORT(Local, dv, Type)    EXESORT(Local, dv, Changed)    EXESORT(Local, dv, Attr)    EXESORTA(Remote)    EXESORT(Remote, uv, Name)    EXESORT(Remote, uv, Ext)    EXESORT(Remote, uv, Size)    EXESORT(Remote, uv, Changed)    EXESORT(Remote, uv, Rights)    EXESORT(Remote, uv, Owner)    EXESORT(Remote, uv, Group)    EXESORT(Remote, uv, Type)    EXESORTA(Current)    EXESORTC(Name, dvName, uvName)    EXESORTC(Ext, dvExt, uvExt)    EXESORTC(Size, dvSize, uvSize)    EXESORTC(Type, dvType, uvType)    EXESORTC(Changed, dvChanged, uvChanged)    EXESORTC(Rights, dvAttr, uvRights)    EXESORTC(Owner, dvName, uvOwner)    EXESORTC(Group, dvName, uvGroup)    EXE(SortColumnAscendingAction, DebugAssert(ListColumn);      COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = true; ListColumn = NULL )    EXE(SortColumnDescendingAction, DebugAssert(ListColumn);      COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = false; ListColumn = NULL )    // SHOW/HIDE COLUMN    EXESHCOL(Local, dv, Name)    EXESHCOL(Local, dv, Ext)    EXESHCOL(Local, dv, Size)    EXESHCOL(Local, dv, Type)    EXESHCOL(Local, dv, Changed)    EXESHCOL(Local, dv, Attr)    EXESHCOL(Remote, uv, Name)    EXESHCOL(Remote, uv, Ext)    EXESHCOL(Remote, uv, Size)    EXESHCOL(Remote, uv, Changed)    EXESHCOL(Remote, uv, Rights)    EXESHCOL(Remote, uv, Owner)    EXESHCOL(Remote, uv, Group)    EXESHCOL(Remote, uv, LinkTarget)    EXESHCOL(Remote, uv, Type)    EXE(HideColumnAction, DebugAssert(ListColumn);      COLVIEWPROPS->Visible[ListColumn->Index] = false; ListColumn = NULL )    EXE(BestFitColumnAction, DebugAssert(ListColumn); ListColumn = NULL ) // TODO    #undef COLVIEWPROPS    // SESSION    EXE(NewSessionAction, ScpExplorer->NewSession(false))    EXE(SiteManagerAction, ScpExplorer->NewSession(true))    EXE(DuplicateSessionAction, ScpExplorer->DuplicateSession())    EXE(CloseSessionAction, ScpExplorer->CloseSession())    EXE(SavedSessionsAction2, CreateSessionListMenu(SavedSessionsAction2))    EXE(WorkspacesAction, CreateWorkspacesMenu(WorkspacesAction))    EXE(OpenedSessionsAction, CreateOpenedSessionListMenu(OpenedSessionsAction))    EXE(SaveCurrentSessionAction2, ScpExplorer->SaveCurrentSession())    EXE(SaveWorkspaceAction, ScpExplorer->SaveWorkspace(false))    // COMMAND    EXE(CompareDirectoriesAction, ScpExplorer->CompareDirectories())    EXE(SynchronizeAction, ScpExplorer->SynchronizeDirectories())    EXE(FullSynchronizeAction, ScpExplorer->FullSynchronizeDirectories())    EXE(ConsoleAction, ScpExplorer->OpenConsole())    EXE(PuttyAction, TTerminalManager::Instance()->OpenInPutty())    EXE(SynchronizeBrowsingAction, ScpExplorer->SynchronizeBrowsingChanged())    EXE(CloseApplicationAction, ScpExplorer->Close())    EXE(FileSystemInfoAction, ScpExplorer->FileSystemInfo())    EXE(SessionGenerateUrlAction2, ScpExplorer->SessionGenerateUrl())    EXE(ClearCachesAction, ScpExplorer->Terminal->ClearCaches())    EXE(NewFileAction, ScpExplorer->EditNew(osCurrent))    EXE(EditorListCustomizeAction, PreferencesDialog(pmEditor))    // CUSTOM COMMANDS    EXE(CustomCommandsFileAction, CreateCustomCommandsMenu(CustomCommandsFileAction, ccltFile))    EXE(CustomCommandsNonFileAction, CreateCustomCommandsMenu(CustomCommandsNonFileAction, ccltNonFile))    EXE(CustomCommandsEnterAction, ScpExplorer->AdHocCustomCommand(false))    EXE(CustomCommandsEnterFocusedAction, ScpExplorer->AdHocCustomCommand(true))    EXE(CustomCommandsLastAction, ScpExplorer->LastCustomCommand(false))    EXE(CustomCommandsLastFocusedAction, ScpExplorer->LastCustomCommand(true))    EXE(CustomCommandsCustomizeAction, PreferencesDialog(pmCustomCommands))    // QUEUE    EXE(QueueEnableAction, ScpExplorer->ToggleQueueEnabled())    #define EXEQUEUE(OPERATION) EXE(Queue ## OPERATION ## Action, \      ScpExplorer->ExecuteQueueOperation(qo ## OPERATION))    EXEQUEUE(GoTo)    EXEQUEUE(Preferences)    EXEQUEUE(ItemQuery)    EXEQUEUE(ItemError)    EXEQUEUE(ItemPrompt)    EXEQUEUE(ItemDelete)    EXEQUEUE(ItemExecute)    EXEQUEUE(ItemPause)    EXEQUEUE(ItemResume)    EXEQUEUE(ItemUp)    EXEQUEUE(ItemDown)    EXEQUEUE(PauseAll)    EXEQUEUE(ResumeAll)    EXEQUEUE(DeleteAll)    EXEQUEUE(DeleteAllDone)    #undef EXEQUEUE    EXE(QueueToggleShowAction, ScpExplorer->ToggleQueueVisibility())    #define QUEUEACTION(SHOW) EXE(Queue ## SHOW ## Action, \      TQueueViewConfiguration Config = WinConfiguration->QueueView; \      if (Config.Show != qvShow) Config.LastHideShow = Config.Show; \      Config.Show = qv ## SHOW; \      WinConfiguration->QueueView = Config)    QUEUEACTION(Show)    QUEUEACTION(HideWhenEmpty)    QUEUEACTION(Hide)    #undef QUEUEACTION    EXE(QueueCycleOnceEmptyAction, CycleQueueOnceEmptyAction())    EXE(QueueIdleOnceEmptyAction, SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction))    EXE(QueueDisconnectOnceEmptyAction2, SetQueueOnceEmptyAction(QueueDisconnectOnceEmptyAction2))    EXE(QueueSuspendOnceEmptyAction2, SetQueueOnceEmptyAction(QueueSuspendOnceEmptyAction2))    EXE(QueueShutDownOnceEmptyAction2, SetQueueOnceEmptyAction(QueueShutDownOnceEmptyAction2))    EXECOMP(QueueToolbar)    EXE(QueueItemSpeedAction, )    ;  }  DoIdle();}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::UpdateNonVisibleActions(){  // following actions needs to be updated even when all clients  // are invisible, so the queue list toolbar button can be shown  NonVisualDataModule->QueueItemQueryAction->Update();  NonVisualDataModule->QueueItemErrorAction->Update();  NonVisualDataModule->QueueItemPromptAction->Update();}//---------------------------------------------------------------------------#define CTRL TShiftState() << ssCtrl#define ALT TShiftState() << ssAlt#define SHIFT TShiftState() << ssShift#define CTRLSHIFT TShiftState() << ssCtrl << ssShift#define CTRLALT TShiftState() << ssCtrl << ssAlt#define NONE TShiftState()void __fastcall TNonVisualDataModule::ExplorerShortcuts(){  // Directory  CurrentCreateDirAction->ShortCut = ShortCut(L'D', CTRL);  // File operation  CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);  CurrentEditAction->ShortCut = ShortCut(L'E', CTRL);  CurrentAddEditLinkAction->ShortCut = ShortCut(L'L', CTRLALT);  CurrentEditInternalAction->ShortCut = 0;  CurrentEditInternalFocusedAction->ShortCut = 0;  // Focused operation  RemoteCopyAction->ShortCut = ShortCut(L'C', CTRL);  RemoteMoveAction->ShortCut = ShortCut(L'M', CTRL);  CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_DELETE, NONE);  CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_RETURN, ALT);  RemoteMoveToFocusedAction->ShortCut = ShortCut(L'M', CTRLALT);  // remote directory  RemoteOpenDirAction->ShortCut = ShortCut(L'O', CTRL);  RemoteRefreshAction->ShortCut = ShortCut(VK_F5, NONE);  RemoteHomeDirAction->ShortCut = ShortCut(L'H', CTRL);  RemotePathToClipboardAction->ShortCut = ShortCut(L'P', CTRLSHIFT);  // selected operation  CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_DELETE, SHIFT);  RemoteMoveToAction->ShortCut = ShortCut(L'M', CTRLALT);  // selection  SelectAction->ShortCut = ShortCut(VK_ADD, NONE);  UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);  SelectAllAction->ShortCut = ShortCut(L'A', CTRL);  InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);  ClearSelectionAction->ShortCut = ShortCut(L'L', CTRLSHIFT);  RestoreSelectionAction->ShortCut = ShortCut(L'R', CTRLSHIFT);  // commands  NewFileAction->ShortCut = ShortCut(L'E', CTRLSHIFT);  RemoteFindFilesAction->ShortCut = ShortCut(VK_F3, NONE);  CloseApplicationAction->ShortCut = ShortCut(VK_F4, ALT);  CloneShortcuts();}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CommanderShortcuts(){  bool ExplorerKeyboardShortcuts = WinConfiguration->ScpCommander.ExplorerKeyboardShortcuts;  // Directory  CurrentCreateDirAction->ShortCut = ShortCut(VK_F7, NONE);  // File operation  CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);  CurrentEditAction->ShortCut = ShortCut(VK_F4, NONE);  CurrentAddEditLinkAction->ShortCut = ShortCut(VK_F6, ALT);  CurrentEditInternalAction->ShortCut = ShortCut(VK_F4, CTRLALT);  CurrentEditInternalFocusedAction->ShortCut = ShortCut(VK_F4, CTRLALT);  // Focused operation  RemoteCopyAction->ShortCut =    ExplorerKeyboardShortcuts ? ShortCut(L'K', CTRL) : ShortCut(VK_F5, NONE);  RemoteMoveAction->ShortCut = ShortCut(VK_F6, NONE);  CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_F8, NONE);  CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_F9, NONE);  RemoteMoveToFocusedAction->ShortCut = ShortCut(VK_F6, SHIFT);  RemoteCopyToFocusedAction->ShortCut = ShortCut(VK_F5, SHIFT);  // remote directory  RemoteOpenDirAction->ShortCut = ShortCut(L'O', CTRL);  RemoteRefreshAction->ShortCut =    ExplorerKeyboardShortcuts ? ShortCut(VK_F5, NONE) : ShortCut(L'R', CTRL);  RemoteHomeDirAction->ShortCut = ShortCut(L'H', CTRL);  RemotePathToClipboardAction->ShortCut = ShortCut(VK_OEM_6 /* ] */, CTRL);  // local directory  LocalPathToClipboardAction->ShortCut = ShortCut(VK_OEM_4 /* [ */, CTRL);  // selected operation  CurrentDeleteAction->SecondaryShortCuts->Clear();  CurrentDeleteAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, NONE)));  CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_F8, SHIFT);  CurrentDeleteAlternativeAction->SecondaryShortCuts->Clear();  CurrentDeleteAlternativeAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, SHIFT)));  RemoteMoveToAction->ShortCut = ShortCut(VK_F6, SHIFT);  RemoteCopyToAction->ShortCut = ShortCut(VK_F5, SHIFT);  // selection  SelectOneAction->ShortCut = VK_INSERT;  SelectAction->ShortCut = ShortCut(VK_ADD, NONE);  UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);  SelectAllAction->ShortCut = ShortCut(L'A', CTRL);  InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);  ClearSelectionAction->ShortCut = ShortCut(L'L', CTRLSHIFT);  RestoreSelectionAction->ShortCut = ShortCut(L'R', CTRLSHIFT);  // commands  NewFileAction->ShortCut = ShortCut(VK_F4, SHIFT);  RemoteFindFilesAction->ShortCut =    ExplorerKeyboardShortcuts ? ShortCut(VK_F3, NONE) : ShortCut(VK_F7, ALT);  // legacy shortcut (can be removed when necessary)  NewFileAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_F4, CTRLSHIFT)));  CloseApplicationAction->ShortCut = ShortCut(VK_F10, NONE);  CloneShortcuts();}#undef CTRL#undef ALT#undef NONE//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CloneShortcuts(){  // Directory  NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;  // File operation  CurrentAddEditLinkContextAction->ShortCut = CurrentAddEditLinkAction->ShortCut;  LocalAddEditLinkAction->ShortCut = CurrentAddEditLinkAction->ShortCut;  RemoteAddEditLinkAction->ShortCut = CurrentAddEditLinkAction->ShortCut;  // local directory  LocalOpenDirAction->ShortCut = RemoteOpenDirAction->ShortCut;  LocalRefreshAction->ShortCut = RemoteRefreshAction->ShortCut;  LocalHomeDirAction->ShortCut = RemoteHomeDirAction->ShortCut;  // selected operation  CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;  CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;  // local selected operation  LocalCopyAction->ShortCut = RemoteCopyAction->ShortCut;  LocalRenameAction->ShortCut = CurrentRenameAction->ShortCut;  LocalEditAction->ShortCut = CurrentEditAction->ShortCut;  LocalMoveAction->ShortCut = RemoteMoveAction->ShortCut;  LocalCreateDirAction->ShortCut = CurrentCreateDirAction->ShortCut;  LocalDeleteAction->ShortCut = CurrentDeleteAction->ShortCut;  LocalPropertiesAction->ShortCut = CurrentPropertiesAction->ShortCut;  // local focused operation  LocalCopyFocusedAction->ShortCut = LocalCopyAction->ShortCut;  LocalMoveFocusedAction->ShortCut = LocalMoveAction->ShortCut;  // remote selected operation  RemoteRenameAction->ShortCut = CurrentRenameAction->ShortCut;  RemoteEditAction->ShortCut = CurrentEditAction->ShortCut;  RemoteCreateDirAction->ShortCut = CurrentCreateDirAction->ShortCut;  RemoteDeleteAction->ShortCut = CurrentDeleteAction->ShortCut;  RemotePropertiesAction->ShortCut = CurrentPropertiesAction->ShortCut;  // remote focused operation  RemoteCopyFocusedAction->ShortCut = RemoteCopyAction->ShortCut;  RemoteMoveFocusedAction->ShortCut = RemoteMoveAction->ShortCut;  // selection  LocalSelectAction->ShortCut = SelectAction->ShortCut;  LocalUnselectAction->ShortCut = UnselectAction->ShortCut;  LocalSelectAllAction->ShortCut = SelectAllAction->ShortCut;  RemoteSelectAction->ShortCut = SelectAction->ShortCut;  RemoteUnselectAction->ShortCut = UnselectAction->ShortCut;  RemoteSelectAllAction->ShortCut = SelectAllAction->ShortCut;}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::SetScpExplorer(TCustomScpExplorerForm * value){  FScpExplorer = value;  SessionIdleTimer->Enabled = (FScpExplorer != NULL);}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::SessionIdleTimerTimer(      TObject */*Sender*/){  DoIdle();}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::DoIdle(){  if (!FSessionIdleTimerExecuting)  {    FSessionIdleTimerExecuting = true;    try    {      DebugAssert(ScpExplorer);      ScpExplorer->Idle();    }    __finally    {      FSessionIdleTimerExecuting = false;    }  }}//---------------------------------------------------------------------------UnicodeString __fastcall TNonVisualDataModule::CustomCommandCaption(const TCustomCommandType * Command, bool Toolbar){  UnicodeString Result = Command->Name;  if (Toolbar)  {    Result = EscapeHotkey(StripHotkey(Result));  }  return Result;}//---------------------------------------------------------------------------UnicodeString __fastcall TNonVisualDataModule::CustomCommandHint(const TCustomCommandType * Command){  UnicodeString Name = StripHotkey(Command->Name);  UnicodeString ShortHint = FMTLOAD(CUSTOM_COMMAND_HINT, (Name));  UnicodeString LongHint =    !Command->Description.IsEmpty() ? Command->Description : FMTLOAD(CUSTOM_COMMAND_HINT_LONG, (Name, Command->Command));  UnicodeString Result = FORMAT(L"%s|%s", (ShortHint, LongHint));  return Result;}//---------------------------------------------------------------------------const int CustomCommandOnFocused = 0x0100;const int CustomCommandBoth = 0x0200;const int CustomCommandExtension = 0x0400;const int CustomCommandIndexMask = 0x00FF;//---------------------------------------------------------------------------int __fastcall TNonVisualDataModule::CreateCustomCommandsListMenu(  TCustomCommandList * List, TTBCustomItem * Menu, bool OnFocused, bool Toolbar, TCustomCommandListType ListType, int Tag){  int Result = 0;  for (int Index = 0; Index < List->Count; Index++)  {    const TCustomCommandType * Command = List->Commands[Index];    int State = ScpExplorer->CustomCommandState(*Command, OnFocused, ListType);    if (State >= 0)    {      TTBCustomItem * Item = new TTBXItem(Owner);      Item->Caption = CustomCommandCaption(Command, Toolbar);      Item->Tag = Index | Tag;      Item->Enabled = (State > 0);      if (OnFocused)      {        Item->Tag = Item->Tag | CustomCommandOnFocused;      }      if (ListType == ccltBoth)      {        Item->Tag = Item->Tag | CustomCommandBoth;      }      Item->Hint = CustomCommandHint(Command);      if (ListType != ccltBoth)      {        Item->ShortCut = Command->ShortCut;      }      Item->OnClick = CustomCommandClick;      Menu->Add(Item);      Result++;    }  }  return Result;}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(  TTBCustomItem * Menu, bool OnFocused, bool Toolbar, TCustomCommandListType ListType){  CreateCustomCommandsListMenu(WinConfiguration->CustomCommandList, Menu, OnFocused, Toolbar, ListType, 0);  TTBCustomItem * Item;  if ((ListType == ccltAll) || (ListType == ccltFile) || (ListType == ccltNonFile))  {    Item = new TTBXItem(Menu);    Item->Action = OnFocused ? CustomCommandsEnterFocusedAction : CustomCommandsEnterAction;    Menu->Add(Item);    Item = new TTBXItem(Menu);    Item->Action = OnFocused ? CustomCommandsLastFocusedAction : CustomCommandsLastAction;    if (Toolbar)    {      Item->Caption = EscapeHotkey(StripHotkey(LoadStr(CUSTOM_COMMAND_LAST_SHORT)));    }    Menu->Add(Item);  }  TTBXSeparatorItem * Separator = AddMenuSeparator(Menu);  int ExtensionItems = CreateCustomCommandsListMenu(WinConfiguration->ExtensionList, Menu, OnFocused, Toolbar, ListType, CustomCommandExtension);  Separator->Visible = (ExtensionItems > 0);  AddMenuSeparator(Menu);  if (((ListType == ccltFile) || ((ListType == ccltNonFile) && !OnFocused)) && DebugAlwaysTrue(!Toolbar))  {    Item = new TTBXSubmenuItem(Menu);    // copy the texts from the action, but do not use is as a handler, because it will duplicate the auxiliary commands in the submenu    Item->Action = (ListType == ccltFile) ? CustomCommandsNonFileAction : CustomCommandsFileAction;    Item->Action = NULL;    TCustomCommandListType SubListType = (ListType == ccltFile) ? ccltNonFile : ccltFile;    CreateCustomCommandsListMenu(WinConfiguration->CustomCommandList, Item, OnFocused, Toolbar, SubListType, 0);    TTBXSeparatorItem * Separator = AddMenuSeparator(Item);    int ExtensionItems = CreateCustomCommandsListMenu(WinConfiguration->ExtensionList, Item, OnFocused, Toolbar, SubListType, CustomCommandExtension);    Separator->Visible = (ExtensionItems > 0);    Menu->Add(Item);  }  if (!Toolbar && (ListType != ccltBoth))  {    Item = new TTBXItem(Menu);    Item->Action = CustomCommandsBandAction;    Menu->Add(Item);  }  Item = new TTBXItem(Menu);  Item->Action = CustomCommandsCustomizeAction;  Menu->Add(Item);}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(  TAction * Action, bool OnFocused, TCustomCommandListType ListType){  DebugAssert(Action);  TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);  if (Menu)  {    int PrevCount = Menu->Count;    CreateCustomCommandsMenu(Menu, OnFocused, false, ListType);    for (int Index = 0; Index < PrevCount; Index++)    {      Menu->Delete(0);    }  }}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(TAction * Action, TCustomCommandListType ListType){  TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);  if (DebugAlwaysTrue(Menu != NULL))  {    bool OnFocused =      (Menu == RemoteDirViewPopupCustomCommandsMenu) || (Menu == LocalFilePopupCustomCommandsMenu) || (Menu == RemoteFilePopupCustomCommandsMenu);    CreateCustomCommandsMenu(Action, OnFocused, ListType);  }}//---------------------------------------------------------------------------bool __fastcall TNonVisualDataModule::CheckCustomCommandsToolbarList(TTBXToolbar * Toolbar, TCustomCommandList * List, int & Index){  bool Changed = false;  int CommandIndex = 0;  while (!Changed && (CommandIndex < List->Count))  {    TTBCustomItem * Item = Toolbar->Items->Items[Index];    const TCustomCommandType * Command = List->Commands[CommandIndex];    Changed =      (Item->Caption != CustomCommandCaption(Command, true)) ||      (Item->Hint != CustomCommandHint(Command));    Index++;    CommandIndex++;  }  return Changed;}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::UpdateCustomCommandsToolbarList(TTBXToolbar * Toolbar, TCustomCommandList * List, int & Index){  for (int CommandIndex = 0; CommandIndex < List->Count; CommandIndex++, Index++)  {    TTBCustomItem * Item = Toolbar->Items->Items[Index];    DebugAssert((Item->Tag & CustomCommandIndexMask) == CommandIndex);    int State = ScpExplorer->CustomCommandState(*List->Commands[CommandIndex], false, ccltAll);    DebugAssert(State >= 0);    Item->Enabled = (State > 0);  }}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::UpdateCustomCommandsToolbar(TTBXToolbar * Toolbar){  // can be called while explorer is being created  if (ScpExplorer == NULL)  {    return;  }  TCustomCommandList * CustomCommandList = WinConfiguration->CustomCommandList;  TCustomCommandList * ExtensionList = WinConfiguration->ExtensionList;  int AfterCustomCommandsCommandCount = 2; // ad hoc, last  int AdditionalCommands = AfterCustomCommandsCommandCount + 3; // custom/ext separator + separator, customize  int CommandCount = CustomCommandList->Count + ExtensionList->Count;  bool Changed = (CommandCount + AdditionalCommands != Toolbar->Items->Count);  if (!Changed)  {    int Index = 0;    Changed = CheckCustomCommandsToolbarList(Toolbar, CustomCommandList, Index);    if (!Changed)    {      Index += AfterCustomCommandsCommandCount;      Changed = (dynamic_cast<TTBXSeparatorItem *>(Toolbar->Items->Items[Index]) == NULL);      Index++;      if (!Changed)      {        Changed = CheckCustomCommandsToolbarList(Toolbar, ExtensionList, Index);      }    }  }  if (Changed)  {    Toolbar->BeginUpdate();    try    {      Toolbar->Items->Clear();      CreateCustomCommandsMenu(Toolbar->Items, false, true, ccltAll);      DebugAssert(CommandCount + AdditionalCommands == Toolbar->Items->Count);    }    __finally    {      Toolbar->EndUpdate();    }  }  else  {    int Index = 0;    UpdateCustomCommandsToolbarList(Toolbar, CustomCommandList, Index);    Index += AfterCustomCommandsCommandCount + 1;    UpdateCustomCommandsToolbarList(Toolbar, ExtensionList, Index);  }}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CustomCommandClick(TObject * Sender){  TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);  DebugAssert(Item);  const TCustomCommandList * List = FLAGSET(Item->Tag, CustomCommandExtension) ? WinConfiguration->ExtensionList : WinConfiguration->CustomCommandList;  const TCustomCommandType * Command = List->Commands[Item->Tag & CustomCommandIndexMask];  if (FLAGCLEAR(Item->Tag, CustomCommandBoth))  {    ScpExplorer->ExecuteFileOperationCommand(foCustomCommand, osRemote,      FLAGSET(Item->Tag, CustomCommandOnFocused), false, const_cast<TCustomCommandType *>(Command));  }  else  {    ScpExplorer->BothCustomCommand(*Command);  }}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CreateSessionColorMenu(TAction * Action){  if (DebugAlwaysTrue(Action->ActionComponent != NULL))  {    ::CreateSessionColorMenu(Action->ActionComponent, ScpExplorer->SessionColor,      SessionColorChange);  }}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::SessionColorChange(TColor Color){  ScpExplorer->SessionColor = Color;}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CreateSessionListMenu(TAction * Action){  StoredSessions->Load();  CreateSessionListMenuLevel(    dynamic_cast<TTBCustomItem *>(Action->ActionComponent), 0, 0);}//---------------------------------------------------------------------------UnicodeString __fastcall TNonVisualDataModule::GetSessionFolderRoot(  TSessionData * Data, int Level){  UnicodeString Path = Data->Name;  UnicodeString Root;  for (int ALevel = 0; ALevel < Level; ALevel++)  {    Root.Insert(CutToChar(Path, L'/', false) + L'/', Root.Length() + 1);  }  return Root;}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CreateSessionListMenuLevel(  TTBCustomItem * Menu, int Index, int Level){  Menu->Clear();  TTBCustomItem * Item = new TTBXItem(Menu);  UnicodeString Root;  if (Level == 0)  {    Item->Action = SiteManagerAction;    Root = L"";  }  else  {    DebugAssert(Index < StoredSessions->Count);    TSessionData * Data = StoredSessions->Sessions[Index];    Root = GetSessionFolderRoot(Data, Level);    Item->Caption = LoadStr(SAVEDSESSIONFOLDER_THIS_OPEN);    Item->Tag = MAKELONG(Index, Level);    UnicodeString FolderName = Root;    if (DebugAlwaysTrue(!FolderName.IsEmpty() && FolderName[FolderName.Length()] == L'/'))    {      FolderName.Delete(FolderName.Length(), 1);    }    Item->Hint = FMTLOAD(SAVEDSESSIONFOLDER_THIS_HINT, (FolderName));    Item->OnClick = SessionFolderThisItemClick;  }  Menu->Insert(Menu->Count, Item);  AddMenuSeparator(Menu);  int FirstSession = Menu->Count;  UnicodeString PrevName;  while (Index < StoredSessions->Count)  {    TSessionData * Data = StoredSessions->Sessions[Index];    if (!AnsiSameText(Data->Name.SubString(1, Root.Length()), Root))    {      // Sessions are sorted, so no chance further sessions may match      break;    }    else if (!Data->IsWorkspace)    {      UnicodeString Name = Data->Name.SubString(Root.Length() + 1, Data->Name.Length() - Root.Length());      int P = Name.Pos(L'/');      if (P > 0)      {        Name.SetLength(P - 1);      }      if (Name != PrevName)      {        if (P > 0)        {          TTBCustomItem * Item = new TTBXSubmenuItem(Menu);          Item->Caption = Name;          Item->Tag = ((Level + 1) << 16) | Index; // MAKELONG          Item->ImageIndex = SavedSessionsAction2->ImageIndex;          Item->OnClick = SessionFolderItemClick;          Menu->Insert(FirstSession, Item);          FirstSession++;        }        else        {          TTBCustomItem * Item = new TTBXItem(Menu);          Item->Caption = Name;          Item->Tag = Index;          Item->Hint = FMTLOAD(SAVEDSESSION_HINT, (Data->Name));          Item->OnClick = SessionItemClick;          Menu->Insert(Menu->Count, Item);        }        PrevName = Name;      }    }    Index++;  }}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::SessionFolderItemClick(TObject * Sender){  TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);  DebugAssert(Item != NULL);  CreateSessionListMenuLevel(Item, LOWORD(Item->Tag), HIWORD(Item->Tag));}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::SessionFolderThisItemClick(TObject * Sender){  TTBCustomItem * Item = DebugNotNull(dynamic_cast<TTBCustomItem *>(Sender));  int Index = LOWORD(Item->Tag);  int Level = HIWORD(Item->Tag);  UnicodeString Folder = GetSessionFolderRoot(StoredSessions->Sessions[Index], Level);  ScpExplorer->OpenFolderOrWorkspace(Folder);}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::SessionItemClick(TObject * Sender){  DebugAssert(StoredSessions && (((TTBCustomItem *)Sender)->Tag < StoredSessions->Count));  ScpExplorer->OpenStoredSession(StoredSessions->Sessions[((TTBCustomItem *)Sender)->Tag]);}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CreateWorkspacesMenu(TAction * Action){  StoredSessions->Load();  if (!StoredSessions->HasAnyWorkspace())  {    Abort();  }  else  {    TTBCustomItem * Menu =      DebugNotNull(dynamic_cast<TTBCustomItem *>(Action->ActionComponent));    Menu->Clear();    std::unique_ptr<TStrings> Workspaces(StoredSessions->GetWorkspaces());    for (int Index = 0; Index < Workspaces->Count; Index++)    {      TTBCustomItem * Item = new TTBXItem(Menu);      Item->Caption = Workspaces->Strings[Index];      Item->Tag = Index;      Item->Hint = FMTLOAD(WORKSPACE_HINT, (Workspaces->Strings[Index]));      Item->OnClick = WorkspaceItemClick;      Menu->Insert(Menu->Count, Item);    }  }}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::WorkspaceItemClick(TObject * Sender){  std::unique_ptr<TStrings> Workspaces(StoredSessions->GetWorkspaces());  ScpExplorer->OpenFolderOrWorkspace(    Workspaces->Strings[DebugNotNull(dynamic_cast<TTBCustomItem *>(Sender))->Tag]);}//---------------------------------------------------------------------------TShortCut __fastcall TNonVisualDataModule::OpenSessionShortCut(int Index){  if (Index >= 0 && Index < 10)  {    return ShortCut((Word)(Index < 9 ? L'0' + 1 + Index : L'0'),      TShiftState() << ssAlt);  }  else  {    return scNone;  }}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CreateOpenedSessionListMenu(TAction * Action){  TTBCustomItem * OpenedSessionsMenu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);  DebugAssert(OpenedSessionsMenu != NULL);  TTerminalManager * Manager = TTerminalManager::Instance();  TStrings * TerminalList = Manager->TerminalList;  int PrevCount = OpenedSessionsMenu->Count;  for (int Index = 0; Index < TerminalList->Count; Index++)  {    TTerminal * Terminal = dynamic_cast<TTerminal *>(TerminalList->Objects[Index]);    DebugAssert(Terminal);    TTBCustomItem * Item = new TTBXItem(OpenedSessionsMenu);    Item->Caption = TerminalList->Strings[Index];    Item->Tag = int(Terminal);    Item->Hint = FMTLOAD(OPENEDSESSION_HINT, (Item->Caption));    Item->Checked = (Manager->ActiveTerminal == Terminal);    Item->ShortCut = OpenSessionShortCut(Index);    Item->OnClick = OpenedSessionItemClick;    Item->RadioItem = true;    OpenedSessionsMenu->Add(Item);  }  for (int Index = 0; Index < PrevCount; Index++)  {    OpenedSessionsMenu->Delete(0);  }}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::OpenedSessionItemClick(TObject * Sender){  TTerminalManager::Instance()->ActiveTerminal = (TTerminal*)(((TMenuItem *)Sender)->Tag);}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CreateEditorListMenu(TTBCustomItem * Menu, bool OnFocused){  DebugAssert(Menu != NULL);  int PrevCount = Menu->Count;  TTBCustomItem * Item;  Item = new TTBXItem(Menu);  Item->Action = OnFocused ? CurrentEditFocusedAction : CurrentEditAction;  Menu->Add(Item);  AddMenuSeparator(Menu);  Item = new TTBXItem(Menu);  Item->Action = OnFocused ? CurrentEditInternalFocusedAction : CurrentEditInternalAction;  Menu->Add(Item);  AddMenuSeparator(Menu);  TStringList * UsedEditors = CreateSortedStringList();  try  {    const TEditorList * EditorList = WinConfiguration->EditorList;    for (int Index = 0; Index < EditorList->Count; Index++)    {      const TEditorPreferences * Editor = EditorList->Editors[Index];      if ((Editor->Data->Editor == edExternal) &&          (UsedEditors->IndexOf(Editor->Data->ExternalEditor) < 0))      {        UsedEditors->Add(Editor->Data->ExternalEditor);        TTBCustomItem * Item = new TTBXItem(Menu);        Item->Caption = Editor->Name;        Item->Tag = Index;        Item->Hint = FMTLOAD(EXTERNAL_EDITOR_HINT, (Editor->Name));        if (OnFocused)        {          Item->OnClick = EditorItemClickFocused;        }        else        {          Item->OnClick = EditorItemClick;        }        Menu->Add(Item);      }    }    Item = new TTBXItem(Menu);    Item->Action = OnFocused ? CurrentEditWithFocusedAction : CurrentEditWithAction;    Menu->Add(Item);    AddMenuSeparator(Menu);    Item = new TTBXItem(Menu);    Item->Action = EditorListCustomizeAction;    Menu->Add(Item);    for (int Index = 0; Index < PrevCount; Index++)    {      Menu->Delete(0);    }  }  __finally  {    delete UsedEditors;  }}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::DoEditorItemClick(TObject * Sender, bool OnFocused){  int Tag = dynamic_cast<TTBXItem*>(Sender)->Tag;  const TEditorList * EditorList = WinConfiguration->EditorList;  // sanity check  if (Tag < EditorList->Count)  {    ScpExplorer->ExecuteFile(osCurrent, efExternalEditor, EditorList->Editors[Tag]->Data,      true, OnFocused);  }}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::EditorItemClick(TObject * Sender){  DoEditorItemClick(Sender, false);}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::EditorItemClickFocused(TObject * Sender){  DoEditorItemClick(Sender, true);}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::QueuePopupPopup(TObject * /*Sender*/){  TAction * Action = NULL;  switch (ScpExplorer->DefaultQueueOperation())  {    case qoItemQuery:      Action = QueueItemQueryAction;      break;    case qoItemError:      Action = QueueItemErrorAction;      break;    case qoItemPrompt:      Action = QueueItemPromptAction;      break;    case qoItemExecute:      Action = QueueItemExecuteAction;      break;    case qoItemPause:      Action = QueueItemPauseAction;      break;    case qoItemResume:      Action = QueueItemResumeAction;      break;  }  TTBCustomItem * Item;  for (int Index = 0; Index < QueuePopup->Items->Count; Index++)  {    Item = QueuePopup->Items->Items[Index];    TTBItemOptions O = Item->Options;    if ((Action != NULL) && (Item->Action == Action))    {      O << tboDefault;    }    else    {      O >> tboDefault;    }    Item->Options = O;  }  QueueSpeedComboBoxItemUpdate(QueuePopupSpeedComboBoxItem);}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::ShowUpdatesUpdate(){  TUpdatesConfiguration Updates = WinConfiguration->Updates;  unsigned short H, M, S, MS;  DecodeTime(Now(), H, M, S, MS);  int CurrentCompoundVer = Configuration->CompoundVersion;  CheckForUpdatesAction->ImageIndex =    ((Updates.HaveResults && (Updates.Results.ForVersion == CurrentCompoundVer) &&      !Updates.Results.Disabled &&      ((Updates.Results.Critical && !Updates.ShownResults && (MS >= 500)) ||       ((!Updates.Results.Critical || Updates.ShownResults) &&        ((Updates.Results.Version > CurrentCompoundVer) ||         !Updates.Results.Message.IsEmpty())))) ? 80 :     ((int(Updates.Period) <= 0) ? 81 : 63));}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::PreferencesDialog(TPreferencesMode APreferencesMode){  if (ScpExplorer != NULL)  {    ScpExplorer->PreferencesDialog(APreferencesMode);  }  else  {    DoPreferencesDialog(APreferencesMode);  }}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CustomCommandsLastUpdate(TAction * Action){  TCustomCommandType Command;  int State;  bool Defined = ScpExplorer->GetLastCustomCommand(    (Action == CustomCommandsLastFocusedAction), Command, State);  Action->Visible = Defined;  if (Defined)  {    UnicodeString TitleCommand = Command.Command;    int MaxTitleCommandLen = 20;    if (TitleCommand.Length() > MaxTitleCommandLen)    {      TitleCommand = TitleCommand.SubString(1, MaxTitleCommandLen - 3) + Ellipsis;    }    Action->Caption = FMTLOAD(CUSTOM_COMMAND_LAST, (TitleCommand));    Action->Hint = FMTLOAD(CUSTOM_COMMAND_HINT, (Command.Command));    Action->Enabled = (State > 0);  }}//---------------------------------------------------------------------------UnicodeString __fastcall TNonVisualDataModule::QueueItemSpeed(const UnicodeString & Text,  TTBXComboBoxItem * Item){  // Keep in sync with TProgressForm::ItemSpeed  unsigned long Speed = GetSpeedLimit(Text);  ScpExplorer->ExecuteQueueOperation(qoItemSpeed, reinterpret_cast<void*>(Speed));  UnicodeString Result = SetSpeedLimit(Speed);  SaveToHistory(Item->Strings, Result);  CustomWinConfiguration->History[L"SpeedLimit"] = Item->Strings;  return Result;}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::QueuePopupSpeedComboBoxItemItemClick(  TObject * Sender){  TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);  QueueItemSpeedAction->Text = QueueItemSpeed(Item->Text, Item);}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemAcceptText(  TObject * Sender, UnicodeString & NewText, bool & /*Accept*/){  TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);  NewText = QueueItemSpeed(NewText, Item);  QueueItemSpeedAction->Text = NewText;}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItem(TTBXComboBoxItem * Item){  // IDE often looses this link  Item->OnAcceptText = QueueSpeedComboBoxItemAcceptText;  Item->OnItemClick = QueuePopupSpeedComboBoxItemItemClick;}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemUpdate(TTBXComboBoxItem * Item){  CopySpeedLimits(CustomWinConfiguration->History[L"SpeedLimit"], Item->Strings);}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::SetQueueOnceEmptyAction(TAction * Action){  TAction * Current = CurrentQueueOnceEmptyAction();  if (Current != Action)  {    Current->Checked = false;    Action->Checked = true;  }}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::CycleQueueOnceEmptyAction(){  TAction * Current = CurrentQueueOnceEmptyAction();  Current->Checked = false;  if (Current == QueueIdleOnceEmptyAction)  {    QueueDisconnectOnceEmptyAction2->Checked = true;  }  else if (Current == QueueDisconnectOnceEmptyAction2)  {    QueueSuspendOnceEmptyAction2->Checked = true;  }  else if (Current == QueueSuspendOnceEmptyAction2)  {    QueueShutDownOnceEmptyAction2->Checked = true;  }  else if (Current == QueueShutDownOnceEmptyAction2)  {    QueueIdleOnceEmptyAction->Checked = true;  }  else  {    DebugFail();  }}//---------------------------------------------------------------------------TAction * __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyAction(){  TAction * Result;  if (QueueIdleOnceEmptyAction->Checked)  {    Result = QueueIdleOnceEmptyAction;  }  else if (QueueDisconnectOnceEmptyAction2->Checked)  {    Result = QueueDisconnectOnceEmptyAction2;  }  else if (QueueSuspendOnceEmptyAction2->Checked)  {    Result = QueueSuspendOnceEmptyAction2;  }  else if (QueueShutDownOnceEmptyAction2->Checked)  {    Result = QueueShutDownOnceEmptyAction2;  }  else  {    DebugFail();  }  return Result;}//---------------------------------------------------------------------------TOnceDoneOperation __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyOperation(){  TOnceDoneOperation Result;  TBasicAction * Current = CurrentQueueOnceEmptyAction();  if (Current == QueueIdleOnceEmptyAction)  {    Result = odoIdle;  }  else if (Current == QueueDisconnectOnceEmptyAction2)  {    Result = odoDisconnect;  }  else if (Current == QueueSuspendOnceEmptyAction2)  {    Result = odoSuspend;  }  else if (Current == QueueShutDownOnceEmptyAction2)  {    Result = odoShutDown;  }  else  {    DebugFail();  }  return Result;}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::ResetQueueOnceEmptyOperation(){  SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction);}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::StartBusy(){  FBusy++;}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::EndBusy(){  FBusy--;}//---------------------------------------------------------------------------bool __fastcall TNonVisualDataModule::GetBusy(){  return    (FBusy > 0) ||    ((ScpExplorer != NULL) && ScpExplorer->IsBusy());}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::FocusedEditMenuItemPopup(TTBCustomItem * Sender,  bool /*FromLink*/){  CreateEditorListMenu(Sender, true);}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::EditMenuItemPopup(TTBCustomItem * Sender,  bool /*FromLink*/){  CreateEditorListMenu(Sender, false);}//---------------------------------------------------------------------------void __fastcall TNonVisualDataModule::QueuePopupSpeedComboBoxItemAdjustImageIndex(  TTBXComboBoxItem * Sender, const UnicodeString /*AText*/, int /*AIndex*/, int & ImageIndex){  // Use fixed image (do not change image by item index)  ImageIndex = Sender->ImageIndex;}//---------------------------------------------------------------------------
 |