HANDLE FileList::OpenPluginForFile(const string* FileName, DWORD FileAttr, OPENFILEPLUGINTYPE Type) { HANDLE Result = nullptr; if(FileName && *FileName && !(FileAttr&FILE_ATTRIBUTE_DIRECTORY)) { SetCurPath(); _ALGO(SysLog(L"close AnotherPanel file")); CtrlObject->Cp()->GetAnotherPanel(this)->CloseFile(); _ALGO(SysLog(L"call Plugins.OpenFilePlugin {")); Result = CtrlObject->Plugins->OpenFilePlugin(FileName, 0, Type); _ALGO(SysLog(L"}")); } return Result; }
/* $ 12.04.2002 IS PluginPutFilesToAnother теперь int - возвращает то, что возвращает PutFiles: -1 - прервано пользовтелем 0 - неудача 1 - удача 2 - удача, курсор принудительно установлен на файл и заново его устанавливать не нужно (см. PluginPutFilesToNew) */ int FileList::PluginPutFilesToAnother(int Move,Panel *AnotherPanel) { if (AnotherPanel->GetMode()!=PLUGIN_PANEL) return 0; FileList *AnotherFilePanel=(FileList *)AnotherPanel; PluginPanelItem *ItemList; int ItemNumber,PutCode=0; SaveSelection(); CreatePluginItemList(ItemList,ItemNumber); if (ItemList && ItemNumber>0) { SetCurPath(); _ALGO(SysLog(L"call Plugins.PutFiles")); PutCode=CtrlObject->Plugins->PutFiles(AnotherFilePanel->hPlugin,ItemList,ItemNumber,Move!=0,0); if (PutCode==1 || PutCode==2) { if (!ReturnCurrentFile) { _ALGO(SysLog(L"call ClearSelection()")); ClearSelection(); } _ALGO(SysLog(L"call PutDizToPlugin")); PutDizToPlugin(AnotherFilePanel,ItemList,ItemNumber,FALSE,Move,&Diz,&AnotherFilePanel->Diz); AnotherPanel->SetPluginModified(); } else if (!ReturnCurrentFile) PluginClearSelection(ItemList,ItemNumber); _ALGO(SysLog(L"call DeletePluginItemList")); DeletePluginItemList(ItemList,ItemNumber); Update(UPDATE_KEEP_SELECTION); Redraw(); if (AnotherPanel==CtrlObject->Cp()->GetAnotherPanel(this)) { AnotherPanel->Update(UPDATE_KEEP_SELECTION); AnotherPanel->Redraw(); } } return PutCode; }
/* Функция для вызова команды "Архивные команды" (Shift-F3) */ void FileList::ProcessHostFile() { _ALGO(CleverSysLog clv(L"FileList::ProcessHostFile()")); //_ALGO(SysLog(L"FileName='%s'",(FileName?FileName:"(nullptr)"))); if (FileCount>0 && SetCurPath()) { int Done=FALSE; SaveSelection(); if (PanelMode==PLUGIN_PANEL && !(*PluginsList.Last())->strHostFile.IsEmpty()) { PluginPanelItem *ItemList; int ItemNumber; _ALGO(SysLog(L"call CreatePluginItemList")); CreatePluginItemList(ItemList,ItemNumber); _ALGO(SysLog(L"call Plugins.ProcessHostFile")); Done=CtrlObject->Plugins->ProcessHostFile(hPlugin,ItemList,ItemNumber,0); if (Done) SetPluginModified(); else { if (!ReturnCurrentFile) PluginClearSelection(ItemList,ItemNumber); Redraw(); } _ALGO(SysLog(L"call DeletePluginItemList")); DeletePluginItemList(ItemList,ItemNumber); if (Done) ClearSelection(); } else { size_t SCount=GetRealSelCount(); if (SCount > 0) { for (int I=0; I < FileCount; ++I) { if (ListData[I]->Selected) { Done=ProcessOneHostFile(I); if (Done == 1) Select(ListData[I],0); else if (Done == -1) continue; else // Если ЭТО убрать, то... будем жать ESC до потере пулься break; // } } if (SelectedFirst) SortFileList(TRUE); } else { if ((Done=ProcessOneHostFile(CurFile)) == 1) ClearSelection(); } } if (Done) { Update(UPDATE_KEEP_SELECTION); Redraw(); Panel *AnotherPanel=CtrlObject->Cp()->GetAnotherPanel(this); AnotherPanel->Update(UPDATE_KEEP_SELECTION|UPDATE_SECONDARY); AnotherPanel->Redraw(); } } }
void FileList::ReadFileNames(int KeepSelection, int IgnoreVisible, int DrawMessage) { TPreRedrawFuncGuard preRedrawFuncGuard(PR_ReadFileNamesMsg); TaskBar TB(false); strOriginalCurDir=strCurDir; if (!IsVisible() && !IgnoreVisible) { UpdateRequired=TRUE; UpdateRequiredMode=KeepSelection; return; } UpdateRequired=FALSE; AccessTimeUpdateRequired=FALSE; DizRead=FALSE; FAR_FIND_DATA_EX fdata; FileListItem *CurPtr=0,**OldData=0; string strCurName, strNextCurName; int OldFileCount=0; StopFSWatcher(); if (this!=CtrlObject->Cp()->LeftPanel && this!=CtrlObject->Cp()->RightPanel) return; string strSaveDir; apiGetCurrentDirectory(strSaveDir); { string strOldCurDir = strCurDir; if (!SetCurPath()) { FlushInputBuffer(); // Очистим буффер ввода, т.к. мы уже можем быть в другом месте... if (!StrCmp(strCurDir, strOldCurDir)) //?? i?? { GetPathRoot(strOldCurDir,strOldCurDir); if (!apiIsDiskInDrive(strOldCurDir)) IfGoHome(strOldCurDir.At(0)); /* При смене каталога путь не изменился */ } return; } } SortGroupsRead=FALSE; if (GetFocus()) CtrlObject->CmdLine->SetCurDir(strCurDir); LastCurFile=-1; Panel *AnotherPanel=CtrlObject->Cp()->GetAnotherPanel(this); AnotherPanel->QViewDelTempName(); size_t PrevSelFileCount=SelFileCount; SelFileCount=0; SelFileSize=0; TotalFileCount=0; TotalFileSize=0; CacheSelIndex=-1; CacheSelClearIndex=-1; if (Opt.ShowPanelFree) { unsigned __int64 TotalSize,TotalFree; if (!apiGetDiskSize(strCurDir,&TotalSize,&TotalFree,&FreeDiskSize)) FreeDiskSize=0; } if (FileCount>0) { strCurName = ListData[CurFile]->strName; if (ListData[CurFile]->Selected) { for (int i=CurFile+1; i < FileCount; i++) { CurPtr = ListData[i]; if (!CurPtr->Selected) { strNextCurName = CurPtr->strName; break; } } } } if (KeepSelection || PrevSelFileCount>0) { OldData=ListData; OldFileCount=FileCount; } else DeleteListData(ListData,FileCount); ListData=nullptr; int ReadOwners=IsColumnDisplayed(OWNER_COLUMN); int ReadNumLinks=IsColumnDisplayed(NUMLINK_COLUMN); int ReadNumStreams=IsColumnDisplayed(NUMSTREAMS_COLUMN); int ReadStreamsSize=IsColumnDisplayed(STREAMSSIZE_COLUMN); string strComputerName; if (ReadOwners) { CurPath2ComputerName(strCurDir, strComputerName); // сбросим кэш SID`ов SIDCacheFlush(); } SetLastError(ERROR_SUCCESS); int AllocatedCount=0; FileListItem *NewPtr; // сформируем заголовок вне цикла wchar_t Title[2048]; int TitleLength=Min((int)X2-X1-1,(int)(ARRAYSIZE(Title))-1); //wmemset(Title,0x0CD,TitleLength); //BUGBUG //Title[TitleLength]=0; MakeSeparator(TitleLength, Title, 9, nullptr); BOOL IsShowTitle=FALSE; BOOL NeedHighlight=Opt.Highlight && PanelMode != PLUGIN_PANEL; if (!Filter) Filter=new FileFilter(this,FFT_PANEL); //Рефреш текущему времени для фильтра перед началом операции Filter->UpdateCurrentTime(); CtrlObject->HiFiles->UpdateCurrentTime(); bool bCurDirRoot = false; ParsePath(strCurDir, nullptr, &bCurDirRoot); PATH_TYPE Type = ParsePath(strCurDir, nullptr, &bCurDirRoot); bool NetRoot = bCurDirRoot && (Type == PATH_REMOTE || Type == PATH_REMOTEUNC); FileCount = 0; string strFind = strCurDir; AddEndSlash(strFind); strFind+=L'*'; ::FindFile Find(strFind, true); DWORD FindErrorCode = ERROR_SUCCESS; bool UseFilter=Filter->IsEnabledOnPanel(); bool ReadCustomData=IsColumnDisplayed(CUSTOM_COLUMN0)!=0; DWORD StartTime = GetTickCount(); while (Find.Get(fdata)) { FindErrorCode = GetLastError(); if ((Opt.ShowHidden || !(fdata.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))) && (!UseFilter || Filter->FileInFilter(fdata, nullptr, &fdata.strFileName))) { if (FileCount>=AllocatedCount) { AllocatedCount+=4096; FileListItem **pTemp; if (!(pTemp=(FileListItem **)xf_realloc(ListData,AllocatedCount*sizeof(*ListData)))) break; ListData=pTemp; } ListData[FileCount] = new FileListItem; ListData[FileCount]->Clear(); NewPtr=ListData[FileCount]; NewPtr->FileAttr = fdata.dwFileAttributes; NewPtr->CreationTime = fdata.ftCreationTime; NewPtr->AccessTime = fdata.ftLastAccessTime; NewPtr->WriteTime = fdata.ftLastWriteTime; NewPtr->ChangeTime = fdata.ftChangeTime; NewPtr->FileSize = fdata.nFileSize; NewPtr->AllocationSize = fdata.nAllocationSize; NewPtr->strName = fdata.strFileName; NewPtr->strShortName = fdata.strAlternateFileName; NewPtr->Position=FileCount++; NewPtr->NumberOfLinks=1; if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { NewPtr->ReparseTag=fdata.dwReserved0; //MSDN } if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { TotalFileSize += NewPtr->FileSize; if (ReadNumLinks) NewPtr->NumberOfLinks=GetNumberOfLinks(fdata.strFileName); } else { NewPtr->AllocationSize = 0; } NewPtr->SortGroup=DEFAULT_SORT_GROUP; if (ReadOwners) { string strOwner; GetFileOwner(strComputerName, NewPtr->strName,strOwner); NewPtr->strOwner = strOwner; } NewPtr->NumberOfStreams=NewPtr->FileAttr&FILE_ATTRIBUTE_DIRECTORY?0:1; NewPtr->StreamsSize=NewPtr->FileSize; if (ReadNumStreams||ReadStreamsSize) { EnumStreams(TestParentFolderName(fdata.strFileName)?strCurDir:fdata.strFileName,NewPtr->StreamsSize,NewPtr->NumberOfStreams); } if (ReadCustomData) CtrlObject->Plugins->GetCustomData(NewPtr); if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) TotalFileCount++; //memcpy(ListData+FileCount,&NewPtr,sizeof(NewPtr)); // FileCount++; DWORD CurTime = GetTickCount(); if (CurTime - StartTime > RedrawTimeout) { StartTime = CurTime; if (IsVisible()) { if (!IsShowTitle) { if (!DrawMessage) { Text(X1+1,Y1,ColorIndexToColor(COL_PANELBOX),Title); IsShowTitle=TRUE; SetColor(Focus ? COL_PANELSELECTEDTITLE:COL_PANELTITLE); } } LangString strReadMsg(MReadingFiles); strReadMsg << FileCount; if (DrawMessage) { ReadFileNamesMsg(strReadMsg); } else { TruncStr(strReadMsg,TitleLength-2); int MsgLength=(int)strReadMsg.GetLength(); GotoXY(X1+1+(TitleLength-MsgLength-1)/2,Y1); FS<<L" "<<strReadMsg<<L" "; } } if (CheckForEsc()) { break; } } } } if (!(FindErrorCode==ERROR_SUCCESS || FindErrorCode==ERROR_NO_MORE_FILES || FindErrorCode==ERROR_FILE_NOT_FOUND)) Message(MSG_WARNING|MSG_ERRORTYPE,1,MSG(MError),MSG(MReadFolderError),MSG(MOk)); if ((Opt.ShowDotsInRoot || !bCurDirRoot) || (NetRoot && CtrlObject->Plugins->FindPlugin(Opt.KnownIDs.Network))) // NetWork Plugin { if (FileCount>=AllocatedCount) { FileListItem **pTemp; if ((pTemp=(FileListItem **)xf_realloc(ListData,(FileCount+1)*sizeof(*ListData)))) ListData=pTemp; } if (ListData) { ListData[FileCount] = new FileListItem; string TwoDotsOwner; if (ReadOwners) { GetFileOwner(strComputerName,strCurDir,TwoDotsOwner); } FILETIME TwoDotsTimes[4]={}; if(apiGetFindDataEx(strCurDir,fdata)) { TwoDotsTimes[0]=fdata.ftCreationTime; TwoDotsTimes[1]=fdata.ftLastAccessTime; TwoDotsTimes[2]=fdata.ftLastWriteTime; TwoDotsTimes[3]=fdata.ftChangeTime; } AddParentPoint(ListData[FileCount],FileCount,TwoDotsTimes,TwoDotsOwner); FileCount++; } } if (IsColumnDisplayed(DIZ_COLUMN)) ReadDiz(); if (NeedHighlight) { CtrlObject->HiFiles->GetHiColor(ListData, FileCount); } if (AnotherPanel->GetMode()==PLUGIN_PANEL) { HANDLE hAnotherPlugin=AnotherPanel->GetPluginHandle(); PluginPanelItem *PanelData=nullptr; string strPath; size_t PanelCount=0; strPath = strCurDir; AddEndSlash(strPath); if (CtrlObject->Plugins->GetVirtualFindData(hAnotherPlugin,&PanelData,&PanelCount,strPath)) { FileListItem **pTemp; if ((pTemp=(FileListItem **)xf_realloc(ListData,(FileCount+PanelCount)*sizeof(*ListData)))) { ListData=pTemp; for (size_t i=0; i < PanelCount; i++) { CurPtr = ListData[FileCount+i]; PluginPanelItem &pfdata=PanelData[i]; PluginToFileListItem(&PanelData[i],CurPtr); CurPtr->Position=FileCount; TotalFileSize += pfdata.FileSize; CurPtr->PrevSelected=CurPtr->Selected=0; CurPtr->ShowFolderSize=0; CurPtr->SortGroup=CtrlObject->HiFiles->GetGroup(CurPtr); if (!TestParentFolderName(pfdata.FileName) && !(CurPtr->FileAttr & FILE_ATTRIBUTE_DIRECTORY)) TotalFileCount++; } // цветовую боевую раскраску в самом конце, за один раз CtrlObject->HiFiles->GetHiColor(&ListData[FileCount],PanelCount); FileCount+=static_cast<int>(PanelCount); } CtrlObject->Plugins->FreeVirtualFindData(hAnotherPlugin,PanelData,PanelCount); } } InitFSWatcher(false); CorrectPosition(); if (KeepSelection || PrevSelFileCount>0) { MoveSelection(ListData,FileCount,OldData,OldFileCount); DeleteListData(OldData,OldFileCount); } if (SortGroups) ReadSortGroups(false); if (!KeepSelection && PrevSelFileCount>0) { SaveSelection(); ClearSelection(); } SortFileList(FALSE); if (CurFile>=FileCount || StrCmpI(ListData[CurFile]->strName,strCurName)) if (!GoToFile(strCurName) && !strNextCurName.IsEmpty()) GoToFile(strNextCurName); /* $ 13.02.2002 DJ SetTitle() - только если мы текущий фрейм! */ if (CtrlObject->Cp() == FrameManager->GetCurrentFrame()) SetTitle(); FarChDir(strSaveDir); //??? }
void FileList::ReadFileNames(int KeepSelection, int UpdateEvenIfPanelInvisible, int DrawMessage) { SCOPED_ACTION(TPreRedrawFuncGuard)(std::make_unique<FileListPreRedrawItem>()); SCOPED_ACTION(TaskBar)(false); strOriginalCurDir = strCurDir; if (!IsVisible() && !UpdateEvenIfPanelInvisible) { UpdateRequired=TRUE; UpdateRequiredMode=KeepSelection; return; } UpdateRequired=FALSE; AccessTimeUpdateRequired=FALSE; DizRead=FALSE; api::FAR_FIND_DATA fdata; decltype(ListData) OldData; string strCurName, strNextCurName; StopFSWatcher(); if (this!=Global->CtrlObject->Cp()->LeftPanel && this!=Global->CtrlObject->Cp()->RightPanel) return; string strSaveDir; api::GetCurrentDirectory(strSaveDir); { string strOldCurDir(strCurDir); if (!SetCurPath()) { FlushInputBuffer(); // Очистим буффер ввода, т.к. мы уже можем быть в другом месте... if (strCurDir == strOldCurDir) //?? i?? { GetPathRoot(strOldCurDir,strOldCurDir); if (!api::IsDiskInDrive(strOldCurDir)) IfGoHome(strOldCurDir.front()); /* При смене каталога путь не изменился */ } return; } } SortGroupsRead=FALSE; if (GetFocus()) Global->CtrlObject->CmdLine->SetCurDir(strCurDir); LastCurFile=-1; Panel *AnotherPanel=Global->CtrlObject->Cp()->GetAnotherPanel(this); AnotherPanel->QViewDelTempName(); size_t PrevSelFileCount=SelFileCount; SelFileCount=0; SelFileSize=0; TotalFileCount=0; TotalFileSize=0; CacheSelIndex=-1; CacheSelClearIndex=-1; FreeDiskSize = -1; if (Global->Opt->ShowPanelFree) { api::GetDiskSize(strCurDir, nullptr, nullptr, &FreeDiskSize); } if (!ListData.empty()) { strCurName = ListData[CurFile].strName; if (ListData[CurFile].Selected && !ReturnCurrentFile) { for (size_t i=CurFile+1; i < ListData.size(); i++) { if (!ListData[i].Selected) { strNextCurName = ListData[i].strName; break; } } } } if (KeepSelection || PrevSelFileCount>0) { OldData.swap(ListData); } else DeleteListData(ListData); DWORD FileSystemFlags = 0; string PathRoot; GetPathRoot(strCurDir, PathRoot); api::GetVolumeInformation(PathRoot, nullptr, nullptr, nullptr, &FileSystemFlags, nullptr); ListData.clear(); bool ReadOwners = IsColumnDisplayed(OWNER_COLUMN); bool ReadNumLinks = IsColumnDisplayed(NUMLINK_COLUMN); bool ReadNumStreams = IsColumnDisplayed(NUMSTREAMS_COLUMN); bool ReadStreamsSize = IsColumnDisplayed(STREAMSSIZE_COLUMN); if (!(FileSystemFlags&FILE_SUPPORTS_HARD_LINKS) && IsWindows7OrGreater()) { ReadNumLinks = false; } if(!(FileSystemFlags&FILE_NAMED_STREAMS)) { ReadNumStreams = false; ReadStreamsSize = false; } string strComputerName; if (ReadOwners) { string strTemp; CurPath2ComputerName(strCurDir, strComputerName, strTemp); } SetLastError(ERROR_SUCCESS); // сформируем заголовок вне цикла string Title = MakeSeparator(X2-X1-1, 9, nullptr); BOOL IsShowTitle=FALSE; BOOL NeedHighlight=Global->Opt->Highlight && PanelMode != PLUGIN_PANEL; if (!Filter) Filter = std::make_unique<FileFilter>(this,FFT_PANEL); //Рефреш текущему времени для фильтра перед началом операции Filter->UpdateCurrentTime(); Global->CtrlObject->HiFiles->UpdateCurrentTime(); bool bCurDirRoot = false; ParsePath(strCurDir, nullptr, &bCurDirRoot); PATH_TYPE Type = ParsePath(strCurDir, nullptr, &bCurDirRoot); bool NetRoot = bCurDirRoot && (Type == PATH_REMOTE || Type == PATH_REMOTEUNC); string strFind(strCurDir); AddEndSlash(strFind); strFind+=L'*'; api::FindFile Find(strFind, true); DWORD FindErrorCode = ERROR_SUCCESS; bool UseFilter=Filter->IsEnabledOnPanel(); bool ReadCustomData=IsColumnDisplayed(CUSTOM_COLUMN0)!=0; DWORD StartTime = GetTickCount(); std::all_of(CONST_RANGE(Find, fdata) -> bool { Global->CatchError(); FindErrorCode = Global->CaughtError(); if ((Global->Opt->ShowHidden || !(fdata.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))) && (!UseFilter || Filter->FileInFilter(fdata, nullptr, &fdata.strFileName))) { if (ListData.size() == ListData.capacity()) ListData.reserve(ListData.size() + 4096); ListData.emplace_back(VALUE_TYPE(ListData)()); auto& NewItem = ListData.back(); NewItem.FileAttr = fdata.dwFileAttributes; NewItem.CreationTime = fdata.ftCreationTime; NewItem.AccessTime = fdata.ftLastAccessTime; NewItem.WriteTime = fdata.ftLastWriteTime; NewItem.ChangeTime = fdata.ftChangeTime; NewItem.FileSize = fdata.nFileSize; NewItem.AllocationSize = fdata.nAllocationSize; NewItem.strName = fdata.strFileName; NewItem.strShortName = fdata.strAlternateFileName; NewItem.Position = ListData.size() - 1; NewItem.NumberOfLinks=1; if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { NewItem.ReparseTag=fdata.dwReserved0; //MSDN } if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { TotalFileSize += NewItem.FileSize; if (ReadNumLinks) NewItem.NumberOfLinks = GetNumberOfLinks(fdata.strFileName, true); } else { NewItem.AllocationSize = 0; } NewItem.SortGroup=DEFAULT_SORT_GROUP; if (ReadOwners) { string strOwner; GetFileOwner(strComputerName, NewItem.strName,strOwner); NewItem.strOwner = strOwner; } NewItem.NumberOfStreams=NewItem.FileAttr&FILE_ATTRIBUTE_DIRECTORY?0:1; NewItem.StreamsSize=NewItem.FileSize; if (ReadNumStreams||ReadStreamsSize) { EnumStreams(TestParentFolderName(fdata.strFileName)? strCurDir : fdata.strFileName, NewItem.StreamsSize, NewItem.NumberOfStreams); } if (ReadCustomData) NewItem.strCustomData = Global->CtrlObject->Plugins->GetCustomData(NewItem.strName); if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) TotalFileCount++; DWORD CurTime = GetTickCount(); if (CurTime - StartTime > (DWORD)Global->Opt->RedrawTimeout) { StartTime = CurTime; if (IsVisible()) { if (!IsShowTitle) { if (!DrawMessage) { Text(X1+1,Y1,ColorIndexToColor(COL_PANELBOX),Title); IsShowTitle=TRUE; SetColor(Focus ? COL_PANELSELECTEDTITLE:COL_PANELTITLE); } } LangString strReadMsg(MReadingFiles); strReadMsg << ListData.size(); if (DrawMessage) { ReadFileNamesMsg(strReadMsg); } else { TruncStr(strReadMsg,static_cast<int>(Title.size())-2); int MsgLength=(int)strReadMsg.size(); GotoXY(X1+1+(static_cast<int>(Title.size())-MsgLength-1)/2,Y1); Global->FS << L" "<<strReadMsg<<L" "; } } Global->CtrlObject->Macro.SuspendMacros(true); bool check = CheckForEsc(); Global->CtrlObject->Macro.SuspendMacros(false); if (check) { // break loop return false; } } } return true; });
bool CommandLine::ProcessKey(const Manager::Key& Key) { auto LocalKey = Key; if ((LocalKey()==KEY_CTRLEND || LocalKey()==KEY_RCTRLEND || LocalKey()==KEY_CTRLNUMPAD1 || LocalKey()==KEY_RCTRLNUMPAD1) && (CmdStr.GetCurPos()==CmdStr.GetLength())) { if (LastCmdPartLength==-1) strLastCmdStr = CmdStr.GetString(); auto strStr = strLastCmdStr; const auto CurCmdPartLength = strStr.size(); Global->CtrlObject->CmdHistory->GetSimilar(strStr,LastCmdPartLength); if (LastCmdPartLength==-1) { strLastCmdStr = CmdStr.GetString(); LastCmdPartLength = static_cast<int>(CurCmdPartLength); } { SCOPED_ACTION(SetAutocomplete)(&CmdStr); CmdStr.SetString(strStr); CmdStr.Select(LastCmdPartLength,static_cast<int>(strStr.size())); } Show(); return true; } if (LocalKey() == KEY_UP || LocalKey() == KEY_NUMPAD8) { if (Global->CtrlObject->Cp()->LeftPanel()->IsVisible() || Global->CtrlObject->Cp()->RightPanel()->IsVisible()) return false; LocalKey=KEY_CTRLE; } else if (LocalKey() == KEY_DOWN || LocalKey() == KEY_NUMPAD2) { if (Global->CtrlObject->Cp()->LeftPanel()->IsVisible() || Global->CtrlObject->Cp()->RightPanel()->IsVisible()) return false; LocalKey=KEY_CTRLX; } // $ 25.03.2002 VVM + При погашенных панелях колесом крутим историю if (!Global->CtrlObject->Cp()->LeftPanel()->IsVisible() && !Global->CtrlObject->Cp()->RightPanel()->IsVisible()) { switch (LocalKey()) { case KEY_MSWHEEL_UP: LocalKey = KEY_CTRLE; break; case KEY_MSWHEEL_DOWN: LocalKey = KEY_CTRLX; break; case KEY_MSWHEEL_LEFT: LocalKey = KEY_CTRLS; break; case KEY_MSWHEEL_RIGHT: LocalKey = KEY_CTRLD; break; } } switch (LocalKey()) { case KEY_CTRLE: case KEY_RCTRLE: case KEY_CTRLX: case KEY_RCTRLX: { if (Global->CtrlObject->CmdHistory->IsOnTop()) { m_CurCmdStr = CmdStr.GetString(); } SCOPED_ACTION(SetAutocomplete)(&CmdStr); const auto strStr = LocalKey() == KEY_CTRLE || LocalKey() == KEY_RCTRLE? Global->CtrlObject->CmdHistory->GetPrev() : Global->CtrlObject->CmdHistory->GetNext(); SetString(Global->CtrlObject->CmdHistory->IsOnTop()? m_CurCmdStr : strStr, true); } return true; case KEY_ESC: { // $ 24.09.2000 SVS - Если задано поведение по "Несохранению при Esc", то позицию в хистори не меняем и ставим в первое положение. if (Global->Opt->CmdHistoryRule) Global->CtrlObject->CmdHistory->ResetPosition(); SetString(L"", true); return true; } case KEY_F2: { UserMenu(false); return true; } case KEY_ALTF8: case KEY_RALTF8: { history_record_type Type; string strStr; const auto SelectType = Global->CtrlObject->CmdHistory->Select(msg(lng::MHistoryTitle), L"History"sv, strStr, Type); if (SelectType == HRT_ENTER || SelectType == HRT_SHIFTETNER || SelectType == HRT_CTRLENTER || SelectType == HRT_CTRLALTENTER) { std::unique_ptr<SetAutocomplete> disable; if(SelectType != HRT_CTRLENTER) { disable = std::make_unique<SetAutocomplete>(&CmdStr); } SetString(strStr, true); if (SelectType != HRT_CTRLENTER) { ProcessKey(SelectType == HRT_CTRLALTENTER? Manager::Key(KEY_CTRLALTENTER) : (SelectType == HRT_ENTER? Manager::Key(KEY_ENTER) : Manager::Key(KEY_SHIFTENTER))); } } } return true; case KEY_ALTF10: case KEY_RALTF10: if (!Global->Opt->Tree.TurnOffCompletely) { string strStr; const auto ActivePanel = Global->CtrlObject->Cp()->ActivePanel(); { // TODO: здесь можно добавить проверку, что мы в корне диска и отсутствие файла Tree.Far... FolderTree::create(strStr, MODALTREE_ACTIVE, TRUE, false); } Global->CtrlObject->Cp()->RedrawKeyBar(); if (!strStr.empty()) { ActivePanel->SetCurDir(strStr,true); ActivePanel->Show(); if (ActivePanel->GetType() == panel_type::TREE_PANEL) ActivePanel->ProcessKey(Manager::Key(KEY_ENTER)); } else { // TODO: ... а здесь проверить факт изменения/появления файла Tree.Far и мы опять же в корне (чтобы лишний раз не апдейтить панель) ActivePanel->Update(UPDATE_KEEP_SELECTION); ActivePanel->Redraw(); const auto AnotherPanel = Global->CtrlObject->Cp()->PassivePanel(); if (AnotherPanel->NeedUpdatePanel(ActivePanel.get())) { AnotherPanel->Update(UPDATE_KEEP_SELECTION);//|UPDATE_SECONDARY); AnotherPanel->Redraw(); } } } return true; case KEY_ALTF11: case KEY_RALTF11: ShowViewEditHistory(); Global->CtrlObject->Cp()->Redraw(); return true; case KEY_ALTF12: case KEY_RALTF12: { history_record_type Type; GUID Guid; string strFile, strData, strStr; const auto SelectType = Global->CtrlObject->FolderHistory->Select(msg(lng::MFolderHistoryTitle), L"HistoryFolders"sv, strStr, Type, &Guid, &strFile, &strData); switch(SelectType) { case HRT_ENTER: case HRT_SHIFTETNER: case HRT_CTRLSHIFTENTER: { if (SelectType == HRT_SHIFTETNER) Global->CtrlObject->FolderHistory->SetAddMode(false,2,true); // пусть плагин сам прыгает... ;-) auto Panel = Global->CtrlObject->Cp()->ActivePanel(); if (SelectType == HRT_CTRLSHIFTENTER) Panel = Global->CtrlObject->Cp()->PassivePanel(); //Type==1 - плагиновый путь //Type==0 - обычный путь Panel->ExecShortcutFolder(std::move(strStr), Guid, strFile, strData, true); // Panel may be changed if(SelectType == HRT_CTRLSHIFTENTER) { Panel = Global->CtrlObject->Cp()->ActivePanel(); Panel->SetCurPath(); Panel = Global->CtrlObject->Cp()->PassivePanel(); } else { Panel = Global->CtrlObject->Cp()->ActivePanel(); } Panel->Redraw(); Global->CtrlObject->FolderHistory->SetAddMode(true,2,true); } break; case HRT_CTRLENTER: SetString(strStr, true); break; default: break; } } return true; case KEY_NUMENTER: case KEY_SHIFTNUMENTER: case KEY_ENTER: case KEY_SHIFTENTER: case KEY_CTRLALTENTER: case KEY_RCTRLRALTENTER: case KEY_CTRLRALTENTER: case KEY_RCTRLALTENTER: case KEY_CTRLALTNUMENTER: case KEY_RCTRLRALTNUMENTER: case KEY_CTRLRALTNUMENTER: case KEY_RCTRLALTNUMENTER: { const auto ActivePanel = Global->CtrlObject->Cp()->ActivePanel(); CmdStr.RemoveSelection(); Refresh(); const auto& strStr = CmdStr.GetString(); bool TryExecute = true; if (!strStr.empty()) { ActivePanel->SetCurPath(); if (!(Global->Opt->ExcludeCmdHistory&EXCLUDECMDHISTORY_NOTCMDLINE)) Global->CtrlObject->CmdHistory->AddToHistory(strStr, HR_DEFAULT, nullptr, {}, m_CurDir); TryExecute = !ActivePanel->ProcessPluginEvent(FE_COMMAND, UNSAFE_CSTR(strStr)); } if (TryExecute) { const auto KeyCode = LocalKey(); const auto IsNewWindow = (KeyCode & KEY_SHIFT) != 0; const auto IsRunAs = (KeyCode & KEY_CTRL || KeyCode & KEY_RCTRL) && (KeyCode & KEY_ALT || KeyCode & KEY_RALT); execute_info Info; Info.Command = strStr; Info.NewWindow = IsNewWindow; Info.RunAs = IsRunAs; SetString(L"", false); ExecString(Info); } } return true; case KEY_CTRLU: case KEY_RCTRLU: CmdStr.RemoveSelection(); Refresh(); return true; case KEY_OP_XLAT: { // 13.12.2000 SVS - ! Для CmdLine - если нет выделения, преобразуем всю строку (XLat) CmdStr.Xlat((Global->Opt->XLat.Flags&XLAT_CONVERTALLCMDLINE) != 0); // иначе неправильно работает ctrl-end strLastCmdStr = CmdStr.GetString(); LastCmdPartLength = static_cast<int>(strLastCmdStr.size()); return true; } /* дополнительные клавиши для выделения в ком строке. ВНИМАНИЕ! Для сокращения кода этот кусок должен стоять перед "default" */ case KEY_ALTSHIFTLEFT: case KEY_ALTSHIFTNUMPAD4: case KEY_RALTSHIFTLEFT: case KEY_RALTSHIFTNUMPAD4: case KEY_ALTSHIFTRIGHT: case KEY_ALTSHIFTNUMPAD6: case KEY_RALTSHIFTRIGHT: case KEY_RALTSHIFTNUMPAD6: case KEY_ALTSHIFTEND: case KEY_ALTSHIFTNUMPAD1: case KEY_RALTSHIFTEND: case KEY_RALTSHIFTNUMPAD1: case KEY_ALTSHIFTHOME: case KEY_ALTSHIFTNUMPAD7: case KEY_RALTSHIFTHOME: case KEY_RALTSHIFTNUMPAD7: LocalKey&=~(KEY_ALT|KEY_RALT); [[fallthrough]]; default: // Сбрасываем выделение на некоторых клавишах if (!Global->Opt->CmdLine.EditBlock) { static const unsigned int UnmarkKeys[]= { KEY_LEFT, KEY_NUMPAD4, KEY_CTRLS, KEY_RCTRLS, KEY_RIGHT, KEY_NUMPAD6, KEY_CTRLD, KEY_RCTRLD, KEY_CTRLLEFT, KEY_CTRLNUMPAD4, KEY_RCTRLLEFT, KEY_RCTRLNUMPAD4, KEY_CTRLRIGHT, KEY_CTRLNUMPAD6, KEY_RCTRLRIGHT, KEY_RCTRLNUMPAD6, KEY_CTRLHOME, KEY_CTRLNUMPAD7, KEY_RCTRLHOME, KEY_RCTRLNUMPAD7, KEY_CTRLEND, KEY_CTRLNUMPAD1, KEY_RCTRLEND, KEY_RCTRLNUMPAD1, KEY_HOME, KEY_NUMPAD7, KEY_END, KEY_NUMPAD1 }; if (contains(UnmarkKeys, LocalKey())) { CmdStr.RemoveSelection(); } } if (LocalKey() == KEY_CTRLD || LocalKey() == KEY_RCTRLD) LocalKey=KEY_RIGHT; if(LocalKey() == KEY_CTRLSPACE || LocalKey() == KEY_RCTRLSPACE) { SCOPED_ACTION(SetAutocomplete)(&CmdStr, true); CmdStr.AutoComplete(true,false); return true; } if (!CmdStr.ProcessKey(LocalKey)) return Global->WindowManager->Desktop()->ProcessKey(Key); LastCmdPartLength=-1; return true; } }