/* $ 14.09.2000 SVS + Функция FarMkTemp - получение имени временного файла с полным путем. Dest - приемник результата Template - шаблон по правилам функции mktemp, например "FarTmpXXXXXX" Вернет требуемый размер приемника. */ int WINAPI FarMkTemp(wchar_t *Dest, DWORD size, const wchar_t *Prefix) { string strDest; if (FarMkTempEx(strDest, Prefix, TRUE) && Dest && size) { xwcsncpy(Dest, strDest, size); } return static_cast<int>(strDest.GetLength()+1); }
void PrepareUnitStr() { for (int i=0; i<UNIT_COUNT; i++) { xwcsncpy(UnitStr[i][0],MSG(MListBytes+i),MAX_UNITSTR_SIZE); wcscpy(UnitStr[i][1],UnitStr[i][0]); CharLower(UnitStr[i][0]); CharUpper(UnitStr[i][1]); } }
void InitRecodeOutTable() { for (size_t i=0; i<ARRAYSIZE(Oem2Unicode); i++) { char c = static_cast<char>(i); MultiByteToWideChar(CP_OEMCP, MB_USEGLYPHCHARS, &c, 1, &Oem2Unicode[i], 1); } if (Global->Opt->CleanAscii) { std::fill(std::begin(Oem2Unicode), std::begin(Oem2Unicode) + 32, L'.'); Oem2Unicode[0x07]=L'*'; Oem2Unicode[0x10]=L'>'; Oem2Unicode[0x11]=L'<'; Oem2Unicode[0x15]=L'$'; Oem2Unicode[0x16]=L'-'; Oem2Unicode[0x18]=L'|'; Oem2Unicode[0x19]=L'V'; Oem2Unicode[0x1A]=L'>'; Oem2Unicode[0x1B]=L'<'; Oem2Unicode[0x1E]=L'X'; Oem2Unicode[0x1F]=L'X'; Oem2Unicode[0x7F]=L'.'; } if (Global->Opt->NoGraphics) { std::fill(std::begin(Oem2Unicode) + 0xB3, std::begin(Oem2Unicode) + 0xDB, L'+'); Oem2Unicode[0xB3]=L'|'; Oem2Unicode[0xBA]=L'|'; Oem2Unicode[0xC4]=L'-'; Oem2Unicode[0xCD]=L'='; } { // перед [пере]инициализацией восстановим буфер (либо из реестра, либо...) xwcsncpy(BoxSymbols,Global->Opt->strBoxSymbols.data(),ARRAYSIZE(BoxSymbols)-1); if (Global->Opt->NoGraphics) { for (int i=BS_V1; i<=BS_LT_H1V1; i++) BoxSymbols[i]=L'+'; BoxSymbols[BS_V1]=BoxSymbols[BS_V2]=L'|'; BoxSymbols[BS_H1]=L'-'; BoxSymbols[BS_H2]=L'='; } } //_SVS(SysLogDump("Oem2Unicode",0,(LPBYTE)Oem2Unicode,sizeof(Oem2Unicode),nullptr)); }
void InitRecodeOutTable() { for (size_t i=0; i<ARRAYSIZE(Oem2Unicode); i++) { char c = static_cast<char>(i); MultiByteToWideChar(CP_OEMCP, MB_USEGLYPHCHARS, &c, 1, &Oem2Unicode[i], 1); } if (Global->Opt->CleanAscii) { std::fill_n(Oem2Unicode, size_t(L' '), L'.'); Oem2Unicode[0x07]=L'*'; Oem2Unicode[0x10]=L'>'; Oem2Unicode[0x11]=L'<'; Oem2Unicode[0x15]=L'$'; Oem2Unicode[0x16]=L'-'; Oem2Unicode[0x18]=L'|'; Oem2Unicode[0x19]=L'V'; Oem2Unicode[0x1A]=L'>'; Oem2Unicode[0x1B]=L'<'; Oem2Unicode[0x1E]=L'X'; Oem2Unicode[0x1F]=L'X'; Oem2Unicode[0x7F]=L'.'; Oem2Unicode[0xFF]=L' '; } const auto ApplyNoGraphics = [](wchar_t* Buffer) { std::fill(Buffer + BS_V1, Buffer + BS_LT_H1V1 + 1, L'+'); Buffer[BS_V1] = L'|'; Buffer[BS_V2] = L'|'; Buffer[BS_H1] = L'-'; Buffer[BS_H2] = L'='; }; // перед [пере]инициализацией восстановим буфер (либо из реестра, либо...) xwcsncpy(BoxSymbols, Global->Opt->strBoxSymbols.data(), ARRAYSIZE(BoxSymbols) - 1); if (Global->Opt->NoGraphics) { ApplyNoGraphics(Oem2Unicode); ApplyNoGraphics(BoxSymbols); } }
static const wchar_t *__GetNextWord(const wchar_t *BufPtr,string &strCurKeyText,int& Line) { // пропускаем ведущие пробельные символы while (IsSpace(*BufPtr) || IsEol(*BufPtr)) { if (IsEol(*BufPtr)) { Line++;//TODO!!! } BufPtr++; } if (!*BufPtr) return nullptr; const wchar_t *CurBufPtr=BufPtr; wchar_t Chr=*BufPtr, Chr2=BufPtr[1]; BOOL SpecMacro=Chr==L'$' && Chr2 && !(IsSpace(Chr2) || IsEol(Chr2)); // ищем конец очередного названия клавиши while (Chr && !(IsSpace(Chr) || IsEol(Chr))) { if (SpecMacro && (Chr == L'[' || Chr == L'(' || Chr == L'{')) break; if (IsEol(Chr)) { Line++;//TODO!!! } BufPtr++; Chr=*BufPtr; } int Length=(int)(BufPtr-CurBufPtr); wchar_t *CurKeyText = strCurKeyText.GetBuffer(Length+1); xwcsncpy(CurKeyText,CurBufPtr,Length+1); strCurKeyText.ReleaseBuffer(); return BufPtr; }
static const wchar_t *_SubstFileName(const wchar_t *CurStr,TSubstData *PSubstData,string &strOut) { // рассмотрим переключатели активности/пассивности панели. if (!StrCmpN(CurStr,L"!#",2)) { CurStr+=2; PSubstData->PassivePanel=TRUE; return CurStr; } if (!StrCmpN(CurStr,L"!^",2)) { CurStr+=2; PSubstData->PassivePanel=FALSE; return CurStr; } // !! символ '!' if (!StrCmpN(CurStr,L"!!",2) && CurStr[2] != L'?') { strOut += L"!"; CurStr+=2; return CurStr; } // !.! Длинное имя файла с расширением if (!StrCmpN(CurStr,L"!.!",3) && CurStr[3] != L'?') { if (PSubstData->PassivePanel) strOut += PSubstData->strAnotherName; else strOut += PSubstData->Name; CurStr+=3; return CurStr; } // !~ Короткое имя файла без расширения if (!StrCmpN(CurStr,L"!~",2)) { strOut += PSubstData->PassivePanel ? PSubstData->strAnotherShortNameOnly : PSubstData->strShortNameOnly; CurStr+=2; return CurStr; } // !` Длинное расширение файла без имени if (!StrCmpN(CurStr,L"!`",2)) { const wchar_t *Ext; if (CurStr[2] == L'~') { Ext=wcsrchr((PSubstData->PassivePanel ? PSubstData->strAnotherShortName.CPtr():PSubstData->ShortName),L'.'); CurStr+=3; } else { Ext=wcsrchr((PSubstData->PassivePanel ? PSubstData->strAnotherName.CPtr():PSubstData->Name),L'.'); CurStr+=2; } if (Ext && *Ext) strOut += ++Ext; return CurStr; } // !& !&~ список файлов разделенных пробелом. if ((!StrCmpN(CurStr,L"!&~",3) && CurStr[3] != L'?') || (!StrCmpN(CurStr,L"!&",2) && CurStr[2] != L'?')) { string strFileNameL, strShortNameL; Panel *WPanel=PSubstData->PassivePanel?PSubstData->AnotherPanel:PSubstData->ActivePanel; DWORD FileAttrL; int ShortN0=FALSE; int CntSkip=2; if (CurStr[2] == L'~') { ShortN0=TRUE; CntSkip++; } WPanel->GetSelName(nullptr,FileAttrL); int First = TRUE; while (WPanel->GetSelName(&strFileNameL,FileAttrL,&strShortNameL)) { if (ShortN0) strFileNameL = strShortNameL; else // в список все же должно попасть имя в кавычках. QuoteSpaceOnly(strFileNameL); // Вот здесь фиг его знает - нужно/ненужно... // если будет нужно - раскомментируем :-) // if(FileAttrL & FILE_ATTRIBUTE_DIRECTORY) // AddEndSlash(FileNameL); // А нужен ли нам пробел в самом начале? if (First) First = FALSE; else strOut += L" "; strOut += strFileNameL; } CurStr+=CntSkip; return CurStr; } // !@ Имя файла, содержащего имена помеченных файлов // !$! Имя файла, содержащего короткие имена помеченных файлов // Ниже идет совмещение кода для разбора как !@! так и !$! //Вообще-то (по исторической справедливости как бы) - в !$! нужно выбрасывать модификаторы Q и A // Но нафиг нада:) if (!StrCmpN(CurStr,L"!@",2) || !StrCmpN(CurStr,L"!$",2)) { string *pListName; string *pAnotherListName; bool ShortN0 = FALSE; if (CurStr[1] == L'$') ShortN0 = TRUE; if (ShortN0) { pListName = PSubstData->pShortListName; pAnotherListName = PSubstData->pAnotherShortListName; } else { pListName = PSubstData->pListName; pAnotherListName = PSubstData->pAnotherListName; } wchar_t Modifers[32]=L""; const wchar_t *Ptr; if ((Ptr=wcschr(CurStr+2,L'!')) ) { if (Ptr[1] != L'?') { xwcsncpy(Modifers,CurStr+2,Min(ARRAYSIZE(Modifers),static_cast<size_t>(Ptr-(CurStr+2)+1))); if (pListName) { if (PSubstData->PassivePanel && (!pAnotherListName->IsEmpty() || PSubstData->AnotherPanel->MakeListFile(*pAnotherListName,ShortN0,Modifers))) { if (ShortN0) ConvertNameToShort(*pAnotherListName, *pAnotherListName); strOut += *pAnotherListName; } if (!PSubstData->PassivePanel && (!pListName->IsEmpty() || PSubstData->ActivePanel->MakeListFile(*pListName,ShortN0,Modifers))) { if (ShortN0) ConvertNameToShort(*pListName,*pListName); strOut += *pListName; } } else { strOut += CurStr; strOut += Modifers; strOut += L"!"; } CurStr+=Ptr-CurStr+1; return CurStr; } } } // !-! Короткое имя файла с расширением if (!StrCmpN(CurStr,L"!-!",3) && CurStr[3] != L'?') { if (PSubstData->PassivePanel) strOut += PSubstData->strAnotherShortName; else strOut += PSubstData->ShortName; CurStr+=3; return CurStr; } // !+! Аналогично !-!, но если длинное имя файла утеряно // после выполнения команды, FAR восстановит его if (!StrCmpN(CurStr,L"!+!",3) && CurStr[3] != L'?') { if (PSubstData->PassivePanel) strOut += PSubstData->strAnotherShortName; else strOut += PSubstData->ShortName; CurStr+=3; PSubstData->PreserveLFN=TRUE; return CurStr; } // !: Текущий диск if (!StrCmpN(CurStr,L"!:",2)) { string strCurDir; string strRootDir; if (*PSubstData->Name && PSubstData->Name[1]==L':') strCurDir = PSubstData->Name; else if (PSubstData->PassivePanel) PSubstData->AnotherPanel->GetCurDir(strCurDir); else strCurDir = PSubstData->strCmdDir; GetPathRoot(strCurDir,strRootDir); DeleteEndSlash(strRootDir); strOut += strRootDir; CurStr+=2; return CurStr; } // !\ Текущий путь // !/ Короткое имя текущего пути // Ниже идет совмещение кода для разбора как !\ так и !/ if (!StrCmpN(CurStr,L"!\\",2) || !StrCmpN(CurStr,L"!=\\",3) || !StrCmpN(CurStr,L"!/",2) || !StrCmpN(CurStr,L"!=/",3)) { string strCurDir; bool ShortN0 = FALSE; int RealPath= CurStr[1]==L'='?1:0; if (CurStr[1] == L'/' || (RealPath && CurStr[2] == L'/')) { ShortN0 = TRUE; } if (PSubstData->PassivePanel) PSubstData->AnotherPanel->GetCurDir(strCurDir); else strCurDir = PSubstData->strCmdDir; if (RealPath) { _MakePath1(PSubstData->PassivePanel?KEY_ALTSHIFTBACKBRACKET:KEY_ALTSHIFTBRACKET,strCurDir,L"",ShortN0); Unquote(strCurDir); } if (ShortN0) ConvertNameToShort(strCurDir,strCurDir); AddEndSlash(strCurDir); CurStr+=2+RealPath; if (*CurStr==L'!') { if (wcspbrk(PSubstData->PassivePanel?PSubstData->strAnotherName.CPtr():PSubstData->Name,L"\\:")) strCurDir.Clear(); } strOut += strCurDir; return CurStr; } // !?<title>?<init>! if (!StrCmpN(CurStr,L"!?",2) && wcschr(CurStr+2,L'!')) { int j; int i = IsReplaceVariable(CurStr); if (i == -1) // if bad format string { // skip 1 char j = 1; } else { j = i + 1; } strOut.Append(CurStr, j); CurStr += j; return CurStr; } // ! Длинное имя файла без расширения if (*CurStr==L'!') { strOut += PointToName(PSubstData->PassivePanel ? PSubstData->strAnotherNameOnly : PSubstData->strNameOnly); CurStr++; } return CurStr; }
// На основе имени файла (Src) и маски (Dest) генерируем новое имя // SelectedFolderNameLength - длина каталога. Например, есть // каталог dir1, а в нем файл file1. Нужно сгенерировать имя по маске для dir1. // Параметры могут быть следующими: Src="dir1", SelectedFolderNameLength=0 // или Src="dir1\\file1", а SelectedFolderNameLength=4 (длина "dir1") int ConvertWildcards(const wchar_t *SrcName, string &strDest, int SelectedFolderNameLength) { string strPartAfterFolderName; string strSrc = SrcName; wchar_t *DestName = strDest.GetBuffer(strDest.GetLength()+strSrc.GetLength()+1); //??? wchar_t *DestNamePtr = (wchar_t*)PointToName(DestName); string strWildName = DestNamePtr; if (!wcschr(strWildName, L'*') && !wcschr(strWildName, L'?')) { //strDest.ReleaseBuffer (); не надо так как строка не поменялась return FALSE; } if (SelectedFolderNameLength) { strPartAfterFolderName = ((const wchar_t *)strSrc+SelectedFolderNameLength); strSrc.SetLength(SelectedFolderNameLength); } const wchar_t *Src = strSrc; const wchar_t *SrcNamePtr = PointToName(Src); int BeforeNameLength = DestNamePtr==DestName ? (int)(SrcNamePtr-Src) : 0; wchar_t *PartBeforeName = (wchar_t*)xf_malloc((BeforeNameLength+1)*sizeof(wchar_t)); xwcsncpy(PartBeforeName, Src, BeforeNameLength+1); const wchar_t *SrcNameDot = wcsrchr(SrcNamePtr, L'.'); const wchar_t *CurWildPtr = strWildName; while (*CurWildPtr) { switch (*CurWildPtr) { case L'?': CurWildPtr++; if (*SrcNamePtr) *(DestNamePtr++)=*(SrcNamePtr++); break; case L'*': CurWildPtr++; while (*SrcNamePtr) { if (*CurWildPtr==L'.' && SrcNameDot && !wcschr(CurWildPtr+1,L'.')) { if (SrcNamePtr==SrcNameDot) break; } else if (*SrcNamePtr==*CurWildPtr) { break; } *(DestNamePtr++)=*(SrcNamePtr++); } break; case L'.': CurWildPtr++; *(DestNamePtr++)=L'.'; if (wcspbrk(CurWildPtr,L"*?")) while (*SrcNamePtr) if (*(SrcNamePtr++)==L'.') break; break; default: *(DestNamePtr++)=*(CurWildPtr++); if (*SrcNamePtr && *SrcNamePtr!=L'.') SrcNamePtr++; break; } } *DestNamePtr=0; if (DestNamePtr!=DestName && *(DestNamePtr-1)==L'.') *(DestNamePtr-1)=0; strDest.ReleaseBuffer(); if (*PartBeforeName) strDest = PartBeforeName+strDest; if (SelectedFolderNameLength) strDest += strPartAfterFolderName; //BUGBUG???, was src in 1.7x xf_free(PartBeforeName); return TRUE; }
bool History::SaveHistory() { if (!*EnableSave) return true; if (!HistoryList.Count()) { DeleteRegKey(strRegKey); return true; } //for dialogs, locked items should show first (be last in the list) if (TypeHistory == HISTORYTYPE_DIALOG) { for (const HistoryRecord *HistoryItem=HistoryList.First(), *LastItem=HistoryList.Last(); HistoryItem; ) { const HistoryRecord *tmp = HistoryItem; HistoryItem=HistoryList.Next(HistoryItem); if (tmp->Lock) HistoryList.MoveAfter(HistoryList.Last(), tmp); if (tmp == LastItem) break; } } wchar_t *TypesBuffer=nullptr; if (SaveType) { TypesBuffer=(wchar_t *)xf_malloc((HistoryList.Count()+1)*sizeof(wchar_t)); if (!TypesBuffer) return false; } wchar_t *LocksBuffer=nullptr; if (!(LocksBuffer=(wchar_t *)xf_malloc((HistoryList.Count()+1)*sizeof(wchar_t)))) { if (TypesBuffer) xf_free(TypesBuffer); return false; } FILETIME *TimesBuffer=nullptr; if (!(TimesBuffer=(FILETIME *)xf_malloc((HistoryList.Count()+1)*sizeof(FILETIME)))) { if (LocksBuffer) xf_free(LocksBuffer); if (TypesBuffer) xf_free(TypesBuffer); return false; } memset(TimesBuffer,0,(HistoryList.Count()+1)*sizeof(FILETIME)); wmemset(LocksBuffer,0,HistoryList.Count()+1); if (SaveType) wmemset(TypesBuffer,0,HistoryList.Count()+1); bool ret = false; HKEY hKey = nullptr; wchar_t *BufferLines=nullptr, *PtrBuffer; size_t SizeLines=0, SizeTypes=0, SizeLocks=0, SizeTimes=0; int Position = -1; size_t i=HistoryList.Count()-1; for (const HistoryRecord *HistoryItem=HistoryList.Last(); HistoryItem ; HistoryItem=HistoryList.Prev(HistoryItem)) { if (!(PtrBuffer=(wchar_t*)xf_realloc(BufferLines,(SizeLines+HistoryItem->strName.GetLength()+2)*sizeof(wchar_t)))) { ret = false; goto end; } BufferLines=PtrBuffer; xwcsncpy(BufferLines+SizeLines,HistoryItem->strName,HistoryItem->strName.GetLength()+1); SizeLines+=HistoryItem->strName.GetLength()+1; if (SaveType) TypesBuffer[SizeTypes++]=HistoryItem->Type+L'0'; LocksBuffer[SizeLocks++]=HistoryItem->Lock+L'0'; TimesBuffer[SizeTimes].dwLowDateTime=HistoryItem->Timestamp.dwLowDateTime; TimesBuffer[SizeTimes].dwHighDateTime=HistoryItem->Timestamp.dwHighDateTime; SizeTimes++; if (HistoryItem == CurrentItem) Position = static_cast<int>(i); i--; } hKey=CreateRegKey(strRegKey); if (hKey) { RegSetValueEx(hKey,L"Lines",0,REG_MULTI_SZ,(unsigned char *)BufferLines,static_cast<DWORD>(SizeLines*sizeof(wchar_t))); if (SaveType) RegSetValueEx(hKey,L"Types",0,REG_SZ,(unsigned char *)TypesBuffer,static_cast<DWORD>((SizeTypes+1)*sizeof(wchar_t))); RegSetValueEx(hKey,L"Locks",0,REG_SZ,(unsigned char *)LocksBuffer,static_cast<DWORD>((SizeLocks+1)*sizeof(wchar_t))); RegSetValueEx(hKey,L"Times",0,REG_BINARY,(unsigned char *)TimesBuffer,(DWORD)SizeTimes*sizeof(FILETIME)); RegSetValueEx(hKey,L"Position",0,REG_DWORD,(BYTE *)&Position,sizeof(Position)); RegCloseKey(hKey); ret = true; } end: if (BufferLines) xf_free(BufferLines); if (TypesBuffer) xf_free(TypesBuffer); if (LocksBuffer) xf_free(LocksBuffer); if (TimesBuffer) xf_free(TimesBuffer); return ret; }
int Panel::SetPluginCommand(int Command,int Param1,void* Param2) { _ALGO(CleverSysLog clv(L"Panel::SetPluginCommand")); _ALGO(SysLog(L"(Command=%s, Param1=[%d/0x%08X], Param2=[%d/0x%08X])",_FCTL_ToName(Command),(int)Param1,Param1,(int)Param2,Param2)); int Result=FALSE; ProcessingPluginCommand++; switch (Command) { case FCTL_SETVIEWMODE: Result = Parent()->ChangePanelViewMode(shared_from_this(), Param1, Parent()->IsTopWindow()); break; case FCTL_SETSORTMODE: { int Mode=Param1; if ((Mode>SM_DEFAULT) && (Mode < SM_COUNT)) { SetSortMode(panel_sort(Mode - 1)); // Уменьшим на 1 из-за SM_DEFAULT Result=TRUE; } break; } case FCTL_SETSORTORDER: { ChangeSortOrder(Param1 != 0); Result=TRUE; break; } case FCTL_SETDIRECTORIESFIRST: { ChangeDirectoriesFirst(Param1 != 0); Result=TRUE; break; } case FCTL_CLOSEPANEL: if (m_PanelMode == panel_mode::PLUGIN_PANEL) { string folder=NullToEmpty((const wchar_t *)Param2); SetCurDir(folder,true); if (folder.empty()) Update(UPDATE_KEEP_SELECTION); Redraw(); } Result=TRUE; break; case FCTL_GETPANELINFO: { PanelInfo *Info=(PanelInfo *)Param2; if(!CheckStructSize(Info)) break; *Info = {}; Info->StructSize = sizeof(PanelInfo); UpdateIfRequired(); Info->OwnerGuid=FarGuid; Info->PluginHandle=nullptr; switch (GetType()) { case panel_type::FILE_PANEL: Info->PanelType=PTYPE_FILEPANEL; break; case panel_type::TREE_PANEL: Info->PanelType=PTYPE_TREEPANEL; break; case panel_type::QVIEW_PANEL: Info->PanelType=PTYPE_QVIEWPANEL; break; case panel_type::INFO_PANEL: Info->PanelType=PTYPE_INFOPANEL; break; } int X1,Y1,X2,Y2; GetPosition(X1,Y1,X2,Y2); Info->PanelRect.left=X1; Info->PanelRect.top=Y1; Info->PanelRect.right=X2; Info->PanelRect.bottom=Y2; Info->ViewMode=GetViewMode(); Info->SortMode = static_cast<OPENPANELINFO_SORTMODES>((GetSortMode() < panel_sort::COUNT? SM_UNSORTED - static_cast<int>(panel_sort::UNSORTED) : 0) + static_cast<int>(GetSortMode())); Info->Flags |= Global->Opt->ShowHidden? PFLAGS_SHOWHIDDEN : 0; Info->Flags |= Global->Opt->Highlight? PFLAGS_HIGHLIGHT : 0; Info->Flags |= GetSortOrder()? PFLAGS_REVERSESORTORDER : 0; Info->Flags |= GetSortGroups()? PFLAGS_USESORTGROUPS : 0; Info->Flags |= GetSelectedFirstMode()? PFLAGS_SELECTEDFIRST : 0; Info->Flags |= GetDirectoriesFirst()? PFLAGS_DIRECTORIESFIRST : 0; Info->Flags |= (GetMode() == panel_mode::PLUGIN_PANEL)? PFLAGS_PLUGIN : 0; Info->Flags |= IsVisible()? PFLAGS_VISIBLE : 0; Info->Flags |= IsFocused()? PFLAGS_FOCUS : 0; Info->Flags |= Parent()->IsLeft(this)? PFLAGS_PANELLEFT : 0; if (GetType() == panel_type::FILE_PANEL) { FileList *DestFilePanel=(FileList *)this; if (Info->Flags&PFLAGS_PLUGIN) { Info->OwnerGuid = DestFilePanel->GetPluginHandle()->plugin()->Id(); Info->PluginHandle = DestFilePanel->GetPluginHandle()->panel(); static int Reenter=0; if (!Reenter) { Reenter++; OpenPanelInfo PInfo; DestFilePanel->GetOpenPanelInfo(&PInfo); if (PInfo.Flags & OPIF_REALNAMES) Info->Flags |= PFLAGS_REALNAMES; if (PInfo.Flags & OPIF_DISABLEHIGHLIGHTING) Info->Flags &= ~PFLAGS_HIGHLIGHT; if (PInfo.Flags & OPIF_USECRC32) Info->Flags |= PFLAGS_USECRC32; if (PInfo.Flags & OPIF_SHORTCUT) Info->Flags |= PFLAGS_SHORTCUT; Reenter--; } } DestFilePanel->PluginGetPanelInfo(*Info); } if (!(Info->Flags&PFLAGS_PLUGIN)) // $ 12.12.2001 DJ - на неплагиновой панели - всегда реальные имена Info->Flags |= PFLAGS_REALNAMES; Result=TRUE; break; } case FCTL_GETPANELPREFIX: { string strTemp; if (GetType() == panel_type::FILE_PANEL && GetMode() == panel_mode::PLUGIN_PANEL) { PluginInfo PInfo = {sizeof(PInfo)}; FileList *DestPanel = ((FileList*)this); if (DestPanel->GetPluginInfo(&PInfo)) strTemp = NullToEmpty(PInfo.CommandPrefix); } if (Param1&&Param2) xwcsncpy((wchar_t*)Param2, strTemp.c_str(), Param1); Result=(int)strTemp.size()+1; break; } case FCTL_GETPANELHOSTFILE: case FCTL_GETPANELFORMAT: { string strTemp; if (GetType() == panel_type::FILE_PANEL) { FileList *DestFilePanel=(FileList *)this; static int Reenter=0; if (!Reenter && GetMode() == panel_mode::PLUGIN_PANEL) { Reenter++; OpenPanelInfo PInfo; DestFilePanel->GetOpenPanelInfo(&PInfo); switch (Command) { case FCTL_GETPANELHOSTFILE: strTemp=NullToEmpty(PInfo.HostFile); break; case FCTL_GETPANELFORMAT: strTemp=NullToEmpty(PInfo.Format); break; } Reenter--; } } if (Param1&&Param2) xwcsncpy((wchar_t*)Param2, strTemp.c_str(), Param1); Result=(int)strTemp.size()+1; break; } case FCTL_GETPANELDIRECTORY: { static int Reenter=0; if(!Reenter) { Reenter++; ShortcutInfo Info; GetShortcutInfo(Info); Result = static_cast<int>(aligned_sizeof<FarPanelDirectory>()); const auto folderOffset = Result; Result+=static_cast<int>(sizeof(wchar_t)*(Info.ShortcutFolder.size()+1)); const auto pluginFileOffset = Result; Result+=static_cast<int>(sizeof(wchar_t)*(Info.PluginFile.size()+1)); const auto pluginDataOffset = Result; Result+=static_cast<int>(sizeof(wchar_t)*(Info.PluginData.size()+1)); const auto dirInfo = static_cast<FarPanelDirectory*>(Param2); if(Param1>=Result && CheckStructSize(dirInfo)) { dirInfo->StructSize=sizeof(FarPanelDirectory); dirInfo->PluginId=Info.PluginGuid; dirInfo->Name = static_cast<wchar_t*>(static_cast<void*>(static_cast<char*>(Param2) + folderOffset)); dirInfo->Param = static_cast<wchar_t*>(static_cast<void*>(static_cast<char*>(Param2) + pluginDataOffset)); dirInfo->File = static_cast<wchar_t*>(static_cast<void*>(static_cast<char*>(Param2) + pluginFileOffset)); *std::copy(ALL_CONST_RANGE(Info.ShortcutFolder), const_cast<wchar_t*>(dirInfo->Name)) = L'\0'; *std::copy(ALL_CONST_RANGE(Info.PluginData), const_cast<wchar_t*>(dirInfo->Param)) = L'\0'; *std::copy(ALL_CONST_RANGE(Info.PluginFile), const_cast<wchar_t*>(dirInfo->File)) = L'\0'; } Reenter--; } break; } case FCTL_GETCOLUMNTYPES: case FCTL_GETCOLUMNWIDTHS: if (GetType() == panel_type::FILE_PANEL) { string strColumnTypes,strColumnWidths; ((FileList *)this)->PluginGetColumnTypesAndWidths(strColumnTypes,strColumnWidths); if (Command==FCTL_GETCOLUMNTYPES) { if (Param1&&Param2) xwcsncpy((wchar_t*)Param2,strColumnTypes.c_str(),Param1); Result=(int)strColumnTypes.size()+1; } else { if (Param1&&Param2) xwcsncpy((wchar_t*)Param2,strColumnWidths.c_str(),Param1); Result=(int)strColumnWidths.size()+1; } } break; case FCTL_GETPANELITEM: { if (GetType() == panel_type::FILE_PANEL && CheckNullOrStructSize(static_cast<FarGetPluginPanelItem*>(Param2))) Result = static_cast<int>(static_cast<FileList*>(this)->PluginGetPanelItem(Param1, static_cast<FarGetPluginPanelItem*>(Param2))); break; } case FCTL_GETSELECTEDPANELITEM: { if (GetType() == panel_type::FILE_PANEL && CheckNullOrStructSize(static_cast<FarGetPluginPanelItem*>(Param2))) Result = static_cast<int>(static_cast<FileList*>(this)->PluginGetSelectedPanelItem(Param1, static_cast<FarGetPluginPanelItem*>(Param2))); break; } case FCTL_GETCURRENTPANELITEM: { if (GetType() == panel_type::FILE_PANEL && CheckNullOrStructSize(static_cast<FarGetPluginPanelItem*>(Param2))) { PanelInfo Info; const auto DestPanel = static_cast<FileList*>(this); DestPanel->PluginGetPanelInfo(Info); Result = static_cast<int>(DestPanel->PluginGetPanelItem(static_cast<int>(Info.CurrentItem), static_cast<FarGetPluginPanelItem*>(Param2))); } break; } case FCTL_BEGINSELECTION: { if (GetType() == panel_type::FILE_PANEL) { ((FileList *)this)->PluginBeginSelection(); Result=TRUE; } break; } case FCTL_SETSELECTION: { if (GetType() == panel_type::FILE_PANEL) { ((FileList *)this)->PluginSetSelection(Param1, Param2 != nullptr); Result=TRUE; } break; } case FCTL_CLEARSELECTION: { if (GetType() == panel_type::FILE_PANEL) { static_cast<FileList*>(this)->PluginClearSelection(Param1); Result=TRUE; } break; } case FCTL_ENDSELECTION: { if (GetType() == panel_type::FILE_PANEL) { ((FileList *)this)->PluginEndSelection(); Result=TRUE; } break; } case FCTL_UPDATEPANEL: Update(Param1?UPDATE_KEEP_SELECTION:0); if (GetType() == panel_type::QVIEW_PANEL) UpdateViewPanel(); Result=TRUE; break; case FCTL_REDRAWPANEL: { PanelRedrawInfo *Info=(PanelRedrawInfo *)Param2; if (CheckStructSize(Info)) { m_CurFile=static_cast<int>(Info->CurrentItem); m_CurTopFile=static_cast<int>(Info->TopPanelItem); } // $ 12.05.2001 DJ перерисовываемся только в том случае, если мы - текущее окно if (Parent()->IsTopWindow()) Redraw(); Result=TRUE; break; } case FCTL_SETPANELDIRECTORY: { const auto dirInfo = static_cast<const FarPanelDirectory*>(Param2); if (CheckStructSize(dirInfo)) { Result = ExecShortcutFolder(NullToEmpty(dirInfo->Name), dirInfo->PluginId, NullToEmpty(dirInfo->File), NullToEmpty(dirInfo->Param), false, false, true); // restore current directory to active panel path if (!IsFocused()) { Parent()->ActivePanel()->SetCurPath(); } } break; } case FCTL_SETACTIVEPANEL: { if (IsVisible()) { Parent()->SetActivePanel(this); Result=TRUE; } break; } } ProcessingPluginCommand--; return Result; }