diff --git a/far/changelog b/far/changelog index e4ac542b73..3b4207c87d 100644 --- a/far/changelog +++ b/far/changelog @@ -1,3 +1,9 @@ +-------------------------------------------------------------------------------- +MZK 22.01.2023 09:32:07 -0800 - build 6096 + +1. Added "Search for Hex" functionality to the unified SearchReplace dialog. + Internal implementation only; no user-visible changes are expected. + -------------------------------------------------------------------------------- drkns 22.01.2023 21:06:44 +0000 - build 6095 diff --git a/far/editor.cpp b/far/editor.cpp index f37439439a..43cdb68c2b 100644 --- a/far/editor.cpp +++ b/far/editor.cpp @@ -78,9 +78,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //---------------------------------------------------------------------------- -static bool ReplaceMode, ReplaceAll; - -static int EditorID=0; +static int GlobalEditorCount{}; enum class Editor::undo_type: char { @@ -130,7 +128,9 @@ Editor::Editor(window_ptr Owner, uintptr_t Codepage, bool DialogUsed): GlobalEOL(GetDefaultEOL()), m_codepage(Codepage), EdOpt(Global->Opt->EdOpt), - LastSearchDlgOptions{ + LastSearchDlgParams{ + .ShowButtonAll = true, + .SearchStr = Global->GetSearchString(Codepage), .CaseSensitive = Global->GlobalSearchCaseSensitive, .WholeWords = Global->GlobalSearchWholeWords, .Reverse = Global->GlobalSearchReverse, @@ -138,22 +138,13 @@ Editor::Editor(window_ptr Owner, uintptr_t Codepage, bool DialogUsed): .Fuzzy = Global->GlobalSearchFuzzy, .PreserveStyle = false // Consider: Should we introduce Global->Opt->EdOpt.ReplacePreserveStyle? }, - EditorID(::EditorID++), + EditorID(::GlobalEditorCount++), Color(colors::PaletteColorToFarColor(COL_EDITORTEXT)), SelColor(colors::PaletteColorToFarColor(COL_EDITORSELECTEDTEXT)) { if (DialogUsed) m_Flags.Set(FEDITOR_DIALOGMEMOEDIT); - if (Global->GetSearchHex()) - { - const auto Blob = HexStringToBlob(Global->GetSearchString(), 0); - strLastSearchStr.assign(view_as(Blob.data()), view_as(Blob.data() + Blob.size())); - } - else - { - strLastSearchStr = Global->GetSearchString(); - } UnmarkMacroBlock(); PushString({}); } @@ -214,26 +205,16 @@ void Editor::SwapState(Editor& swap_state) swap(MaxRightPosState, swap_state.MaxRightPosState); } -// Consider: Since this function deals with the options of Search/Replace dialog and nothing else, +// Consider: Since this function deals with Search/Replace dialog parameters and nothing else, // should it be called after the dialog was closed (not cancelled) instead of in Edior's destructor? void Editor::KeepInitParameters() const { - // Установлен глобальный режим поиска 16-ричных данных? - if (Global->GetSearchHex()) - { - // BUGBUG, it's unclear how to represent unicode in hex - const auto AnsiStr = encoding::get_bytes(m_codepage, strLastSearchStr); - Global->StoreSearchString(BlobToHexString(view_bytes(AnsiStr), 0), true); - } - else - { - Global->StoreSearchString(strLastSearchStr, false); - } - Global->GlobalSearchCaseSensitive = LastSearchDlgOptions.CaseSensitive.value(); - Global->GlobalSearchWholeWords = LastSearchDlgOptions.WholeWords.value(); - Global->GlobalSearchReverse = LastSearchDlgOptions.Reverse.value(); - Global->Opt->EdOpt.SearchRegexp = LastSearchDlgOptions.Regexp.value(); - Global->GlobalSearchFuzzy = LastSearchDlgOptions.Fuzzy.value(); + Global->StoreSearchString(LastSearchDlgParams.SearchStr, m_codepage, Global->GetSearchHex()); + Global->GlobalSearchCaseSensitive = LastSearchDlgParams.CaseSensitive.value(); + Global->GlobalSearchWholeWords = LastSearchDlgParams.WholeWords.value(); + Global->GlobalSearchReverse = LastSearchDlgParams.Reverse.value(); + Global->Opt->EdOpt.SearchRegexp = LastSearchDlgParams.Regexp.value(); + Global->GlobalSearchFuzzy = LastSearchDlgParams.Fuzzy.value(); } void Editor::DisplayObject() @@ -1883,14 +1864,14 @@ bool Editor::ProcessKeyInternal(const Manager::Key& Key, bool& Refresh) case KEY_F7: { - bool ReplaceMode0=ReplaceMode; - bool ReplaceAll0=ReplaceAll; - ReplaceMode=ReplaceAll=false; + bool ReplaceMode0 = LastSearchDlgParams.ReplaceMode; + bool ReplaceAll0 = ReplaceAll; + LastSearchDlgParams.ReplaceMode=ReplaceAll=false; if (!Search(false)) { - ReplaceMode=ReplaceMode0; - ReplaceAll=ReplaceAll0; + LastSearchDlgParams.ReplaceMode = ReplaceMode0; + ReplaceAll = ReplaceAll0; } return true; @@ -1901,15 +1882,15 @@ bool Editor::ProcessKeyInternal(const Manager::Key& Key, bool& Refresh) { if (!m_Flags.Check(FEDITOR_LOCKMODE)) { - bool ReplaceMode0=ReplaceMode; - bool ReplaceAll0=ReplaceAll; - ReplaceMode = true; + bool ReplaceMode0 = LastSearchDlgParams.ReplaceMode; + bool ReplaceAll0 = ReplaceAll; + LastSearchDlgParams.ReplaceMode = true; ReplaceAll = false; if (!Search(false)) { - ReplaceMode=ReplaceMode0; - ReplaceAll=ReplaceAll0; + LastSearchDlgParams.ReplaceMode = ReplaceMode0; + ReplaceAll = ReplaceAll0; } } @@ -1935,10 +1916,10 @@ bool Editor::ProcessKeyInternal(const Manager::Key& Key, bool& Refresh) case KEY_RALTF7: { TurnOffMarkingBlock(); - bool LastSearchReverseOrig = LastSearchDlgOptions.Reverse.value(); - LastSearchDlgOptions.Reverse = !LastSearchReverseOrig; + bool LastSearchReverseOrig = LastSearchDlgParams.Reverse.value(); + LastSearchDlgParams.Reverse = !LastSearchReverseOrig; Search(true); - LastSearchDlgOptions.Reverse = LastSearchReverseOrig; + LastSearchDlgParams.Reverse = LastSearchReverseOrig; return true; } @@ -3296,18 +3277,7 @@ class undo_block bool Editor::Search(bool Next) { - static string strLastReplaceStr; - bool MatchFound, UserBreak; - std::optional UndoBlock; - - if (Next && strLastSearchStr.empty()) - return true; - - auto strSearchStr = strLastSearchStr; - auto strReplaceStr = strLastReplaceStr; - auto SearchDlgOptions{ LastSearchDlgOptions }; - - bool FindAllReferences = false; + bool FindAll{}; if (!Next) { @@ -3356,24 +3326,19 @@ bool Editor::Search(bool Next) }; switch (GetSearchReplaceString( - ReplaceMode, - {}, - {}, - strSearchStr, - strReplaceStr, - {}, - {}, - SearchDlgOptions, + LastSearchDlgParams, + L"SearchText"sv, + L"ReplaceText"sv, + m_codepage, L"EditorSearch"sv, - false, - ReplaceMode? &EditorReplaceId : &EditorSearchId, + LastSearchDlgParams.ReplaceMode? &EditorReplaceId : &EditorSearchId, Picker)) { case 0: return false; case 2: - FindAllReferences = true; + FindAll = true; break; default: @@ -3381,32 +3346,25 @@ bool Editor::Search(bool Next) } } - strLastSearchStr = strSearchStr; - strLastReplaceStr = strReplaceStr; - LastSearchDlgOptions = SearchDlgOptions; - - if (FindAllReferences) - { - SearchDlgOptions.Reverse.value() = false; - } - - if (strSearchStr.empty()) + if (LastSearchDlgParams.SearchStr.empty()) return true; - string QuotedStr; + const auto Reverse = !FindAll && LastSearchDlgParams.Reverse.value(); + bool MatchFound{}, UserBreak{}; + std::optional UndoBlock; + string QuotedStr; const auto FindAllList = VMenu2::create({}, {}); size_t AllRefLines{}; + { SetCursorType(false, -1); - MatchFound = false; - UserBreak = false; - auto CurPos = FindAllReferences? 0 : m_it_CurLine->GetCurPos(); + auto CurPos = FindAll? 0 : m_it_CurLine->GetCurPos(); if (Next && m_FoundLine == m_it_CurLine) { - if (SearchDlgOptions.Reverse.value()) + if (Reverse) { if (EdOpt.SearchCursorAtEnd) { @@ -3426,30 +3384,32 @@ bool Editor::Search(bool Next) } } - auto CurPtr = FindAllReferences? FirstLine() : m_it_CurLine, TmpPtr = CurPtr; + auto CurPtr = FindAll? FirstLine() : m_it_CurLine, TmpPtr = CurPtr; std::vector Match; named_regex_match NamedMatch; RegExp re; - if (SearchDlgOptions.Regexp.value()) + if (LastSearchDlgParams.Regexp.value()) { // Q: что важнее: опция диалога или опция RegExp`а? try { - re.Compile(strSearchStr, (strSearchStr.starts_with(L'/')? OP_PERLSTYLE : 0) | OP_OPTIMIZE | (SearchDlgOptions.CaseSensitive.value()? 0 : OP_IGNORECASE)); + re.Compile( + LastSearchDlgParams.SearchStr, + (LastSearchDlgParams.SearchStr.starts_with(L'/')? OP_PERLSTYLE : 0) | OP_OPTIMIZE | (LastSearchDlgParams.CaseSensitive.value()? 0 : OP_IGNORECASE)); } catch (regex_exception const& e) { - ReCompileErrorMessage(e, strSearchStr); + ReCompileErrorMessage(e, LastSearchDlgParams.SearchStr); return false; //BUGBUG } } - QuotedStr = quote_unconditional(strSearchStr); + QuotedStr = quote_unconditional(LastSearchDlgParams.SearchStr); searchers Searchers; - const auto& Searcher = init_searcher(Searchers, SearchDlgOptions.CaseSensitive.value(), SearchDlgOptions.Fuzzy.value(), strLastSearchStr); + const auto& Searcher = init_searcher(Searchers, LastSearchDlgParams.CaseSensitive.value(), LastSearchDlgParams.Fuzzy.value(), LastSearchDlgParams.SearchStr); const time_check TimeCheck; std::optional Progress; @@ -3469,21 +3429,22 @@ bool Editor::Search(bool Next) } if (!Progress) - Progress.emplace(msg(lng::MEditSearchTitle), format(msg(lng::MEditSearchingFor), QuotedStr), 0); + Progress.emplace(msg(lng::MSearchReplaceSearchTitle), format(msg(lng::MEditSearchingFor), QuotedStr), 0); SetCursorType(false, -1); - const auto Total = FindAllReferences? Lines.size() : SearchDlgOptions.Reverse.value()? StartLine : Lines.size() - StartLine; + const auto Total = FindAll? Lines.size() : Reverse? StartLine : Lines.size() - StartLine; const auto Current = std::abs(CurPtr.Number() - StartLine); Progress->update(ToPercent(Current, Total)); taskbar::set_value(Current,Total); } - auto strReplaceStrCurrent = ReplaceMode? strReplaceStr : L""s; + // $ 2023-01-15 MZK: Why do we need it? + auto strReplaceStrCurrent = LastSearchDlgParams.ReplaceMode? LastSearchDlgParams.ReplaceStr : L""s; int SearchLength; if (SearchAndReplaceString( CurPtr->GetString(), - strSearchStr, + LastSearchDlgParams.SearchStr, Searcher, re, Match, @@ -3491,11 +3452,11 @@ bool Editor::Search(bool Next) strReplaceStrCurrent, CurPos, { - .CaseSensitive = SearchDlgOptions.CaseSensitive.value(), - .WholeWords = SearchDlgOptions.WholeWords.value(), - .Reverse = SearchDlgOptions.Reverse.value(), - .Regexp = SearchDlgOptions.Regexp.value(), - .PreserveStyle = SearchDlgOptions.PreserveStyle.value() + .CaseSensitive = LastSearchDlgParams.CaseSensitive.value(), + .WholeWords = LastSearchDlgParams.WholeWords.value(), + .Reverse = LastSearchDlgParams.Reverse.value(), + .Regexp = LastSearchDlgParams.Regexp.value(), + .PreserveStyle = LastSearchDlgParams.PreserveStyle.value() }, SearchLength, GetWordDiv() @@ -3507,7 +3468,7 @@ bool Editor::Search(bool Next) m_FoundPos = CurPos; m_FoundSize = SearchLength; - if(FindAllReferences) + if(FindAll) { int NextPos = CurPos + (SearchLength? SearchLength : 1); @@ -3532,7 +3493,7 @@ bool Editor::Search(bool Next) if (!EdOpt.PersistentBlocks) UnmarkBlock(); - if (EdOpt.SearchSelFound && !ReplaceMode) + if (EdOpt.SearchSelFound && !LastSearchDlgParams.ReplaceMode) { Pasting++; UnmarkBlock(); @@ -3565,7 +3526,7 @@ bool Editor::Search(bool Next) if (TabCurPos + SearchLength + 8 > CurPtr->GetLeftPos() + ObjWidth()) CurPtr->SetLeftPos(TabCurPos + SearchLength + 8 - ObjWidth()); - if (!ReplaceMode) + if (!LastSearchDlgParams.ReplaceMode) { CurPtr->SetCurPos(m_FoundPos + (EdOpt.SearchCursorAtEnd? SearchLength : 0)); break; @@ -3590,7 +3551,7 @@ bool Editor::Search(bool Next) Progress.reset(); MsgCode = Message(0, - msg(lng::MEditReplaceTitle), + msg(lng::MSearchReplaceReplaceTitle), { msg(lng::MEditAskReplace), quote_unconditional(CurPtr->GetString().substr(CurPos, SearchLength)), @@ -3710,7 +3671,7 @@ bool Editor::Search(bool Next) CurPtr->SetString(NewStr, true); CurPtr->SetCurPos(CurPos + static_cast(strReplaceStrCurrent.size())); - if (EdOpt.SearchSelFound && !ReplaceMode) + if (EdOpt.SearchSelFound && !LastSearchDlgParams.ReplaceMode) { UnmarkBlock(); BeginStreamMarking(CurPtr); @@ -3727,11 +3688,11 @@ bool Editor::Search(bool Next) } CurPos = m_it_CurLine->GetCurPos(); - if ((Skip || ZeroLength) && !SearchDlgOptions.Reverse.value()) + if ((Skip || ZeroLength) && !Reverse) { CurPos++; } - if (!(Skip || ZeroLength) && SearchDlgOptions.Reverse.value()) + if (!(Skip || ZeroLength) && Reverse) { (m_it_CurLine = CurPtr = m_FoundLine)->SetCurPos(CurPos = m_FoundPos); } @@ -3739,7 +3700,7 @@ bool Editor::Search(bool Next) } else { - if (SearchDlgOptions.Reverse.value()) + if (Reverse) { if (CurPtr == Lines.begin()) { @@ -3763,7 +3724,7 @@ bool Editor::Search(bool Next) } Show(); - if(FindAllReferences && MatchFound) + if(FindAll && MatchFound) { const auto MenuY1 = ScrY - 20; const auto MenuY2 = MenuY1 + std::min(static_cast(FindAllList->size()), 10) + 2; @@ -3884,7 +3845,7 @@ bool Editor::Search(bool Next) if (!MatchFound && !UserBreak) Message(MSG_WARNING, - msg(lng::MEditSearchTitle), + msg(lng::MSearchReplaceSearchTitle), { msg(lng::MEditNotFound), QuotedStr @@ -5019,7 +4980,6 @@ void Editor::VCopy(int Append) if (Clip->Open()) { - string CopyData; if (Append) @@ -6214,11 +6174,6 @@ Editor::numbered_iterator Editor::GetStringByNumber(int DestLine) return CurPtr; } -void Editor::SetReplaceMode(bool Mode) -{ - ReplaceMode = Mode; -} - int Editor::GetLineCurPos() const { return m_it_CurLine->GetTabCurPos(); diff --git a/far/editor.hpp b/far/editor.hpp index 6e4c893683..e26a684076 100644 --- a/far/editor.hpp +++ b/far/editor.hpp @@ -142,7 +142,6 @@ class Editor final: public SimpleScreenObject void AutoDeleteColors(); int GetId() const { return EditorID; } - static void SetReplaceMode(bool Mode); static eol GetDefaultEOL(); struct EditorUndoData; @@ -381,8 +380,9 @@ class Editor final: public SimpleScreenObject Options::EditorOptions EdOpt; int Pasting{}; int XX2{}; //scrollbar - string strLastSearchStr; - SearchReplaceDlgOptions LastSearchDlgOptions; + + SearchReplaceDlgParams LastSearchDlgParams; + bool ReplaceAll{}; int EditorID{}; int EditorControlLock{}; diff --git a/far/farlang.templ.m4 b/far/farlang.templ.m4 index be8a0ab5fa..52782b02da 100644 --- a/far/farlang.templ.m4 +++ b/far/farlang.templ.m4 @@ -6481,6 +6481,260 @@ MCannotSetSecurity "Немагчыма надаць правы доступа да файлу" "Negaliu nustatyti failo priėjimo teisių failui" +MSearchReplaceSearchTitle +l: +"Поиск" +"Search" +"Hledání" +"Suchen" +"Keresés" +"Szukaj" +"Buscar" +"Hľadanie" +"Ricerca" +"Пошук" +"Пошук" +"Paieška" + +MSearchReplaceReplaceTitle +l: +"Замена" +"Replace" +"Nahradit" +"Ersetzen" +"Keresés és csere" +"Zamień" +"Reemplazar" +"Nahradiť" +"Sostituisci" +"Заміна" +"Змена" +"Pakeisti" + +MSearchReplaceText +"&Текст" +"&Text" +"&Text" +"&Text" +upd:"&Szöveg" +"&Tekst" +upd:"Cadena de &texto" +"&Text" +"&Testo" +"&Текст" +"&Тэкст" +upd:"Ieškoti &teksto" + +MSearchReplaceHex +"16-ричный &код" +"&Hex" +"He&x" +"&Hex (xx xx …)" +upd:"&Hexákra" +"Sz&esnastkowo" +upd:"Cadena &hexadecimal" +"He&x" +"&Esadecimale" +"16-ковий &код" +"&Hex" +upd:"Ieškoti &hex" + +MSearchReplacePickWord +"&Слово" +"W&ord" +"Slovo" +upd:"Word" +upd:"Word" +"Słowo" +"Palabra" +"Slovo" +"Parola" +"&Слово" +"&Слова" +upd:"W&ord" + +MSearchReplacePickSelection +"&Выделение" +"Se&lection" +"Výběr" +upd:"Selection" +upd:"Selection" +"Zaznaczenie" +"Selección" +"Výber" +"Selezione" +"В&иділення" +"&Вылучэнне" +upd:"Se&lection" + +MSearchReplaceSearchFor +"&Искать" +"&Search for" +"&Hledat" +"&Suchen nach" +"&Keresés:" +"&Znajdź" +"&Buscar por" +"&Hľadať" +"Ricerca &Di" +"&Шукати" +"&Шукаць" +"&Rasti" + +MSearchReplaceReplaceWith +"Заменить &на" +"R&eplace with" +"Nahradit &s" +"&Ersetzen mit" +"&Erre cseréli:" +"Zamień &na" +"R&eemplazar con" +"Nahradiť &čím" +"Sostituisci &Con" +"Замінити &на" +"Змяніць &на" +"Pa&keisti" + +MSearchReplaceCase +"&Учитывать регистр" +"&Case sensitive" +"&Rozlišovat velikost písmen" +"G&roß-/Kleinschrb." +"&Nagy/kisbetű érz." +"&Uwzględnij wielkość znaków" +"Sensible min./ma&y." +"&malé a VEĽKÉ" +"&Minuscole/MAIUSCOLE" +"&Враховувати регістр" +"&Улічваць рэгістр" +"&Didžiosios skiriasi" + +MSearchReplaceWholeWords +"Только &целые слова" +"&Whole words" +"&Celá slova" +"&Ganze Wörter" +"Csak e&gész szavak" +"&Tylko całe słowa" +"&Palabras enteras" +"&Celé slová" +"&Parole Intere" +"Лише &цілі слова" +"Толькі по&ўныя словы" +"Visi ž&odžiai" + +MSearchReplaceReverse +"Обратн&ый поиск" +"Re&verse search" +"&Zpětné hledání" +"Richtung um&kehren" +"&Visszafelé keres" +"Szukaj w &odwrotnym kierunku" +"Búsqueda &inversa" +"Opačné h&ľadanie" +"Ricerca In&versa" +"Зворотний пошу&к" +"Зваротн&ы пошук" +"At&virkščia paieška" + +MSearchReplaceRegexp +"&Регулярные выражения" +"Re&gular expressions" +"Re&gulární výrazy" +"Reguläre Ausdrücke" +upd:"Re&gular expressions" +"Wyrażenie ®ularne" +"Expresiones re&gulares" +"Re&gulárne výrazy" +"E&spressione Regolare" +"&Регулярні вирази" +"&Рэгулярныя выразы" +upd:"Re&gular expressions" + +MSearchReplaceFuzzy +"Нестроги&й поиск" +"Fu&zzy search" +upd:"Fu&zzy search" +upd:"Fu&zzy search" +upd:"Fu&zzy search" +"W&yszuk. rozmyte" +"Búsqueda di&fusa" +upd:"Fu&zzy search" +upd:"Fu&zzy search" +upd:"Fu&zzy search" +"Нястрог&і пошук" +upd:"Fu&zzy search" + +MSearchReplacePreserveStyle +"&Сохранять стиль" +"&Preserve style" +"&Zachovat styl" +upd:"&Preserve Stil" +upd:"&Megőrzése stílus" +"&Zachowaj styl" +"Preservar es&tilo" +"&Zachovať štýl" +"Mantieni Lo St&ile" +"&Зберігати стиль" +"Захоўваць &стыль" +upd:"&Preserve style" + +MSearchReplaceSearch +"Искать" +"Search" +"Hledat" +"Suchen" +"Kere&sés" +"&Szukaj" +"Buscar" +"Hľadať" +"&Ricerca" +"Шукати" +"Шукаць" +"&Ieškoti" + +MSearchReplaceReplace +"&Замена" +"&Replace" +"&Nahradit" +"E&rsetzen" +"&Csere" +"Za&mień" +"&Reemplazar" +"&Nahradiť" +"&Sostituisci" +"&Замінити" +"&Змена" +"Pakeisti &į" + +MSearchReplaceAll +"Вс&ё" +"&All" +"Všechn&y" +"&Alles" +upd:"&All" +"&Wszystko" +"&Todo" +"Všetk&y" +"&Tutti" +"Вс&е" +"Ус&ё" +"&Atšaukti" + +MSearchReplaceCancel +"Отменить" +"Cancel" +"Storno" +"Abbruch" +"&Mégsem" +"&Anuluj" +"Cancelar" +"Storno" +"&Annulla" +"Скасувати" +"Адмяніць" +"&Atšaukti" + MEditTitle l: "Редактор" @@ -6785,256 +7039,30 @@ MEditROOpen "Вы хотите редактировать его?" "Do you wish to edit it?" "Přejete si ho upravit?" -"Wollen Sie sie dennoch bearbeiten?" -"Mégis szerkeszti?" -"Czy chcesz go edytować?" -"Desea editarlo?" -"Chcete ho upraviť?" -"Vuoi Modificarlo?" -"Ви бажаєте редагувати його?" -"Вы жадаеце мяняць яго?" -"Ar norite jį redaguoti?" - -MEditCanNotEditDirectory -l: -"Невозможно редактировать папку" -"It is impossible to edit the folder" -"Nelze editovat adresář" -"Es ist nicht möglich den Ordner zu bearbeiten" -"A mappa nem szerkeszthető" -"Nie można edytować folderu" -"Es imposible editar el directorio" -"Nemôžem upraviť priečinok" -"Impossibile Modificare La Cartella" -"Неможливо редагувати папку" -"Немагчыма змяніць каталог" -upd:"It is impossible to edit the folder" - -MEditSearchTitle -l: -"Поиск" -"Search" -"Hledat" -"Suchen" -"Keresés" -"Szukaj" -"Buscar" -"Hľadanie" -"Ricerca" -"Пошук" -"Пошук" -"Paieška" - -MEditSearchFor -"&Искать" -"&Search for" -"&Hledat" -"&Suchen nach" -"&Keresés:" -"&Znajdź" -"&Buscar por" -"&Hľadať" -"Ricerca &Di" -"&Шукати" -"&Шукаць" -upd:"&Search for" - -MEditSearchPickWord -"&Слово" -"W&ord" -"Slovo" -upd:"Word" -upd:"Word" -"Słowo" -"Palabra" -"Slovo" -"Parola" -"&Слово" -"&Слова" -upd:"W&ord" - -MEditSearchPickSelection -"&Выделение" -"Se&lection" -"Výběr" -upd:"Selection" -upd:"Selection" -"Zaznaczenie" -"Selección" -"Výber" -"Selezione" -"В&иділення" -"&Вылучэнне" -upd:"Se&lection" - -MEditSearchCase -"&Учитывать регистр" -"&Case sensitive" -"&Rozlišovat velikost písmen" -"G&roß-/Kleinschrb." -"&Nagy/kisbetű érz." -"&Uwzględnij wielkość znaków" -"Sensible min./ma&y." -"&malé a VEĽKÉ" -"&Minuscole/MAIUSCOLE" -"&Враховувати регістр" -"&Улічваць памер букв" -"&Didžiosios skiriasi" - -MEditSearchWholeWords -"Только &целые слова" -"&Whole words" -"&Celá slova" -"&Ganze Wörter" -"Csak e&gész szavak" -"&Tylko całe wyrazy" -"&Palabras enteras" -"&Celé slová" -"&Parole Intere" -"Лише &цілі слова" -"Толькі по&ўныя словы" -"Visi ž&odžiai" - -MEditSearchReverse -"Обратн&ый поиск" -"Re&verse search" -"&Zpětné hledání" -"Richtung um&kehren" -"&Visszafelé keres" -"Szukaj w &odwrotnym kierunku" -"Búsqueda &inversa" -"Opačné h&ľadanie" -"Ricerca In&versa" -"Зворотний пошу&к" -"Зваротн&ы пошук" -"At&virkščia paieška" - -MEditSearchRegexp -"&Регулярные выражения" -"Re&gular expressions" -"Re&gulární výrazy" -"Reguläre Ausdrücke" -upd:"Re&gular expressions" -"Wyrażenie ®ularne" -"Expresiones re&gulares" -"Re&gulárne výrazy" -"E&spressione Regolare" -"&Регулярні вирази" -"&Рэгулярныя выразы" -upd:"Re&gular expressions" - -MEditSearchFuzzy -"Нестроги&й поиск" -"Fu&zzy search" -upd:"Fu&zzy search" -upd:"Fu&zzy search" -upd:"Fu&zzy search" -"W&yszuk. rozmyte" -"Búsqueda di&fusa" -upd:"Fu&zzy search" -upd:"Fu&zzy search" -upd:"Fu&zzy search" -"Нястрог&і пошук" -upd:"Fu&zzy search" - -MEditSearchPreserveStyle -"&Сохранять стиль" -"&Preserve style" -"&Zachovat styl" -upd:"&Preserve Stil" -upd:"&Megőrzése stílus" -"&Zachowaj styl" -"Preservar es&tilo" -"&Zachovať štýl" -"Mantieni Lo St&ile" -"&Зберігати стиль" -"Захоўваць &стыль" -upd:"&Preserve style" - -MEditSearchSearch -"Искать" -"Search" -"Hledat" -"Suchen" -"Kere&sés" -"&Szukaj" -"Buscar" -"Hľadať" -"&Ricerca" -"Шукати" -"Шукаць" -"&Ieškoti" - -MEditSearchAll -"Вс&ё" -"&All" -"Všechn&y" -"&Alles" -upd:"&All" -"&Wszystko" -"&Todo" -"Všetk&y" -"&Tutti" -"Вс&е" -"Ус&ё" -"&Atšaukti" - -MEditSearchCancel -"Отменить" -"Cancel" -"Storno" -"Abbruch" -"&Mégsem" -"&Anuluj" -"Cancelar" -"Storno" -"&Annulla" -"Скасувати" -"Адмяніць" -"Keisti" - -MEditReplaceTitle -l: -"Замена" -"Replace" -"Nahradit" -"Ersetzen" -"Keresés és csere" -"Zamień" -"Reemplazar" -"Nahradiť" -"Sostituisci" -"Заміна" -"Змена" -"Pakeisti" - -MEditReplaceWith -"Заменить &на" -"R&eplace with" -"Nahradit &s" -"&Ersetzen mit" -"&Erre cseréli:" -"Zamień &na" -"R&eemplazar con" -"Nahradiť &čím" -"Sostituisci &Con" -"Замінити &на" -"Змяніць &на" -"Pa&keisti" - -MEditReplaceReplace -"&Замена" -"&Replace" -"&Nahradit" -"E&rsetzen" -"&Csere" -"Za&mień" -"&Reemplazar" -"&Nahradiť" -"&Sostituisci" -"&Замінити" -"&Змена" -"Pakeisti &į" +"Wollen Sie sie dennoch bearbeiten?" +"Mégis szerkeszti?" +"Czy chcesz go edytować?" +"Desea editarlo?" +"Chcete ho upraviť?" +"Vuoi Modificarlo?" +"Ви бажаєте редагувати його?" +"Вы жадаеце мяняць яго?" +"Ar norite jį redaguoti?" + +MEditCanNotEditDirectory +l: +"Невозможно редактировать папку" +"It is impossible to edit the folder" +"Nelze editovat adresář" +"Es ist nicht möglich den Ordner zu bearbeiten" +"A mappa nem szerkeszthető" +"Nie można edytować folderu" +"Es imposible editar el directorio" +"Nemôžem upraviť priečinok" +"Impossibile Modificare La Cartella" +"Неможливо редагувати папку" +"Немагчыма змяніць каталог" +upd:"It is impossible to edit the folder" MEditSearchingFor l: @@ -11529,6 +11557,34 @@ upd:"Zeichenta&belle verwenden:" "Ужыць кадыро&ўку:" upd:"Using code pa&ge:" +MFindFileAllCodePages +"Все стандартные кодовые страницы" +"All standard code pages" +"Všechny kódové stránky" +upd:"Alle Zeichentabellen" +upd:"Minden kódlappal" +"Wszystkie zainstalowane" +"Todas las páginas de códigos estándar" +"Všetky tabuľky znakov" +"Tutte Le Tabella Caratteri" +"Усі стандартні кодові сторінки" +"Усе стандарныя кадыроўкі" +upd:"All standard code pages" + +MFindFileSelectedCodePages +"Отмеченные кодовые страницы" +"Selected code pages" +"Vybrané kódové stránky" +"Gewählte Codepages" +upd:"Selected code pages" +"Wybrana strona kodowa" +"Páginas de códigos seleccionadas" +"Zvolené kódové stránky" +"Tabelle Caratteri Selezionate" +"Позначені кодові сторінки" +"Адзначаныя кадыроўкі" +upd:"Selected code pages" + MFindFileCase "&Учитывать регистр" "&Case sensitive" @@ -11571,35 +11627,21 @@ upd:"Fu&zzy search" "Нястрог&і пошук" upd:"Fu&zzy search" -MFindFileAllCodePages -"Все стандартные кодовые страницы" -"All standard code pages" -"Všechny kódové stránky" -upd:"Alle Zeichentabellen" -upd:"Minden kódlappal" -"Wszystkie zainstalowane" -"Todas las páginas de códigos estándar" -"Všetky tabuľky znakov" -"Tutte Le Tabella Caratteri" -"Усі стандартні кодові сторінки" -"Усе стандарныя кадыроўкі" -upd:"All standard code pages" - -MFindFileSelectedCodePages -"Отмеченные кодовые страницы" -"Selected code pages" -"Vybrané kódové stránky" -"Gewählte Codepages" -upd:"Selected code pages" -"Wybrana strona kodowa" -"Páginas de códigos seleccionadas" -"Zvolené kódové stránky" -"Tabelle Caratteri Selezionate" -"Позначені кодові сторінки" -"Адзначаныя кадыроўкі" -upd:"Selected code pages" +MFindFileNotContaining +"&Не содержащих" +"&Not containing" +"Neobsahuje" +"Nicht enthalten" +upd:"Not containing" +"&Nie zawierające" +"No conteniendo" +"Neobsahuje" +"Non Contenente" +"Які не містять" +"&Не змяшчае" +upd:"&Not containing" -MFindArchives +MFindFileArchives "Искать в а&рхивах" "Search in arch&ives" "Hledat v a&rchívech" @@ -11613,7 +11655,7 @@ MFindArchives "Шукаць у а&рхівах" "Ieškoti arch&yvuose" -MFindFolders +MFindFileFolders "Искать п&апки" "Search for f&olders" "Hledat a&dresáře" @@ -11627,7 +11669,7 @@ MFindFolders "Шукаць к&аталогі" upd:"Search for f&olders" -MFindSymLinks +MFindFileSymLinks "Искать в символи&ческих ссылках" "Search in symbolic lin&ks" "Hledat v s&ymbolických lincích" @@ -11641,7 +11683,7 @@ MFindSymLinks "Шукаць у сімвалі&чных спасылках" upd:"Search in symbolic lin&ks" -MFindAlternateStreams +MFindFileAlternateStreams "Искать в альтернативных потоках" "Search in a<ernate streams" "Hledat v alternativních streamech" @@ -11655,21 +11697,7 @@ upd:"Search in alternate streams" "Шукаць у струменях" upd:"Search in a<ernate streams" -MSearchNotContaining -"&Не содержащих" -"&Not containing" -"Neobsahuje" -"Nicht enthalten" -upd:"Not containing" -"&Nie zawierające" -"No conteniendo" -"Neobsahuje" -"Non Contenente" -"Які не містять" -"&Не змяшчае" -upd:"&Not containing" - -MSearchWhere +MFindFileSearchArea "Выберите &область поиска:" "Select search &area:" "Zvolte oblast hledání:" @@ -11683,7 +11711,7 @@ upd:"Suchbereich:" "В&обласць пошуку" upd:"Select search &area:" -MSearchAllDisks +MFindFileSearchAllDisks "На всех несъёмных &дисках" "In &all non-removable drives" "Ve všech p&evných jednotkách" @@ -11697,7 +11725,7 @@ MSearchAllDisks "На ўсіх нязменных &дысках" "Ieškoti &visuose fiksuotuose diskuose" -MSearchAllButNetwork +MFindFileSearchAllButNetwork "На всех &локальных дисках" "In all &local drives" "Ve všech &lokálních jednotkách" @@ -11711,7 +11739,7 @@ MSearchAllButNetwork "На ўсіх &мясцовых дысках" upd:"In all &local drives" -MSearchInPATH +MFindFileSearchInPATH "В PATH-катало&гах" "In &PATH folders" "V adresářích z &PATH" @@ -11725,7 +11753,7 @@ MSearchInPATH "В PATH-катало&гах" upd:"In &PATH folders" -MSearchFromRootOfDrive +MFindFileSearchFromRootOfDrive "С кор&ня диска" "From the &root of" "V &kořeni od" @@ -11739,7 +11767,7 @@ MSearchFromRootOfDrive "З кора&ня дыска" upd:"From the &root of" -MSearchFromRootFolder +MFindFileSearchFromRootFolder "С кор&невой папки" "From the &root folder" "V kořeno&vém adresáři" @@ -11753,7 +11781,7 @@ MSearchFromRootFolder "З кара&нёвага каталога" "Ieškoti nuo ša&kninio katalogo" -MSearchFromCurrent +MFindFileSearchFromCurrent "С &текущей папки" "From the curre&nt folder" "V tomto adresář&i" @@ -11767,7 +11795,7 @@ MSearchFromCurrent "З бугучага ка&талога" "Ieškoti nuo &einamo katalogo" -MSearchInCurrent +MFindFileSearchInCurrent "Только в теку&щей папке" "The current folder onl&y" "P&ouze v tomto adresáři" @@ -11781,7 +11809,7 @@ MSearchInCurrent "Толькі &ў бягучым каталоге" "Ieškoti tik eina&mame kataloge" -MSearchInSelected +MFindFileSearchInSelected "В &отмеченных папках" "&Selected folders" "Ve vy&braných adresářích" @@ -11795,7 +11823,7 @@ MSearchInSelected "&Абраныя каталогі" "Ieškoti paž&ymėtuose kataloguose" -MFindUseFilter +MFindFileUseFilter "Исполь&зовать фильтр" "&Use filter" "Použít f&iltr" @@ -11809,7 +11837,7 @@ MFindUseFilter "У&жыць фільтр" upd:"&Use filter" -MFindUsingFilter +MFindFileUsingFilter "используя фильтр" "using filter" "používám filtr" @@ -11879,7 +11907,7 @@ MFindFileAdvanced "Да&даткова" upd:"Advance&d" -MFindSearchingIn +MFindFileSearchingIn "Поиск {0} в" "Searching {0} in" "Hledám {0} v" @@ -11893,7 +11921,7 @@ MFindSearchingIn "Шукаць {0} у" "Ieškau {0} į" -MFindNewSearch +MFindFileNewSearch "&Новый поиск" "&New search" "&Nové hledání" @@ -11907,7 +11935,7 @@ MFindNewSearch "&Новы пошук" "&Nauja paieška" -MFindGoTo +MFindFileGoTo "Пе&рейти" "&Go to" "&Jdi na" @@ -11921,7 +11949,7 @@ MFindGoTo "Пе&райсці" "&Eiti" -MFindView +MFindFileView "&Смотреть" "&View" "Zo&braz" @@ -11935,7 +11963,7 @@ MFindView "Гляд&зець" "&Žiūrėti" -MFindPanel +MFindFilePanel "Пане&ль" "&Panel" "&Panel" @@ -11949,7 +11977,7 @@ MFindPanel "&Панэль" "&Langas" -MFindStop +MFindFileStop "С&топ" "&Stop" "&Stop" @@ -11963,7 +11991,7 @@ MFindStop "Спыні&ць" upd:"&Stop" -MFindDone +MFindFileDone l: "Поиск закончен. Найдено файлов: {0}, папок: {1}" "Search done. Found files: {0}, folders: {1}" @@ -11978,7 +12006,7 @@ l: "Пошук завершаны. Знойдзена файлаў:{0}, каталогаў: {1}" "Paieška baigta. Rasta files: {0}, folders: {1}" -MFindCancel +MFindFileCancel "Отм&ена" "&Cancel" "&Storno" @@ -11992,7 +12020,7 @@ MFindCancel "Адм&яніць" "&Atšaukti" -MFindFound +MFindFileFound l: "Файлов: {0}, папок: {1}" "Files: {0}, folders: {1}" @@ -21196,161 +21224,6 @@ upd:"Osz" "Кал" "Stl" -MViewSearchTitle -l: -"Поиск" -"Search" -"Hledat" -"Durchsuchen" -"Keresés" -"Szukaj" -"Buscar" -"Hľadanie" -"Ricerca" -"Пошук" -"Пошук" -"Paieška" - -MViewSearchFor -"&Искать" -"&Search for" -"H&ledat" -"&Suchen nach" -"&Keresés:" -"&Znajdź" -"&Buscar por" -"H&ľadať" -"&Ricerca Di" -"&Шукати" -"&Шукаць" -"&Rasti" - -MViewSearchForText -"&Текст" -"&Text" -"&Text" -"&Text" -upd:"&Szöveg" -"&Tekst" -upd:"Cadena de &texto" -"&Text" -"&Testo" -"&Текст" -"&Тэкст" -upd:"Ieškoti &teksto" - -MViewSearchForHex -"16-ричный &код" -"&Hex" -"He&x" -"&Hex (xx xx …)" -upd:"&Hexákra" -"Sz&esnastkowo" -upd:"Cadena &hexadecimal" -"He&x" -"&Esadecimale" -"16-ковий &код" -"&Hex" -upd:"Ieškoti &hex" - -MViewSearchCase -"&Учитывать регистр" -"&Case sensitive" -"&Rozlišovat velikost písmen" -"Gr&oß-/Kleinschreibung" -"&Nagy/kisbetű érzékeny" -"&Uwzględnij wielkość znaków" -"Sensible min./ma&y." -"&malé a VEĽKÉ" -"&MAIUSCOLE/minuscole" -"&Учитивать регистр" -"&Улічваць рэгістр" -"&Didžiosios skiriasi" - -MViewSearchWholeWords -"Только &целые слова" -"&Whole words" -"Celá &slova" -"Ganze &Wörter" -"Csak e&gész szavak" -"Tylko &całe wyrazy" -"&Palabras enteras" -"Celé &slová" -"Parole Intere" -"Только &целие слова" -"Толькі по&ўныя словы" -"Visi ž&odžiai" - -MViewSearchFuzzy -"Нестроги&й поиск" -"Fu&zzy search" -upd:"Fu&zzy search" -upd:"Fu&zzy search" -upd:"Fu&zzy search" -"W&yszuk. rozmyte" -"Búsqueda di&fusa" -upd:"Fu&zzy search" -upd:"Fu&zzy search" -upd:"Fu&zzy search" -upd:"Fu&zzy search" -upd:"Fu&zzy search" - -MViewSearchReverse -"Обратн&ый поиск" -"Re&verse search" -"&Zpětné hledání" -"Richtung um&kehren" -"&Visszafelé keres" -"Szukaj w &odwrotnym kierunku" -"Búsqueda in&versa" -"&Opačné hľadanie" -"Ricerca In&versa" -"Обратн&ий Пошук" -"Адваротн&ы пошук" -"At&virkščia paieška" - -MViewSearchRegexp -"&Регулярные выражения" -"Re&gular expressions" -"Re&gulární výrazy" -"&Reguläre Ausdrücke" -upd:"Re&gular expressions" -"Wyrażenie ®ularne" -"Expresiones re&gulares" -"Re&gulárne výrazy" -"Espressione Re&golare" -"&Регулярние виражения" -"&Рэгулярныя выразы" -upd:"Re&gular expressions" - -MViewSearchSearch -"Искать" -"Search" -"Hledat" -"Suchen" -"Keres" -"&Szukaj" -"Buscar" -"Hľadať" -"R&icerca" -"Шукати" -"Шукаць" -"&Ieškoti" - -MViewSearchCancel -"Отменить" -"Cancel" -"Storno" -"Abbrechen" -"Mégsem" -"&Anuluj" -"Cancelar" -"Storno" -"&Annulla" -"Скасувати" -"Адмяніць" -"&Atšaukti" - MViewSearchingFor l: "Поиск" @@ -23031,35 +22904,6 @@ MDocumentsHelpTitle "Дакументы" upd:"Documents help" -MHelpSearchTitle -l: -"Поиск" -"Search" -"Hledání" -"Suchen" -"Keresés" -"Szukaj" -"Buscar" -"Hľadanie" -"Ricerca" -"Пошук" -"Пошук" -upd:"Search" - -MHelpSearchingFor -"&Искать" -"&Search for" -"&Hledat" -"&Suchen nach" -"&Keresés:" -"&Znajdź" -"&Buscar por" -"&Hľadať" -"Cerca" -"&Шукати" -"&Шукаць" -upd:"&Search for" - MHelpSearchCannotFind "Строка не найдена" "Could not find the string" diff --git a/far/findfile.cpp b/far/findfile.cpp index eabfa92e04..fc3a88148e 100644 --- a/far/findfile.cpp +++ b/far/findfile.cpp @@ -605,11 +605,11 @@ string& FindFiles::PrepareDriveNameStr(string &strSearchFromRoot) const (Global->CtrlObject->Cp()->ActivePanel()->GetMode() == panel_mode::PLUGIN_PANEL && Global->CtrlObject->Cp()->ActivePanel()->IsVisible()) ) { - strSearchFromRoot = msg(lng::MSearchFromRootFolder); + strSearchFromRoot = msg(lng::MFindFileSearchFromRootFolder); } else { - strSearchFromRoot = concat(msg(lng::MSearchFromRootOfDrive), L' ', strCurDir); + strSearchFromRoot = concat(msg(lng::MFindFileSearchFromRootOfDrive), L' ', strCurDir); } return strSearchFromRoot; @@ -1487,7 +1487,7 @@ intptr_t FindFiles::FindDlgProc(Dialog* Dlg, intptr_t Msg, intptr_t Param1, void const auto refresh_status = [&] { - const auto strDataStr = format(msg(lng::MFindFound), m_FileCount, m_DirCount); + const auto strDataStr = format(msg(lng::MFindFileFound), m_FileCount, m_DirCount); Dlg->SendMessage(DM_SETTEXTPTR, FD_SEPARATOR1, UNSAFE_CSTR(strDataStr)); if (m_Searcher->Finished()) @@ -1500,7 +1500,7 @@ intptr_t FindFiles::FindDlgProc(Dialog* Dlg, intptr_t Msg, intptr_t Param1, void if (!strFindStr.empty()) { - strSearchStr = format(msg(lng::MFindSearchingIn), quote_unconditional(truncate_right(strFindStr, 10))); + strSearchStr = format(msg(lng::MFindFileSearchingIn), quote_unconditional(truncate_right(strFindStr, 10))); Dlg->SendMessage(DM_SETTEXTPTR, FD_TEXT_STATUS_PERCENTS, UNSAFE_CSTR(format(FSTR(L"{:3}%"sv), m_Percent))); } @@ -1554,11 +1554,11 @@ intptr_t FindFiles::FindDlgProc(Dialog* Dlg, intptr_t Msg, intptr_t Param1, void Finalized = true; SCOPED_ACTION(Dialog::suppress_redraw)(Dlg); - const auto strMessage = format(msg(lng::MFindDone), m_FileCount, m_DirCount); + const auto strMessage = format(msg(lng::MFindFileDone), m_FileCount, m_DirCount); Dlg->SendMessage(DM_SETTEXTPTR, FD_SEPARATOR1, nullptr); Dlg->SendMessage(DM_SETTEXTPTR, FD_TEXT_STATUS, UNSAFE_CSTR(strMessage)); Dlg->SendMessage(DM_SETTEXTPTR, FD_TEXT_STATUS_PERCENTS, nullptr); - Dlg->SendMessage(DM_SETTEXTPTR, FD_BUTTON_STOP, const_cast(msg(lng::MFindCancel).c_str())); + Dlg->SendMessage(DM_SETTEXTPTR, FD_BUTTON_STOP, const_cast(msg(lng::MFindFileCancel).c_str())); ConsoleTitle::SetFarTitle(strMessage); Dlg->SendMessage(DM_ENABLEREDRAW, 1, nullptr); @@ -2696,14 +2696,14 @@ bool FindFiles::FindFilesProcess() if (UseFilter) { - append(strTitle, L" ("sv, msg(lng::MFindUsingFilter), L')'); + append(strTitle, L" ("sv, msg(lng::MFindFileUsingFilter), L')'); } } else { if (UseFilter) { - append(strTitle, L" ("sv, msg(lng::MFindUsingFilter), L')'); + append(strTitle, L" ("sv, msg(lng::MFindFileUsingFilter), L')'); } } @@ -2718,11 +2718,11 @@ bool FindFiles::FindFilesProcess() { DI_TEXT, {{5, DlgHeight-5}, {DlgWidth-(strFindStr.empty()? 6 : 12), DlgHeight-5}}, DIF_SHOWAMPERSAND, L"…"sv }, { DI_TEXT, {{DlgWidth-9, DlgHeight-5}, {DlgWidth-6, DlgHeight-5}}, (strFindStr.empty() ? DIF_HIDDEN : DIF_NONE), }, { DI_TEXT, {{-1, DlgHeight-4}, {0, DlgHeight-4}}, DIF_SEPARATOR, }, - { DI_BUTTON, {{0, DlgHeight-3}, {0, DlgHeight-3}}, DIF_CENTERGROUP | DIF_FOCUS | DIF_DEFAULTBUTTON, msg(lng::MFindNewSearch), }, - { DI_BUTTON, {{0, DlgHeight-3}, {0, DlgHeight-3}}, DIF_CENTERGROUP | DIF_DISABLE, msg(lng::MFindGoTo), }, - { DI_BUTTON, {{0, DlgHeight-3}, {0, DlgHeight-3}}, DIF_CENTERGROUP | DIF_DISABLE, msg(lng::MFindView), }, - { DI_BUTTON, {{0, DlgHeight-3}, {0, DlgHeight-3}}, DIF_CENTERGROUP | DIF_DISABLE, msg(lng::MFindPanel), }, - { DI_BUTTON, {{0, DlgHeight-3}, {0, DlgHeight-3}}, DIF_CENTERGROUP, msg(lng::MFindStop), }, + { DI_BUTTON, {{0, DlgHeight-3}, {0, DlgHeight-3}}, DIF_CENTERGROUP | DIF_FOCUS | DIF_DEFAULTBUTTON, msg(lng::MFindFileNewSearch), }, + { DI_BUTTON, {{0, DlgHeight-3}, {0, DlgHeight-3}}, DIF_CENTERGROUP | DIF_DISABLE, msg(lng::MFindFileGoTo), }, + { DI_BUTTON, {{0, DlgHeight-3}, {0, DlgHeight-3}}, DIF_CENTERGROUP | DIF_DISABLE, msg(lng::MFindFileView), }, + { DI_BUTTON, {{0, DlgHeight-3}, {0, DlgHeight-3}}, DIF_CENTERGROUP | DIF_DISABLE, msg(lng::MFindFilePanel), }, + { DI_BUTTON, {{0, DlgHeight-3}, {0, DlgHeight-3}}, DIF_CENTERGROUP, msg(lng::MFindFileStop), }, }); ArcListItem* FindFileArcItem{}; @@ -3028,7 +3028,7 @@ FindFiles::FindFiles(): static string strLastFindMask = L"*.*"s, strLastFindStr; static string strSearchFromRoot; - strSearchFromRoot = msg(lng::MSearchFromRootFolder); + strSearchFromRoot = msg(lng::MFindFileSearchFromRootFolder); static FindFilesOptions LastOptions; @@ -3086,16 +3086,16 @@ FindFiles::FindFiles(): { DI_CHECKBOX, {{5, 10}, {0, 10}}, DIF_NONE, msg(lng::MFindFileCase), }, { DI_CHECKBOX, {{5, 11}, {0, 11}}, DIF_NONE, msg(lng::MFindFileWholeWords), }, { DI_CHECKBOX, {{5, 12}, {0, 12}}, DIF_NONE, msg(lng::MFindFileFuzzy), }, - { DI_CHECKBOX, {{5, 13}, {0, 13}}, DIF_NONE, msg(lng::MSearchNotContaining), }, - { DI_CHECKBOX, {{41, 10}, {0, 10}}, DIF_NONE, msg(lng::MFindArchives), }, - { DI_CHECKBOX, {{41, 11}, {0, 11}}, DIF_NONE, msg(lng::MFindFolders), }, - { DI_CHECKBOX, {{41, 12}, {0, 12}}, DIF_NONE, msg(lng::MFindSymLinks), }, - { DI_CHECKBOX, {{41, 13}, {0, 13}}, DIF_NONE, msg(lng::MFindAlternateStreams), }, + { DI_CHECKBOX, {{5, 13}, {0, 13}}, DIF_NONE, msg(lng::MFindFileNotContaining), }, + { DI_CHECKBOX, {{41, 10}, {0, 10}}, DIF_NONE, msg(lng::MFindFileArchives), }, + { DI_CHECKBOX, {{41, 11}, {0, 11}}, DIF_NONE, msg(lng::MFindFileFolders), }, + { DI_CHECKBOX, {{41, 12}, {0, 12}}, DIF_NONE, msg(lng::MFindFileSymLinks), }, + { DI_CHECKBOX, {{41, 13}, {0, 13}}, DIF_NONE, msg(lng::MFindFileAlternateStreams), }, { DI_TEXT, {{-1, 14}, {0, 14}}, DIF_SEPARATOR, }, { DI_VTEXT, {{39, 9 }, {39, 14}}, DIF_SEPARATORUSER, }, - { DI_TEXT, {{5, 15}, {0, 15}}, DIF_NONE, msg(lng::MSearchWhere), }, + { DI_TEXT, {{5, 15}, {0, 15}}, DIF_NONE, msg(lng::MFindFileSearchArea), }, { DI_COMBOBOX, {{5, 16}, {36, 16}}, DIF_DROPDOWNLIST | DIF_LISTNOAMPERSAND, }, - { DI_CHECKBOX, {{41, 16}, {0, 16}}, DIF_AUTOMATION, msg(lng::MFindUseFilter), }, + { DI_CHECKBOX, {{41, 16}, {0, 16}}, DIF_AUTOMATION, msg(lng::MFindFileUseFilter), }, { DI_TEXT, {{-1, 17}, {0, 17}}, DIF_SEPARATOR, }, { DI_BUTTON, {{0, 18}, {0, 18}}, DIF_CENTERGROUP | DIF_DEFAULTBUTTON, msg(lng::MFindFileFind), }, { DI_BUTTON, {{0, 18}, {0, 18}}, DIF_CENTERGROUP, msg(lng::MFindFileDrive), }, @@ -3114,13 +3114,13 @@ FindFiles::FindFiles(): FarListItem li[]= { - { 0, msg(lng::MSearchAllDisks).c_str() }, - { 0, msg(lng::MSearchAllButNetwork).c_str() }, - { 0, msg(lng::MSearchInPATH).c_str() }, + { 0, msg(lng::MFindFileSearchAllDisks).c_str() }, + { 0, msg(lng::MFindFileSearchAllButNetwork).c_str() }, + { 0, msg(lng::MFindFileSearchInPATH).c_str() }, { 0, strSearchFromRoot.c_str() }, - { 0, msg(lng::MSearchFromCurrent).c_str() }, - { 0, msg(lng::MSearchInCurrent).c_str() }, - { 0, msg(lng::MSearchInSelected).c_str() }, + { 0, msg(lng::MFindFileSearchFromCurrent).c_str() }, + { 0, msg(lng::MFindFileSearchInCurrent).c_str() }, + { 0, msg(lng::MFindFileSearchInSelected).c_str() }, }; static_assert(std::size(li) == FINDAREA_COUNT); @@ -3232,9 +3232,6 @@ FindFiles::FindFiles(): LastOptions = Options; strLastFindMask = strFindMask; strLastFindStr = strFindStr; - - if (!strFindStr.empty()) - Editor::SetReplaceMode(false); } while (FindFilesProcess()); diff --git a/far/global.cpp b/far/global.cpp index 2803c4bb15..2ae832833f 100644 --- a/far/global.cpp +++ b/far/global.cpp @@ -42,6 +42,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "config.hpp" #include "configdb.hpp" #include "manager.hpp" +#include "strmix.hpp" // Platform: #include "platform.fs.hpp" @@ -81,6 +82,22 @@ void global::StoreSearchString(string_view const Str, bool Hex) m_SearchString = Str; } +string global::GetSearchString(uintptr_t Codepage) +{ + if (GetSearchHex()) + return ConvertHexString(GetSearchString(), Codepage, true); + else + return GetSearchString(); +} + +void global::StoreSearchString(string_view Str, uintptr_t Codepage, bool Hex) +{ + if (Hex) + StoreSearchString(ConvertHexString(Str, Codepage, false), true); + else + StoreSearchString(Str, false); +} + global::far_clock::far_clock() { update(); diff --git a/far/global.hpp b/far/global.hpp index 2f172d876c..51ca7b022a 100644 --- a/far/global.hpp +++ b/far/global.hpp @@ -66,6 +66,8 @@ class global const string& GetSearchString() const { return m_SearchString; } bool GetSearchHex() const { return m_SearchHex; } void StoreSearchString(string_view Str, bool Hex); + string GetSearchString(uintptr_t Codepage); + void StoreSearchString(string_view Str, uintptr_t Codepage, bool Hex); // BUGBUG diff --git a/far/help.cpp b/far/help.cpp index 3d1324b49d..4b9ef3b6fd 100644 --- a/far/help.cpp +++ b/far/help.cpp @@ -188,7 +188,6 @@ class Help final: public window string strFullHelpPathName; string strCurPluginContents; // помним PluginContents (для отображения в заголовке) string strCtrlStartPosChar; - string strLastSearchStr; int FixCount{}; // количество строк непрокручиваемой области @@ -208,7 +207,8 @@ class Help final: public window bool IsNewTopic{true}; bool m_TopicFound{}; bool ErrorHelp{true}; - SearchReplaceDlgOptions LastSearchDlgOptions; + + SearchReplaceDlgParams LastSearchDlgParams; }; struct Help::StackHelpData @@ -232,7 +232,8 @@ Help::Help(private_tag): StackData(std::make_unique()), CurColor(colors::PaletteColorToFarColor(COL_HELPTEXT)), CtrlTabSize(Global->Opt->HelpTabSize), - LastSearchDlgOptions{ + LastSearchDlgParams + { .CaseSensitive = Global->GlobalSearchCaseSensitive, .WholeWords = Global->GlobalSearchWholeWords, .Regexp = Global->Opt->EdOpt.SearchRegexp, @@ -1429,30 +1430,9 @@ bool Help::ProcessKey(const Manager::Key& Key) // не поганим SelTopic, если и так в FoundContents if (StackData->strHelpTopic != FoundContents) { - string strLastSearchStr0=strLastSearchStr; - auto SearchDlgOptions{ LastSearchDlgOptions }; - - string strTempStr; - //int RetCode = GetString(msg(lng::MHelpSearchTitle),msg(lng::MHelpSearchingFor),L"HelpSearch",strLastSearchStr,strLastSearchStr0); - const int RetCode = GetSearchReplaceString( - false, - msg(lng::MHelpSearchTitle), - msg(lng::MHelpSearchingFor), - strLastSearchStr0, - strTempStr, - L"HelpSearch"sv, - {}, - SearchDlgOptions, - {}, - true, - &HelpSearchId); - - if (RetCode <= 0) + if (GetSearchReplaceString(LastSearchDlgParams, L"HelpSearch"sv, {}, CP_DEFAULT, {}, &HelpSearchId) <= 0) return true; - strLastSearchStr=strLastSearchStr0; - LastSearchDlgOptions = SearchDlgOptions; - Stack.emplace(*StackData); IsNewTopic = true; JumpTopic(FoundContents); @@ -1946,8 +1926,7 @@ void Help::Search(const os::fs::file& HelpFile,uintptr_t nCodePage) StackData->CurX=StackData->CurY=0; m_CtrlColorChar = 0; - string strTitleLine=strLastSearchStr; - AddTitle(strTitleLine); + AddTitle(LastSearchDlgParams.SearchStr); bool TopicFound=false; string strCurTopic, strEntryName; @@ -1956,22 +1935,24 @@ void Help::Search(const os::fs::file& HelpFile,uintptr_t nCodePage) named_regex_match NamedMatch; RegExp re; - if (LastSearchDlgOptions.Regexp.value()) + if (LastSearchDlgParams.Regexp.value()) { // Q: что важнее: опция диалога или опция RegExp`а? try { - re.Compile(strLastSearchStr, (strLastSearchStr.starts_with(L'/')? OP_PERLSTYLE : 0) | OP_OPTIMIZE | (LastSearchDlgOptions.CaseSensitive.value()? 0 : OP_IGNORECASE)); + re.Compile( + LastSearchDlgParams.SearchStr, + (LastSearchDlgParams.SearchStr.starts_with(L'/')? OP_PERLSTYLE : 0) | OP_OPTIMIZE | (LastSearchDlgParams.CaseSensitive.value()? 0 : OP_IGNORECASE)); } catch (regex_exception const& e) { - ReCompileErrorMessage(e, strLastSearchStr); + ReCompileErrorMessage(e, LastSearchDlgParams.SearchStr); return; //BUGBUG } } searchers Searchers; - const auto& Searcher = init_searcher(Searchers, LastSearchDlgOptions.CaseSensitive.value(), LastSearchDlgOptions.Fuzzy.value(), strLastSearchStr); + const auto& Searcher = init_searcher(Searchers, LastSearchDlgParams.CaseSensitive.value(), LastSearchDlgParams.Fuzzy.value(), LastSearchDlgParams.SearchStr); os::fs::filebuf StreamBuffer(HelpFile, std::ios::in); std::istream Stream(&StreamBuffer); @@ -2007,16 +1988,16 @@ void Help::Search(const os::fs::file& HelpFile,uintptr_t nCodePage) if (SearchString( Str, - strLastSearchStr, + LastSearchDlgParams.SearchStr, Searcher, re, Match, &NamedMatch, CurPos, { - .CaseSensitive = LastSearchDlgOptions.CaseSensitive.value(), - .WholeWords = LastSearchDlgOptions.WholeWords.value(), - .Regexp = LastSearchDlgOptions.Regexp.value() + .CaseSensitive = LastSearchDlgParams.CaseSensitive.value(), + .WholeWords = LastSearchDlgParams.WholeWords.value(), + .Regexp = LastSearchDlgParams.Regexp.value() }, SearchLength, Global->Opt->EdOpt.strWordDiv diff --git a/far/stddlg.cpp b/far/stddlg.cpp index c86d69ed36..7242d7c8ea 100644 --- a/far/stddlg.cpp +++ b/far/stddlg.cpp @@ -66,6 +66,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "platform.process.hpp" // Common: +#include "common.hpp" #include "common/from_string.hpp" #include "common/function_ref.hpp" #include "common/view/enumerate.hpp" @@ -76,50 +77,64 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //---------------------------------------------------------------------------- int GetSearchReplaceString( - bool IsReplaceMode, - string_view Title, - string_view SubTitle, - string& SearchStr, - string& ReplaceStr, + SearchReplaceDlgParams& Params, string_view TextHistoryName, string_view ReplaceHistoryName, - SearchReplaceDlgOptions& Options, + uintptr_t CodePage, string_view const HelpTopic, - bool HideAll, const UUID* Id, function_ref const Picker) { - if (TextHistoryName.empty()) - TextHistoryName = L"SearchText"sv; + const auto HasHex{ Params.Hex.has_value() }; + const auto HexVal{ Params.Hex.value_or(false) }; + const auto RexVal{ Params.Regexp.value_or(false) }; - if (ReplaceHistoryName.empty()) - ReplaceHistoryName = L"ReplaceText"sv; + string SearchForLabel{ msg(lng::MSearchReplaceSearchFor) }; + if (HasHex) inplace::remove_highlight(SearchForLabel); - if (Title.empty()) - Title = msg(IsReplaceMode? lng::MEditReplaceTitle : lng::MEditSearchTitle); + const auto& DialogTitle{ msg(Params.ReplaceMode ? lng::MSearchReplaceReplaceTitle : lng::MSearchReplaceSearchTitle) }; + const auto& TextLabel{ msg(lng::MSearchReplaceText) }; + const auto& HexLabel{ msg(lng::MSearchReplaceHex) }; + const auto& WordLabel{ msg(lng::MSearchReplacePickWord) }; + const auto& SelectionLabel{ msg(lng::MSearchReplacePickSelection) }; - if (SubTitle.empty()) - SubTitle = msg(lng::MEditSearchFor); + const auto SearchForLabelW{ static_cast(HiStrlen(SearchForLabel)) }; + const auto TextLabelW{ static_cast(HiStrlen(TextLabel) + 4) }; + const auto HexLabelW{ static_cast(HiStrlen(HexLabel) + 4) }; + const auto WordLabelW{ static_cast(HiStrlen(WordLabel) + 4) }; + const auto SelectionLabelW{ static_cast(HiStrlen(SelectionLabel) + 4) }; - const auto DlgWidth = 76; - const auto& WordLabel = msg(lng::MEditSearchPickWord); - const auto& SelectionLabel = msg(lng::MEditSearchPickSelection); - const auto WordButtonSize = HiStrlen(WordLabel) + 4; - const auto SelectionButtonSize = HiStrlen(SelectionLabel) + 4; - const auto SelectionButtonX2 = DlgWidth - 4 - 1; - const auto SelectionButtonX1 = static_cast(SelectionButtonX2 - SelectionButtonSize); - const auto WordButtonX2 = SelectionButtonX1 - 1; - const auto WordButtonX1 = static_cast(WordButtonX2 - WordButtonSize); + constexpr auto DlgWidth{ 76 }; + constexpr auto HorizontalRadioGap{ 2 }; - const auto YFix = IsReplaceMode? 0 : 2; + const auto SearchForX1{ 4 + 1 }; const auto SearchForX2{ SearchForX1 + SearchForLabelW }; + + const auto SelectionButtonX2{ DlgWidth - 4 - 1 }; + const auto SelectionButtonX1{ SelectionButtonX2 - SelectionLabelW }; + const auto WordButtonX2{ SelectionButtonX1 - 1 }; + const auto WordButtonX1{ WordButtonX2 - WordLabelW }; + + const auto TextRadioX1_{ SearchForX2 + HorizontalRadioGap }; const auto TextRadioX2_{ TextRadioX1_ + TextLabelW }; + const auto HexRadioX1_{ TextRadioX2_ + HorizontalRadioGap }; const auto HexRadioX2_{ HexRadioX1_ + HexLabelW }; + + const auto SearchForRadioExtent_{ Picker ? WordButtonX1 - HorizontalRadioGap : DlgWidth - 4 - 1 }; + const auto HexRadioOverage_{ std::max(HexRadioX2_ - SearchForRadioExtent_, 0) }; + + const auto TextRadioX1{ TextRadioX1_ - HexRadioOverage_ }; const auto TextRadioX2{ TextRadioX2_ - HexRadioOverage_ }; + const auto HexRadioX1{ HexRadioX1_ - HexRadioOverage_ }; const auto HexRadioX2{ HexRadioX2_ - HexRadioOverage_ }; + + const auto YFix = Params.ReplaceMode ? 0 : 2; enum item_id { dlg_border, + dlg_radio_text, + dlg_radio_hex, dlg_button_word, dlg_button_selection, dlg_label_search, - dlg_edit_search, + dlg_edit_search_text, + dlg_edit_search_hex, dlg_label_replace, dlg_edit_replace, dlg_separator_1, @@ -137,81 +152,193 @@ int GetSearchReplaceString( dlg_count }; - auto ReplaceDlg = MakeDialogItems( + auto DlgItems = MakeDialogItems( { - { DI_DOUBLEBOX, {{3, 1 }, {DlgWidth-4, 12-YFix}}, DIF_NONE, Title }, - { DI_BUTTON, {{WordButtonX1, 2 }, {WordButtonX2, 2 }}, DIF_BTNNOCLOSE, WordLabel }, - { DI_BUTTON, {{SelectionButtonX1, 2 }, {SelectionButtonX2, 2 }}, DIF_BTNNOCLOSE, SelectionLabel }, - { DI_TEXT, {{5, 2 }, {0, 2 }}, DIF_NONE, SubTitle }, - { DI_EDIT, {{5, 3 }, {70, 3 }}, DIF_FOCUS | DIF_USELASTHISTORY | DIF_HISTORY, SearchStr, }, - { DI_TEXT, {{5, 4 }, {0, 4 }}, DIF_NONE, msg(lng::MEditReplaceWith), }, - { DI_EDIT, {{5, 5 }, {70, 5 }}, DIF_USELASTHISTORY | DIF_HISTORY, ReplaceStr, }, - { DI_TEXT, {{-1, 6-YFix }, {0, 6-YFix }}, DIF_SEPARATOR, }, - { DI_CHECKBOX, {{5, 7-YFix }, {0, 7-YFix }}, DIF_NONE, msg(lng::MEditSearchCase), }, - { DI_CHECKBOX, {{5, 8-YFix }, {0, 8-YFix }}, DIF_NONE, msg(lng::MEditSearchWholeWords), }, - { DI_CHECKBOX, {{5, 9-YFix }, {0, 9-YFix }}, DIF_NONE, msg(lng::MEditSearchReverse), }, - { DI_CHECKBOX, {{40, 7-YFix }, {0, 7-YFix }}, DIF_NONE, msg(lng::MEditSearchRegexp), }, - { DI_CHECKBOX, {{40, 8-YFix }, {0, 8-YFix }}, DIF_NONE, msg(lng::MEditSearchFuzzy), }, - { DI_CHECKBOX, {{40, 9-YFix }, {0, 9-YFix }}, DIF_NONE, msg(lng::MEditSearchPreserveStyle), }, - { DI_TEXT, {{-1, 10-YFix}, {0, 10-YFix}}, DIF_SEPARATOR, }, - { DI_BUTTON, {{0, 11-YFix}, {0, 11-YFix}}, DIF_CENTERGROUP | DIF_DEFAULTBUTTON, msg(IsReplaceMode? lng::MEditReplaceReplace : lng::MEditSearchSearch), }, - { DI_BUTTON, {{0, 11-YFix}, {0, 11-YFix}}, DIF_CENTERGROUP, msg(lng::MEditSearchAll), }, - { DI_BUTTON, {{0, 11-YFix}, {0, 11-YFix}}, DIF_CENTERGROUP, msg(lng::MEditSearchCancel), }, + { DI_DOUBLEBOX, {{3, 1 }, {DlgWidth-4, 12-YFix}}, DIF_NONE, DialogTitle, }, + { DI_RADIOBUTTON, {{TextRadioX1, 2 }, {TextRadioX2, 2 }}, DIF_GROUP, TextLabel, }, + { DI_RADIOBUTTON, {{HexRadioX1, 2 }, {HexRadioX2, 2 }}, DIF_NONE, HexLabel, }, + { DI_BUTTON, {{WordButtonX1, 2 }, {WordButtonX2, 2 }}, DIF_BTNNOCLOSE, WordLabel }, + { DI_BUTTON, {{SelectionButtonX1, 2 }, {SelectionButtonX2, 2 }}, DIF_BTNNOCLOSE, SelectionLabel }, + { DI_TEXT, {{5, 2 }, {0, 2 }}, DIF_NONE, SearchForLabel }, + { DI_EDIT, {{5, 3 }, {DlgWidth-4-2, 3 }}, DIF_USELASTHISTORY | DIF_HISTORY, }, + { DI_FIXEDIT, {{5, 3 }, {DlgWidth-4-2, 3 }}, DIF_MASKEDIT, }, + { DI_TEXT, {{5, 4 }, {0, 4 }}, DIF_NONE, msg(lng::MSearchReplaceReplaceWith), }, + { DI_EDIT, {{5, 5 }, {DlgWidth-4-2, 5 }}, DIF_USELASTHISTORY | DIF_HISTORY, }, + { DI_TEXT, {{-1, 6-YFix }, {0, 6-YFix }}, DIF_SEPARATOR, }, + { DI_CHECKBOX, {{5, 7-YFix }, {0, 7-YFix }}, DIF_NONE, msg(lng::MSearchReplaceCase), }, + { DI_CHECKBOX, {{5, 8-YFix }, {0, 8-YFix }}, DIF_NONE, msg(lng::MSearchReplaceWholeWords), }, + { DI_CHECKBOX, {{5, 9-YFix }, {0, 9-YFix }}, DIF_NONE, msg(lng::MSearchReplaceReverse), }, + { DI_CHECKBOX, {{40, 7-YFix }, {0, 7-YFix }}, DIF_NONE, msg(lng::MSearchReplaceRegexp), }, + { DI_CHECKBOX, {{40, 8-YFix }, {0, 8-YFix }}, DIF_NONE, msg(lng::MSearchReplaceFuzzy), }, + { DI_CHECKBOX, {{40, 9-YFix }, {0, 9-YFix }}, DIF_NONE, msg(lng::MSearchReplacePreserveStyle), }, + { DI_TEXT, {{-1, 10-YFix}, {0, 10-YFix}}, DIF_SEPARATOR, }, + { DI_BUTTON, {{0, 11-YFix}, {0, 11-YFix}}, DIF_CENTERGROUP | DIF_DEFAULTBUTTON, msg(Params.ReplaceMode ? lng::MSearchReplaceReplace : lng::MSearchReplaceSearch), }, + { DI_BUTTON, {{0, 11-YFix}, {0, 11-YFix}}, DIF_CENTERGROUP, msg(lng::MSearchReplaceAll), }, + { DI_BUTTON, {{0, 11-YFix}, {0, 11-YFix}}, DIF_CENTERGROUP, msg(lng::MSearchReplaceCancel), }, }); - ReplaceDlg[dlg_edit_search].strHistory = TextHistoryName; - ReplaceDlg[dlg_edit_replace].strHistory = ReplaceHistoryName; - ReplaceDlg[dlg_checkbox_case].Selected = Options.CaseSensitive.value_or(false); - ReplaceDlg[dlg_checkbox_words].Selected = Options.WholeWords.value_or(false); - ReplaceDlg[dlg_checkbox_reverse].Selected = Options.Reverse.value_or(false); - ReplaceDlg[dlg_checkbox_regex].Selected = Options.Regexp.value_or(false); - ReplaceDlg[dlg_checkbox_fuzzy].Selected = Options.Fuzzy.value_or(false); - ReplaceDlg[dlg_checkbox_style].Selected = Options.PreserveStyle.value_or(false); - - if (IsReplaceMode || HideAll) + const auto SetFlagIf{ [&](const item_id Item, const auto Flag, const bool Condition) { if (Condition) DlgItems[Item].Flags |= Flag; } }; + const auto SetSelected{ [&](const item_id Item, const bool Selected) { DlgItems[Item].Selected = Selected; } }; + const auto SetStringIf{ [&](const item_id Item, const string_view String, const bool Condition) { if (Condition) DlgItems[Item].strData = String; } }; + const auto SetHistory{ [&](const item_id Item, const string_view History) { DlgItems[Item].strHistory = History; } }; + const auto SetMaskIf{ [&](const item_id Item, const bool Condition) { - ReplaceDlg[dlg_button_all].Flags |= DIF_HIDDEN; - } + if (!Condition) return; + auto& HexMask{ DlgItems[Item].strMask }; + HexMask.assign(64 * 3 - 1, 'H'); + for (size_t i{ 2 }; i < HexMask.size(); i += 3) HexMask[i] = L' '; // "HH HH ... HH" + } }; - if (!IsReplaceMode) - { - ReplaceDlg[dlg_label_replace].Flags |= DIF_HIDDEN; - ReplaceDlg[dlg_edit_replace].Flags |= DIF_HIDDEN; - ReplaceDlg[dlg_checkbox_style].Flags |= DIF_HIDDEN; - } + // dlg_radio_text + SetFlagIf(dlg_radio_text, DIF_HIDDEN, !HasHex); + SetSelected(dlg_radio_text, !HexVal); - if (!Picker) - { - ReplaceDlg[dlg_button_word].Flags |= DIF_HIDDEN; - ReplaceDlg[dlg_button_selection].Flags |= DIF_HIDDEN; - } + // dlg_radio_hex + SetFlagIf(dlg_radio_hex, DIF_HIDDEN, !HasHex); + SetSelected(dlg_radio_hex, HexVal); + + // dlg_button_word + SetFlagIf(dlg_button_word, DIF_HIDDEN, !Picker); + SetFlagIf(dlg_button_word, DIF_DISABLE, HexVal); + + // dlg_button_selection + SetFlagIf(dlg_button_selection, DIF_HIDDEN, !Picker); + SetFlagIf(dlg_button_selection, DIF_DISABLE, HexVal); + + // dlg_edit_search_text + SetFlagIf(dlg_edit_search_text, DIF_HIDDEN, HexVal); + SetFlagIf(dlg_edit_search_text, DIF_FOCUS, !HexVal); + SetStringIf(dlg_edit_search_text, Params.SearchStr, !HexVal); + SetHistory(dlg_edit_search_text, TextHistoryName); + + // dlg_edit_search_hex + SetFlagIf(dlg_edit_search_hex, DIF_HIDDEN, !HexVal); + SetFlagIf(dlg_edit_search_hex, DIF_FOCUS, HexVal); + SetStringIf(dlg_edit_search_hex, Params.SearchStr, HexVal); + SetMaskIf(dlg_edit_search_hex, HasHex); + + // dlg_label_replace + SetFlagIf(dlg_label_replace, DIF_HIDDEN, !Params.ReplaceMode); - if (!Options.CaseSensitive.has_value()) - ReplaceDlg[dlg_checkbox_case].Flags |= DIF_DISABLE; // DIF_HIDDEN ?? - if (!Options.WholeWords.has_value()) - ReplaceDlg[dlg_checkbox_words].Flags |= DIF_DISABLE; // DIF_HIDDEN ?? - if (!Options.Reverse.has_value()) - ReplaceDlg[dlg_checkbox_reverse].Flags |= DIF_DISABLE; // DIF_HIDDEN ?? - if (!Options.Regexp.has_value()) - ReplaceDlg[dlg_checkbox_regex].Flags |= DIF_DISABLE; // DIF_HIDDEN ?? - if (!Options.Fuzzy.has_value()) - ReplaceDlg[dlg_checkbox_fuzzy].Flags |= DIF_DISABLE; // DIF_HIDDEN ?? - if (!Options.PreserveStyle.has_value()) - ReplaceDlg[dlg_checkbox_style].Flags |= DIF_DISABLE; // DIF_HIDDEN ?? + // dlg_edit_replace + SetFlagIf(dlg_edit_replace, DIF_HIDDEN, !Params.ReplaceMode); + SetStringIf(dlg_edit_replace, Params.ReplaceStr, Params.ReplaceMode); + SetHistory(dlg_edit_replace, ReplaceHistoryName); + + // dlg_checkbox_case + SetFlagIf(dlg_checkbox_case, DIF_DISABLE, !Params.CaseSensitive.has_value() || HexVal); + SetSelected(dlg_checkbox_case, Params.CaseSensitive.value_or(false)); + + // dlg_checkbox_words + SetFlagIf(dlg_checkbox_words, DIF_DISABLE, !Params.WholeWords.has_value() || HexVal); + SetSelected(dlg_checkbox_words, Params.WholeWords.value_or(false)); + + // dlg_checkbox_reverse + SetFlagIf(dlg_checkbox_reverse, DIF_HIDDEN, !Params.Reverse.has_value()); + SetSelected(dlg_checkbox_reverse, Params.Reverse.value_or(false)); + + // dlg_checkbox_regex + SetFlagIf(dlg_checkbox_regex, DIF_DISABLE, !Params.Regexp.has_value() || HexVal); + SetSelected(dlg_checkbox_regex, Params.Regexp.value_or(false)); + + // dlg_checkbox_fuzzy + SetFlagIf(dlg_checkbox_fuzzy, DIF_DISABLE, !Params.Fuzzy.has_value() || HexVal || RexVal); + SetSelected(dlg_checkbox_fuzzy, Params.Fuzzy.value_or(false)); + + // dlg_checkbox_style + SetFlagIf(dlg_checkbox_style, DIF_HIDDEN, !Params.ReplaceMode || !Params.PreserveStyle.has_value()); + SetSelected(dlg_checkbox_style, Params.PreserveStyle.value_or(false)); + + // dlg_button_all + SetFlagIf(dlg_button_all, DIF_HIDDEN, Params.ReplaceMode || !Params.ShowButtonAll); + + bool TextOrHexHotkeyUsed{}; const auto Handler = [&](Dialog* Dlg, intptr_t Msg, intptr_t Param1, void* Param2) -> intptr_t { - if (Msg == DN_BTNCLICK && Picker && (Param1 == dlg_button_word || Param1 == dlg_button_selection)) + switch (Msg) { - // BUGBUG: #0003136: DM_INSERTTEXT or something like that - static_cast(Dlg->GetAllItem()[dlg_edit_search].ObjPtr)->InsertString(Picker(Param1 == dlg_button_selection)); - Dlg->SendMessage(DM_SETFOCUS, dlg_edit_search, nullptr); - return TRUE; + case DN_BTNCLICK: + switch (Param1) + { + case dlg_radio_text: + case dlg_radio_hex: + { + if (!Param2) break; + + SCOPED_ACTION(Dialog::suppress_redraw)(Dlg); + + const auto OldHex{ !!Dlg->SendMessage(DM_SHOWITEM, dlg_edit_search_hex, ToPtr(-1)) }; + const auto NewHex{ Param1 == dlg_radio_hex }; + const auto OldEdit{ OldHex ? dlg_edit_search_hex : dlg_edit_search_text }; + const auto NewEdit{ NewHex ? dlg_edit_search_hex : dlg_edit_search_text }; + + if (NewHex != OldHex) + { + const auto OldStr{ view_as(Dlg->SendMessage(DM_GETCONSTTEXTPTR, OldEdit, nullptr)) }; + const auto NewStr{ ConvertHexString(OldStr, CodePage, !NewHex) }; + Dlg->SendMessage(DM_SETTEXTPTR, NewEdit, UNSAFE_CSTR(NewStr)); + if (!NewStr.empty()) + { + const auto Unchanged{ static_cast(Dlg->SendMessage(DM_EDITUNCHANGEDFLAG, OldEdit, ToPtr(-1))) }; + Dlg->SendMessage(DM_EDITUNCHANGEDFLAG, NewEdit, ToPtr(Unchanged)); + } + Dlg->SendMessage(DM_SHOWITEM, OldEdit, ToPtr(false)); + Dlg->SendMessage(DM_SHOWITEM, NewEdit, ToPtr(true)); + + const auto Rex{ Dlg->SendMessage(DM_GETCHECK, dlg_checkbox_regex, nullptr) == BSTATE_CHECKED }; + Dlg->SendMessage(DM_ENABLE, dlg_button_word, ToPtr(!NewHex)); + Dlg->SendMessage(DM_ENABLE, dlg_button_selection, ToPtr(!NewHex)); + Dlg->SendMessage(DM_ENABLE, dlg_checkbox_case, ToPtr(Params.CaseSensitive.has_value() && !NewHex)); + Dlg->SendMessage(DM_ENABLE, dlg_checkbox_words, ToPtr(Params.WholeWords.has_value() && !NewHex)); + Dlg->SendMessage(DM_ENABLE, dlg_checkbox_regex, ToPtr(Params.Regexp.has_value() && !NewHex)); + Dlg->SendMessage(DM_ENABLE, dlg_checkbox_fuzzy, ToPtr(Params.Fuzzy.has_value() && !NewHex && !Rex)); + } + + if (TextOrHexHotkeyUsed) + { + TextOrHexHotkeyUsed = false; + Dlg->SendMessage(DM_SETFOCUS, NewEdit, nullptr); + } + } + break; + + case dlg_button_word: + case dlg_button_selection: + { + if (!Picker) break; + + // BUGBUG: #0003136: DM_INSERTTEXT or something like that + static_cast(Dlg->GetAllItem()[dlg_edit_search_text].ObjPtr)->InsertString(Picker(Param1 == dlg_button_selection)); + Dlg->SendMessage(DM_SETFOCUS, dlg_edit_search_text, nullptr); + return TRUE; + } + break; + + case dlg_checkbox_regex: + { + SCOPED_ACTION(Dialog::suppress_redraw)(Dlg); + + const auto Hex{ !!Dlg->SendMessage(DM_SHOWITEM, dlg_edit_search_hex, ToPtr(-1)) }; + const auto Rex{ Dlg->SendMessage(DM_GETCHECK, dlg_checkbox_regex, nullptr) == BSTATE_CHECKED }; + Dlg->SendMessage(DM_ENABLE, dlg_checkbox_words, ToPtr(Params.WholeWords.has_value() && !Hex)); + Dlg->SendMessage(DM_ENABLE, dlg_checkbox_fuzzy, ToPtr(Params.Fuzzy.has_value() && !Hex && !Rex)); + } + break; + } + break; + + case DN_HOTKEY: + { + TextOrHexHotkeyUsed = Param1 == dlg_radio_text || Param1 == dlg_radio_hex; + } + break; } + return Dlg->DefProc(Msg, Param1, Param2); }; - const auto Dlg = Dialog::create(ReplaceDlg, Handler); + const auto Dlg = Dialog::create(DlgItems, Handler); Dlg->SetPosition({ -1, -1, DlgWidth, 14 - YFix }); if (!HelpTopic.empty()) @@ -222,22 +349,36 @@ int GetSearchReplaceString( Dlg->Process(); - if(const auto ExitCode = Dlg->GetExitCode(); ExitCode == dlg_button_action || ExitCode == dlg_button_all) + if (const auto ExitCode = Dlg->GetExitCode(); ExitCode == dlg_button_action || ExitCode == dlg_button_all) { - SearchStr = ReplaceDlg[dlg_edit_search].strData; - ReplaceStr = ReplaceDlg[dlg_edit_replace].strData; - if (Options.CaseSensitive.has_value()) - Options.CaseSensitive = ReplaceDlg[dlg_checkbox_case].Selected == BSTATE_CHECKED; - if (Options.WholeWords.has_value()) - Options.WholeWords = ReplaceDlg[dlg_checkbox_words].Selected == BSTATE_CHECKED; - if (Options.Reverse.has_value()) - Options.Reverse = ReplaceDlg[dlg_checkbox_reverse].Selected == BSTATE_CHECKED; - if (Options.Regexp.has_value()) - Options.Regexp = ReplaceDlg[dlg_checkbox_regex].Selected == BSTATE_CHECKED; - if (Options.Fuzzy.has_value()) - Options.Fuzzy = ReplaceDlg[dlg_checkbox_fuzzy].Selected == BSTATE_CHECKED; - if (Options.PreserveStyle.has_value()) - Options.PreserveStyle = ReplaceDlg[dlg_checkbox_style].Selected == BSTATE_CHECKED; + if (DlgItems[dlg_edit_search_hex].Flags & DIF_HIDDEN) + { + Params.SearchStr = DlgItems[dlg_edit_search_text].strData; + } + else + { + Params.SearchStr = ExtractHexString(DlgItems[dlg_edit_search_hex].strData); + Params.SearchBytes = HexStringToBlob(Params.SearchStr, 0); + } + + if (Params.ReplaceMode) + { + Params.ReplaceStr = DlgItems[dlg_edit_replace].strData; + } + + const auto SaveParam{ [&](auto& Param, const item_id Id) + { + if (Param.has_value()) + Param = DlgItems[Id].Selected == BSTATE_CHECKED; + } }; + + SaveParam(Params.Hex, dlg_radio_hex); + SaveParam(Params.CaseSensitive, dlg_checkbox_case); + SaveParam(Params.WholeWords, dlg_checkbox_words); + SaveParam(Params.Reverse, dlg_checkbox_reverse); + SaveParam(Params.Regexp, dlg_checkbox_regex); + SaveParam(Params.Fuzzy, dlg_checkbox_fuzzy); + SaveParam(Params.PreserveStyle, dlg_checkbox_style); return ExitCode == dlg_button_action ? 1 : 2; } diff --git a/far/stddlg.hpp b/far/stddlg.hpp index 48bfb15c24..4dede525a6 100644 --- a/far/stddlg.hpp +++ b/far/stddlg.hpp @@ -42,6 +42,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Platform: // Common: +#include "common/bytes_view.hpp" #include "common/function_ref.hpp" #include "common/preprocessor.hpp" #include "common/utility.hpp" @@ -54,8 +55,14 @@ enum class lng : int; class regex_exception; struct error_state_ex; -struct SearchReplaceDlgOptions +struct SearchReplaceDlgParams { + bool ReplaceMode{}; + bool ShowButtonAll{}; + string SearchStr; + bytes SearchBytes; + string ReplaceStr; + std::optional Hex; std::optional CaseSensitive; std::optional WholeWords; std::optional Reverse; @@ -69,24 +76,11 @@ struct SearchReplaceDlgOptions от пользователя данные и в случае успешного выполнения диалога возвращает TRUE. Параметры: - IsReplaceMode - true - если хотим заменять - false - если хотим искать + Params + InOut parameter. Specifies which options to show in the dialog and provides initial values. + On exit, contains the values selected by the user. - Title - Заголовок диалога. - Если пустая строка, то применяется MEditReplaceTitle или MEditSearchTitle в зависимости от параметра IsReplaceMode - - SearchStr - Строка поиска. - Результат отработки диалога заносится в нее же. - - ReplaceStr, - Строка замены. - Результат отработки диалога заносится в нее же. - Для случая, если IsReplaceMode=FALSE может быть равна nullptr - - TextHistoryName + TextHistoryName Имя истории строки поиска. Если пустая строка, то принимается значение "SearchText" @@ -94,10 +88,6 @@ struct SearchReplaceDlgOptions Имя истории строки замены. Если пустая строка, то принимается значение "ReplaceText" - Options - InOut parameter. Specifies which options to show in the dialog and provides initial values. - On exit, contains the values selected by the user. - HelpTopic Имя темы помощи. Если пустая строка - тема помощи не назначается. @@ -109,16 +99,11 @@ struct SearchReplaceDlgOptions */ int GetSearchReplaceString( - bool IsReplaceMode, - string_view Title, - string_view SubTitle, - string& SearchStr, - string& ReplaceStr, + SearchReplaceDlgParams& Params, string_view TextHistoryName, string_view ReplaceHistoryName, - SearchReplaceDlgOptions& Options, + uintptr_t CodePage, string_view HelpTopic = {}, - bool HideAll=false, const UUID* Id = nullptr, function_ref Picker = nullptr ); diff --git a/far/vbuild.m4 b/far/vbuild.m4 index 3314f6e3e0..f1700f94af 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -6095 +6096 diff --git a/far/viewer.cpp b/far/viewer.cpp index 0cdef1efe0..1db6deb910 100644 --- a/far/viewer.cpp +++ b/far/viewer.cpp @@ -3179,9 +3179,9 @@ void Viewer::Search(int Next,const Manager::Key* FirstChar) { constexpr auto DlgWidth{ 76 }; constexpr auto HorizontalRadioGap{ 2 }; - const auto& searchFor{ msg(lng::MViewSearchFor) }; - const auto& searchForText{ msg(lng::MViewSearchForText) }; - const auto& searchForHex{ msg(lng::MViewSearchForHex) }; + const auto& searchFor{ msg(lng::MSearchReplaceSearchFor) }; + const auto& searchForText{ msg(lng::MSearchReplaceText) }; + const auto& searchForHex{ msg(lng::MSearchReplaceHex) }; const auto searchForW{ static_cast(HiStrlen(searchFor)) }; const auto searchForTextW{ static_cast(HiStrlen(searchForText) + 4) }; const auto searchForHexW{ static_cast(HiStrlen(searchForHex) + 4) }; @@ -3197,21 +3197,21 @@ void Viewer::Search(int Next,const Manager::Key* FirstChar) auto SearchDlg = MakeDialogItems( { - { DI_DOUBLEBOX, {{3, 1}, {DlgWidth-4, 10}}, DIF_NONE, msg(lng::MViewSearchTitle), }, + { DI_DOUBLEBOX, {{3, 1}, {DlgWidth-4, 10}}, DIF_NONE, msg(lng::MSearchReplaceSearchTitle), }, { DI_RADIOBUTTON, {{searchForTextX1, 2}, {searchForTextX2, 2 }}, DIF_GROUP, searchForText, }, { DI_RADIOBUTTON, {{searchForHexX1, 2}, {searchForHexX2, 2 }}, DIF_NONE, searchForHex, }, { DI_TEXT, {{searchForX1, 2}, {0, 2 }}, DIF_NONE, searchFor, }, { DI_EDIT, {{5, 3}, {DlgWidth-4-2, 3 }}, DIF_HISTORY | DIF_USELASTHISTORY, }, { DI_FIXEDIT, {{5, 3}, {DlgWidth-4-2, 3 }}, DIF_MASKEDIT, }, { DI_TEXT, {{-1, 4}, {0, 4 }}, DIF_SEPARATOR, }, - { DI_CHECKBOX, {{5, 5}, {0, 5 }}, DIF_NONE, msg(lng::MViewSearchCase), }, - { DI_CHECKBOX, {{5, 6}, {0, 6 }}, DIF_NONE, msg(lng::MViewSearchWholeWords), }, - { DI_CHECKBOX, {{5, 7}, {0, 7 }}, DIF_NONE, msg(lng::MViewSearchReverse), }, - { DI_CHECKBOX, {{40, 5}, {0, 5 }}, DIF_NONE, msg(lng::MViewSearchRegexp), }, - { DI_CHECKBOX, {{40, 6}, {0, 6 }}, DIF_NONE, msg(lng::MViewSearchFuzzy), }, + { DI_CHECKBOX, {{5, 5}, {0, 5 }}, DIF_NONE, msg(lng::MSearchReplaceCase), }, + { DI_CHECKBOX, {{5, 6}, {0, 6 }}, DIF_NONE, msg(lng::MSearchReplaceWholeWords), }, + { DI_CHECKBOX, {{5, 7}, {0, 7 }}, DIF_NONE, msg(lng::MSearchReplaceReverse), }, + { DI_CHECKBOX, {{40, 5}, {0, 5 }}, DIF_NONE, msg(lng::MSearchReplaceRegexp), }, + { DI_CHECKBOX, {{40, 6}, {0, 6 }}, DIF_NONE, msg(lng::MSearchReplaceFuzzy), }, { DI_TEXT, {{-1, 8}, {0, 8 }}, DIF_SEPARATOR, }, - { DI_BUTTON, {{0, 9}, {0, 9 }}, DIF_CENTERGROUP | DIF_DEFAULTBUTTON, msg(lng::MViewSearchSearch), }, - { DI_BUTTON, {{0, 9}, {0, 9 }}, DIF_CENTERGROUP, msg(lng::MViewSearchCancel), }, + { DI_BUTTON, {{0, 9}, {0, 9 }}, DIF_CENTERGROUP | DIF_DEFAULTBUTTON, msg(lng::MSearchReplaceSearch), }, + { DI_BUTTON, {{0, 9}, {0, 9 }}, DIF_CENTERGROUP, msg(lng::MSearchReplaceCancel), }, }); string mask(3 * SD_MAX_CHARS, L'H'); @@ -3383,7 +3383,7 @@ void Viewer::Search(int Next,const Manager::Key* FirstChar) else if (found == Search_NotFound) { Message(MSG_WARNING, - msg(lng::MViewSearchTitle), + msg(lng::MSearchReplaceSearchTitle), { msg(LastSearchDlgOptions.Hex? lng::MViewSearchCannotFindHex : lng::MViewSearchCannotFind), strMsgStr @@ -3402,7 +3402,7 @@ void Viewer::Search(int Next,const Manager::Key* FirstChar) static_assert(lng::MViewSearchEod + 2 == lng::MViewSearchBod && lng::MViewSearchEod + 4 == lng::MViewSearchCycle, "Wrong .lng file order"); if (Message(0, - msg(lng::MViewSearchTitle), + msg(lng::MSearchReplaceSearchTitle), { msg(lng::MViewSearchEod + 2 * (found - Search_Eof)), msg(lng::MViewSearchFromBegin + 2 * (found - Search_Eof)), @@ -3445,7 +3445,7 @@ void Viewer::Search(int Next,const Manager::Key* FirstChar) } if (!Progress) - Progress.emplace(msg(lng::MViewSearchTitle), concat(msg(LastSearchDlgOptions.Hex? lng::MViewSearchingHex : lng::MViewSearchingFor), L' ', strMsgStr), 0); + Progress.emplace(msg(lng::MSearchReplaceSearchTitle), concat(msg(LastSearchDlgOptions.Hex? lng::MViewSearchingHex : lng::MViewSearchingFor), L' ', strMsgStr), 0); Progress->update(percent); }