void SMaskEdit::ProcessChar(TCHAR nChar) { int nLen = m_strLiteral.GetLength(); if (m_nStartChar >= nLen) { NotifyPosNotInRange(); return; } if (m_nStartChar != m_nEndChar) { MaskDeleteSel(); } ASSERT(m_nStartChar == m_nEndChar); CorrectPosition(m_nStartChar); if (CanOverType()) { m_strWindowText.SetAt(m_nStartChar, nChar); } else { InsertCharAt(m_nStartChar, nChar); } if (m_nStartChar < nLen) m_nStartChar++; CorrectPosition(m_nStartChar); m_nEndChar = m_nStartChar; }
void SMaskEdit::MaskReplaceSel(LPCTSTR lpszNewText) { ASSERT(CanUseMask()); if (m_nStartChar != m_nEndChar) MaskDeleteSel(); int x = m_nStartChar, nNewTextLen = (int)_tcslen(lpszNewText); int nWindowTextLen = m_strWindowText.GetLength(); if (x >= nWindowTextLen) return; for (int i = 0; i < nNewTextLen; ++i) { TCHAR ch = lpszNewText[i]; if (ch == m_chPrompt || CheckChar(ch, x)) { InsertCharAt(x, ch); x++; while (x < nWindowTextLen && !IsPromptPos(x)) x++; if (x >= m_strWindowText.GetLength()) break; } } CorrectPosition(x); m_nStartChar = m_nEndChar = x; }
void FileList::PluginGetPanelInfo(PanelInfo &Info) { CorrectPosition(); Info.CurrentItem=CurFile; Info.TopPanelItem=CurTopFile; if(ShowShortNames) Info.Flags|=PFLAGS_ALTERNATIVENAMES; Info.ItemsNumber=FileCount; Info.SelectedItemsNumber=ListData?GetSelCount():0; }
void SMaskEdit::GetMaskState(BOOL bCorrectSelection) { ASSERT(m_bUseMask); MaskGetSel(); m_strWindowText = GetWindowText(); ASSERT(m_strDefault.GetLength() == m_strLiteral.GetLength()); ASSERT(m_strMask.GetLength() == m_strLiteral.GetLength()); CorrectWindowText(); if (bCorrectSelection) { CorrectPosition(m_nStartChar); CorrectPosition(m_nEndChar); if (m_nEndChar < m_nStartChar) m_nEndChar = m_nStartChar; } }
void SMaskEdit::MaskSelectAll() { if (!CanUseMask()) { SetSel(0, -1); } else { m_nStartChar = 0; CorrectPosition(m_nStartChar); SetSel(m_nStartChar, -1); } }
TerrainMapArea* cRAI::GetCurrentMapArea(sRAIUnitDef* udr, float3& position) { if( udr->mobileType == 0 ) // flying units & buildings return 0; // other mobile units & their factories int iS = TM->GetSectorIndex(position); if( !TM->IsSectorValid(iS) ) { CorrectPosition(position); iS = TM->GetSectorIndex(position); } return udr->mobileType->sector[iS].area; }
void SMaskEdit::OnSetFocus() { __super::OnSetFocus(); if (!CanUseMask()) { return; } MaskGetSel(); CorrectPosition(m_nStartChar); m_nEndChar = m_nStartChar; SetSel(m_nStartChar, m_nEndChar); }
/* DefaultName - имя элемента на которое позиционируемся. Closed - панель закрывается, если в PrevDataList что-то есть - восстанавливаемчся оттуда. UsePrev - если востанавливаемся из PrevDataList, элемент для позиционирования брать оттуда же. Position - надо ли вообще устанавливать текущий элемент. */ void FileList::PopPrevData(const string& DefaultName,bool Closed,bool UsePrev,bool Position,bool SetDirectorySuccess) { string strName(DefaultName); if (Closed && !PrevDataList.Empty()) { PrevDataItem* Item=*PrevDataList.Last(); PrevDataList.Delete(PrevDataList.Last()); if (Item->PrevFileCount>0) { MoveSelection(ListData,FileCount,Item->PrevListData,Item->PrevFileCount); UpperFolderTopFile = Item->PrevTopFile; if (UsePrev) strName = Item->strPrevName; DeleteListData(Item->PrevListData,Item->PrevFileCount); delete Item; if (SelectedFirst) SortFileList(FALSE); else if (FileCount>0) SortFileList(TRUE); } } if (Position) { long Pos=FindFile(PointToName(strName)); if (Pos!=-1) CurFile=Pos; else GoToFile(strName); CurTopFile=UpperFolderTopFile; UpperFolderTopFile=0; CorrectPosition(); } /* $ 26.04.2001 DJ доделка про несброс выделения при неудаче SetDirectory */ else if (SetDirectorySuccess) CurFile=CurTopFile=0; }
void SMaskEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { if (!CanUseMask()) { __super::OnKeyDown(nChar, nRepCnt, nFlags); return; } BOOL bShift = (::GetKeyState(VK_SHIFT) < 0); BOOL bCtrl = (::GetKeyState(VK_CONTROL) < 0); switch (nChar) { case VK_UP: case VK_LEFT: case VK_HOME: { __super::OnKeyDown(nChar, nRepCnt, nFlags); GetMaskState(FALSE); int nStartChar = m_nStartChar; CorrectPosition(nStartChar, FALSE); if (m_nStartChar < nStartChar) { m_nStartChar = nStartChar; if (!bShift) m_nEndChar = nStartChar; } SetMaskState(); } return; case VK_DOWN: case VK_RIGHT: case VK_END: { __super::OnKeyDown(nChar, nRepCnt, nFlags); GetMaskState(FALSE); int iEndChar = m_nEndChar; CorrectPosition(iEndChar); if (m_nEndChar > iEndChar) { m_nEndChar = iEndChar; if (!bShift) m_nStartChar = iEndChar; } SetMaskState(); } return; case VK_INSERT: { if (bCtrl) { MaskCopy(); } else if (bShift) { MaskPaste(); } else { m_bOverType = !m_bOverType; // set the type-over flag } } return; case VK_DELETE: { GetMaskState(); if (m_nStartChar == m_nEndChar) { m_nEndChar = m_nStartChar +1; } else if (bShift) { MaskCopy(); } MaskDeleteSel(); SetMaskState(); } return; case VK_SPACE: { GetMaskState(); if (!PosInRange(m_nStartChar) || !IsPromptPos(m_nStartChar)) { NotifyPosNotInRange(); return; } TCHAR chSpace = _T(' '); if (!ProcessMask(chSpace, m_nStartChar)) chSpace = m_chPrompt; ProcessChar(chSpace); SetMaskState(); } return; case VK_BACK: { GetMaskState(FALSE); if (((m_nStartChar > 0) || (m_nStartChar == 0 && m_nEndChar != 0)) && (m_nStartChar <= m_strLiteral.GetLength())) { if (m_nStartChar == m_nEndChar) { m_nStartChar--; CorrectPosition(m_nStartChar, FALSE); if (m_bOverType && PosInRange(m_nStartChar)) { m_strWindowText.SetAt(m_nStartChar, m_strDefault[m_nStartChar]); m_nEndChar = m_nStartChar; } } MaskDeleteSel(); SetMaskState(); } else { NotifyPosNotInRange(); } } return; } __super::OnKeyDown(nChar, nRepCnt, nFlags); }
void FileList::ShowFileList(int Fast) { if (Locked()) { CorrectPosition(); return; } string strTitle; string strInfoCurDir; int Length; OpenPanelInfo Info; if (PanelMode==PLUGIN_PANEL) { if (ProcessPluginEvent(FE_REDRAW,nullptr)) return; CtrlObject->Plugins->GetOpenPanelInfo(hPlugin,&Info); strInfoCurDir=Info.CurDir; } bool CurFullScreen=IsFullScreen(); PrepareViewSettings(ViewMode,&Info); CorrectPosition(); if (CurFullScreen!=IsFullScreen()) { CtrlObject->Cp()->SetScreenPosition(); CtrlObject->Cp()->GetAnotherPanel(this)->Update(UPDATE_KEEP_SELECTION|UPDATE_SECONDARY); } SetScreen(X1+1,Y1+1,X2-1,Y2-1,L' ',ColorIndexToColor(COL_PANELTEXT)); Box(X1,Y1,X2,Y2,ColorIndexToColor(COL_PANELBOX),DOUBLE_BOX); if (Opt.ShowColumnTitles) { // SetScreen(X1+1,Y1+1,X2-1,Y1+1,' ',COL_PANELTEXT); SetColor(COL_PANELTEXT); //??? //GotoXY(X1+1,Y1+1); //FS<<fmt::Width(X2-X1-1)<<L""; } for (int I=0,ColumnPos=X1+1; I<ViewSettings.ColumnCount; I++) { if (ViewSettings.ColumnWidth[I]<0) continue; if (Opt.ShowColumnTitles) { LNGID IDMessage=MColumnUnknown; switch (ViewSettings.ColumnType[I] & 0xff) { case NAME_COLUMN: IDMessage=MColumnName; break; case EXTENSION_COLUMN: IDMessage=MColumnExtension; break; case SIZE_COLUMN: IDMessage=MColumnSize; break; case PACKED_COLUMN: IDMessage=MColumnAlocatedSize; break; case DATE_COLUMN: IDMessage=MColumnDate; break; case TIME_COLUMN: IDMessage=MColumnTime; break; case WDATE_COLUMN: IDMessage=MColumnWrited; break; case CDATE_COLUMN: IDMessage=MColumnCreated; break; case ADATE_COLUMN: IDMessage=MColumnAccessed; break; case CHDATE_COLUMN: IDMessage=MColumnChanged; break; case ATTR_COLUMN: IDMessage=MColumnAttr; break; case DIZ_COLUMN: IDMessage=MColumnDescription; break; case OWNER_COLUMN: IDMessage=MColumnOwner; break; case NUMLINK_COLUMN: IDMessage=MColumnMumLinks; break; case NUMSTREAMS_COLUMN: IDMessage=MColumnNumStreams; break; case STREAMSSIZE_COLUMN: IDMessage=MColumnStreamsSize; break; } strTitle=MSG(IDMessage); if (PanelMode==PLUGIN_PANEL && Info.PanelModesArray && ViewMode<static_cast<int>(Info.PanelModesNumber) && Info.PanelModesArray[ViewMode].ColumnTitles) { const wchar_t *NewTitle=Info.PanelModesArray[ViewMode].ColumnTitles[I]; if (NewTitle) strTitle=NewTitle; } string strTitleMsg; CenterStr(strTitle,strTitleMsg,ViewSettings.ColumnWidth[I]); SetColor(COL_PANELCOLUMNTITLE); GotoXY(ColumnPos,Y1+1); FS<<fmt::Precision(ViewSettings.ColumnWidth[I])<<strTitleMsg; } if (I>=ViewSettings.ColumnCount-1) break; if (ViewSettings.ColumnWidth[I+1]<0) continue; SetColor(COL_PANELBOX); ColumnPos+=ViewSettings.ColumnWidth[I]; GotoXY(ColumnPos,Y1); bool DoubleLine = Opt.DoubleGlobalColumnSeparator && (!((I+1)%ColumnsInGlobal)); BoxText(BoxSymbols[DoubleLine?BS_T_H2V2:BS_T_H2V1]); if (Opt.ShowColumnTitles) { GotoXY(ColumnPos,Y1+1); BoxText(BoxSymbols[DoubleLine?BS_V2:BS_V1]); } if (!Opt.ShowPanelStatus) { GotoXY(ColumnPos,Y2); BoxText(BoxSymbols[DoubleLine?BS_B_H2V2:BS_B_H2V1]); } ColumnPos++; } int NextX1=X1+1; if (Opt.ShowSortMode) { static int SortModes[]={UNSORTED,BY_NAME,BY_EXT,BY_MTIME,BY_CTIME, BY_ATIME,BY_CHTIME,BY_SIZE,BY_DIZ,BY_OWNER, BY_COMPRESSEDSIZE,BY_NUMLINKS, BY_NUMSTREAMS,BY_STREAMSSIZE, BY_FULLNAME,BY_CUSTOMDATA }; static LNGID SortStrings[]={MMenuUnsorted,MMenuSortByName, MMenuSortByExt,MMenuSortByWrite,MMenuSortByCreation, MMenuSortByAccess,MMenuSortByChange,MMenuSortBySize,MMenuSortByDiz,MMenuSortByOwner, MMenuSortByAllocatedSize,MMenuSortByNumLinks,MMenuSortByNumStreams,MMenuSortByStreamsSize, MMenuSortByFullName,MMenuSortByCustomData }; for (size_t I=0; I<ARRAYSIZE(SortModes); I++) { if (SortModes[I]==SortMode) { const wchar_t *SortStr=MSG(SortStrings[I]); const wchar_t *Ch=wcschr(SortStr,L'&'); if (Ch) { if (Opt.ShowColumnTitles) GotoXY(NextX1,Y1+1); else GotoXY(NextX1,Y1); SetColor(COL_PANELCOLUMNTITLE); OutCharacter[0]=SortOrder==1 ? Lower(Ch[1]):Upper(Ch[1]); Text(OutCharacter); NextX1++; if (Filter && Filter->IsEnabledOnPanel()) { OutCharacter[0]=L'*'; Text(OutCharacter); NextX1++; } } break; } } } /* <режимы сортировки> */ if (/*GetNumericSort() || GetCaseSensitiveSort() || GetSortGroups() || */GetSelectedFirstMode()) { if (Opt.ShowColumnTitles) GotoXY(NextX1,Y1+1); else GotoXY(NextX1,Y1); SetColor(COL_PANELCOLUMNTITLE); wchar_t *PtrOutCharacter=OutCharacter; *PtrOutCharacter=0; //if (GetSelectedFirstMode()) *PtrOutCharacter++=L'^'; /* if(GetNumericSort()) *PtrOutCharacter++=L'#'; if(GetSortGroups()) *PtrOutCharacter++=L'@'; */ /* if(GetCaseSensitiveSort()) { } */ *PtrOutCharacter=0; Text(OutCharacter); PtrOutCharacter[1]=0; } /* </режимы сортировки> */ if (!Fast && GetFocus()) { if (PanelMode==PLUGIN_PANEL) CtrlObject->CmdLine->SetCurDir(Info.CurDir); else CtrlObject->CmdLine->SetCurDir(strCurDir); CtrlObject->CmdLine->Show(); } int TitleX2=Opt.Clock && !Opt.ShowMenuBar ? Min(ScrX-4,X2):X2; int TruncSize=TitleX2-X1-3; if (!Opt.ShowColumnTitles && Opt.ShowSortMode && Filter && Filter->IsEnabledOnPanel()) TruncSize-=2; GetTitle(strTitle,TruncSize,2);//,(PanelMode==PLUGIN_PANEL?0:2)); Length=(int)strTitle.GetLength(); int ClockCorrection=FALSE; if ((Opt.Clock && !Opt.ShowMenuBar) && TitleX2==ScrX-4) { ClockCorrection=TRUE; TitleX2+=4; } int TitleX=X1+(TitleX2-X1+1-Length)/2; if (ClockCorrection) { int Overlap=TitleX+Length-TitleX2+5; if (Overlap > 0) TitleX-=Overlap; } if (TitleX <= X1) TitleX = X1+1; SetColor(Focus ? COL_PANELSELECTEDTITLE:COL_PANELTITLE); GotoXY(TitleX,Y1); Text(strTitle); if (!FileCount) { SetScreen(X1+1,Y2-1,X2-1,Y2-1,L' ',ColorIndexToColor(COL_PANELTEXT)); SetColor(COL_PANELTEXT); //??? //GotoXY(X1+1,Y2-1); //FS<<fmt::Width(X2-X1-1)<<L""; } if (PanelMode==PLUGIN_PANEL && FileCount>0 && (Info.Flags & OPIF_REALNAMES)) { if (!strInfoCurDir.IsEmpty()) { strCurDir = strInfoCurDir; } else { if (!TestParentFolderName(ListData[CurFile]->strName)) { strCurDir=ListData[CurFile]->strName; size_t pos; if (FindLastSlash(pos,strCurDir)) { if (pos) { if (strCurDir.At(pos-1)!=L':') strCurDir.SetLength(pos); else strCurDir.SetLength(pos+1); } } } else { strCurDir = strOriginalCurDir; } } if (GetFocus()) { CtrlObject->CmdLine->SetCurDir(strCurDir); CtrlObject->CmdLine->Show(); } } if ((Opt.ShowPanelTotals || Opt.ShowPanelFree) && (Opt.ShowPanelStatus || !SelFileCount)) { ShowTotalSize(Info); } ShowList(FALSE,0); ShowSelectedSize(); if (Opt.ShowPanelScrollbar) { SetColor(COL_PANELSCROLLBAR); ScrollBarEx(X2,Y1+1+Opt.ShowColumnTitles,Height,Round(CurTopFile,Columns),Round(FileCount,Columns)); } ShowScreensCount(); if (!ProcessingPluginCommand && LastCurFile!=CurFile) { LastCurFile=CurFile; UpdateViewPanel(); } if (PanelMode==PLUGIN_PANEL) CtrlObject->Cp()->RedrawKeyBar(); }
void FileList::UpdatePlugin(int KeepSelection, int IgnoreVisible) { _ALGO(CleverSysLog clv(L"FileList::UpdatePlugin")); _ALGO(SysLog(L"(KeepSelection=%d, IgnoreVisible=%d)",KeepSelection,IgnoreVisible)); if (!IsVisible() && !IgnoreVisible) { UpdateRequired=TRUE; UpdateRequiredMode=KeepSelection; return; } DizRead=FALSE; FileListItem *CurPtr, **OldData=0; string strCurName, strNextCurName; int OldFileCount=0; StopFSWatcher(); LastCurFile=-1; OpenPanelInfo Info; CtrlObject->Plugins->GetOpenPanelInfo(hPlugin,&Info); FreeDiskSize=0; if (Opt.ShowPanelFree) { if (Info.Flags & OPIF_REALNAMES) { unsigned __int64 TotalSize,TotalFree; if (!apiGetDiskSize(strCurDir,&TotalSize,&TotalFree,&FreeDiskSize)) FreeDiskSize=0; } else if (Info.Flags & OPIF_USEFREESIZE) FreeDiskSize=Info.FreeSize; } PluginPanelItem *PanelData=nullptr; size_t PluginFileCount; if (!CtrlObject->Plugins->GetFindData(hPlugin,&PanelData,&PluginFileCount,0)) { DeleteListData(ListData,FileCount); PopPlugin(TRUE); Update(KeepSelection); // WARP> явный хак, но очень способствует - восстанавливает позицию на панели при ошибке чтения архива. if (!PrevDataList.Empty()) GoToFile((*PrevDataList.Last())->strPrevName); return; } size_t PrevSelFileCount=SelFileCount; SelFileCount=0; SelFileSize=0; TotalFileCount=0; TotalFileSize=0; CacheSelIndex=-1; CacheSelClearIndex=-1; strPluginDizName.Clear(); if (FileCount>0) { CurPtr=ListData[CurFile]; strCurName = CurPtr->strName; if (CurPtr->Selected) { for (int i=CurFile+1; i < FileCount; i++) { CurPtr = ListData[i]; if (!CurPtr->Selected) { strNextCurName = CurPtr->strName; break; } } } } else if (Info.Flags & OPIF_ADDDOTS) { strCurName = L".."; } if (KeepSelection || PrevSelFileCount>0) { OldData=ListData; OldFileCount=FileCount; } else { DeleteListData(ListData,FileCount); } FileCount=static_cast<int>(PluginFileCount); ListData=(FileListItem**)xf_malloc(sizeof(FileListItem*)*(FileCount+1)); if (!ListData) { FileCount=0; return; } if (!Filter) Filter=new FileFilter(this,FFT_PANEL); //Рефреш текущему времени для фильтра перед началом операции Filter->UpdateCurrentTime(); CtrlObject->HiFiles->UpdateCurrentTime(); int DotsPresent=FALSE; int FileListCount=0; bool UseFilter=Filter->IsEnabledOnPanel(); for (int i=0; i < FileCount; i++) { ListData[FileListCount] = new FileListItem; FileListItem *CurListData=ListData[FileListCount]; CurListData->Clear(); if (UseFilter && !(Info.Flags & OPIF_DISABLEFILTER)) { //if (!(CurPanelData->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) if (!Filter->FileInFilter(PanelData[i])) continue; } if (!Opt.ShowHidden && (PanelData[i].FileAttributes & (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))) continue; //ClearStruct(*CurListData); PluginToFileListItem(&PanelData[i],CurListData); CurListData->Position=i; if (!(Info.Flags & OPIF_DISABLESORTGROUPS)/* && !(CurListData->FileAttr & FILE_ATTRIBUTE_DIRECTORY)*/) CurListData->SortGroup=CtrlObject->HiFiles->GetGroup(CurListData); else CurListData->SortGroup=DEFAULT_SORT_GROUP; if (!CurListData->DizText) { CurListData->DeleteDiz=FALSE; //CurListData->DizText=nullptr; } if (TestParentFolderName(CurListData->strName)) { DotsPresent=TRUE; CurListData->FileAttr|=FILE_ATTRIBUTE_DIRECTORY; } else if (!(CurListData->FileAttr & FILE_ATTRIBUTE_DIRECTORY)) { TotalFileCount++; } TotalFileSize += CurListData->FileSize; FileListCount++; } if (!(Info.Flags & OPIF_DISABLEHIGHLIGHTING) || (Info.Flags & OPIF_USEATTRHIGHLIGHTING)) CtrlObject->HiFiles->GetHiColor(ListData,FileListCount,(Info.Flags&OPIF_USEATTRHIGHLIGHTING)!=0); FileCount=FileListCount; if ((Info.Flags & OPIF_ADDDOTS) && !DotsPresent) { ListData[FileCount] = new FileListItem; CurPtr = ListData[FileCount]; CurPtr->Clear(); AddParentPoint(CurPtr,FileCount); if (!(Info.Flags & OPIF_DISABLEHIGHLIGHTING) || (Info.Flags & OPIF_USEATTRHIGHLIGHTING)) CtrlObject->HiFiles->GetHiColor(&CurPtr,1,(Info.Flags&OPIF_USEATTRHIGHLIGHTING)!=0); if (Info.HostFile && *Info.HostFile) { FAR_FIND_DATA_EX FindData; if (apiGetFindDataEx(Info.HostFile, FindData)) { CurPtr->WriteTime=FindData.ftLastWriteTime; CurPtr->CreationTime=FindData.ftCreationTime; CurPtr->AccessTime=FindData.ftLastAccessTime; CurPtr->ChangeTime=FindData.ftChangeTime; } } FileCount++; } if (CurFile >= FileCount) CurFile = FileCount ? FileCount-1 : 0; /* $ 25.02.2001 VVM ! Не считывать повторно список файлов с панели плагина */ if (IsColumnDisplayed(DIZ_COLUMN)) ReadDiz(PanelData,static_cast<int>(PluginFileCount),RDF_NO_UPDATE); CorrectPosition(); CtrlObject->Plugins->FreeFindData(hPlugin,PanelData,PluginFileCount); if (KeepSelection || PrevSelFileCount>0) { MoveSelection(ListData,FileCount,OldData,OldFileCount); DeleteListData(OldData,OldFileCount); } if (!KeepSelection && PrevSelFileCount>0) { SaveSelection(); ClearSelection(); } SortFileList(FALSE); if (CurFile>=FileCount || StrCmpI(ListData[CurFile]->strName,strCurName)) if (!GoToFile(strCurName) && !strNextCurName.IsEmpty()) GoToFile(strNextCurName); SetTitle(); }
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); //??? }