diff --git a/.gitignore b/.gitignore index cb950a30d..4607493e4 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,8 @@ CMakeLists.txt.user* /build /build* +build/ +build*/ /icon/*.png /icon/ImageMagick diff --git a/i18n/NotepadNext_cs.ts b/i18n/NotepadNext_cs.ts index c2fe90a27..2ac3e4611 100644 --- a/i18n/NotepadNext_cs.ts +++ b/i18n/NotepadNext_cs.ts @@ -503,125 +503,140 @@ FindReplaceDialog - - - + + + Find Najít - + Search Mode Režim vyhledávání - + &Normal &Normální - + E&xtended (\n, \r, \t, \0, \x...) E&rozšířené (\n, \r, \t, \0, \x...) - + Re&gular expression Re&gulární výraz - + &. matches newline &. odpovídá novému řádku - + Transparenc&y Průh&lednost - + On losing focus Při ztrátě fokusu - + Always Vždy - + Coun&t Po&čet - + &Replace Nah&radit - + Replace &All Na&hradit vše - + Replace All in &Opened Documents Nahradit ve všech v &otevřených dokumentech - + + Replace All in Files + + + + Find All in All &Opened Documents Najít vše ve všech &otevřených dokumentech - + Find All in Current Document Najít vše v aktuálním dokumentu - + Close Zavřít - + &Find: &Najít: - + Replace: Nahradit: - + + Path of directory containing files to be replaced: + + + + + Select Containing Directory + + + + Backward direction Zpětný směr - + Match &whole word only Hledat pouze &celá slova - + Match &case Rozlišovat malá a &VELKÁ písmena - + Wra&p Around Na konci znovu od &začátku - + Replace Nahradit - - + + Replaced %Ln matches Nahrazeno %Ln shod @@ -629,28 +644,37 @@ Nahrazeno %Ln shod + + + Replaced matches in %Ln files + + + + + + - + The end of the document has been reached. Found 1st occurrence from the top. Bylo dosaženo konce dokumentu. Nalezeno 1. výskyt shora. - + No matches found. Nebyly nalezeny žádné shody. - + 1 occurrence was replaced 1 výskyt byl nahrazen - + No more occurrences were found Nebyly nalezeny žádné další výskyty - + Found %Ln matches Nalezeno %Ln shod @@ -658,6 +682,11 @@ Nalezeno %Ln shod + + + Select Directory + + FolderAsWorkspaceDock @@ -1454,9 +1483,9 @@ Ctrl+F - + Find in Files... - Najít v souboru... + Najít v souboru... @@ -1494,8 +1523,8 @@ F11 - - + + Start Recording Začít nahrávání @@ -2032,37 +2061,37 @@ - + Go to line Přejít na řádek - + Line Number (1 - %1) Číslo řádku (1 – %1) - + Stop Recording Zastavit nahrávání - + Debug Info Debug Info - + New %1 Nový %1 - + Create File Vytvořit soubor - + <b>%1</b> does not exist. Do you want to create it? <b>%1</b> neexistuje. Chcete jej vytvořit? @@ -2079,7 +2108,7 @@ Uložit soubor - + Open Folder as Workspace Otevřít složku jako pracovní prostor diff --git a/i18n/NotepadNext_es.ts b/i18n/NotepadNext_es.ts index 1dea655cf..30b67e793 100644 --- a/i18n/NotepadNext_es.ts +++ b/i18n/NotepadNext_es.ts @@ -499,159 +499,187 @@ FindReplaceDialog - - - + + + Find Buscar - + Search Mode Modo de búsqueda - + &Normal &Normal - + E&xtended (\n, \r, \t, \0, \x...) E&xtendida (\n, \r, \t, \0, \x...) - + Re&gular expression Expresión re&gular - + &. matches newline &. coincide con una nueva línea - + Transparenc&y Transparenc&ia - + On losing focus Al perder el enfoque - + Always Siempre - + Coun&t Con&tar - + &Replace &Reemplazar - + Replace &All Reemplazar &todo - + Replace All in &Opened Documents Reemplazar todo en documentos &abiertos - + + Replace All in Files + + + + Find All in All &Opened Documents Buscar todo en todos los documentos &abiertos - + Find All in Current Document Buscar todo en el documento actual - + Close Cerrar - + &Find: &Buscar: - + Replace: Reemplazar: - + + Path of directory containing files to be replaced: + + + + + Select Containing Directory + + + + Backward direction Sentido inverso - + Match &whole word only Coincidir solo &palabra completa - + Match &case Coincidir &minúsculas/mayúsculas - + Wra&p Around Búsqueda circular - + Replace Reemplazar - - + + Replaced %Ln matches Se ha reemplazado %Ln incidencia Se han reemplazado %Ln incidencias + + + Replaced matches in %Ln files + + + + + - + The end of the document has been reached. Found 1st occurrence from the top. Se ha alcanzado el fin del documento. Se encontró la 1ª incidencia desde arriba. - + No matches found. Ninguna incidencia encontrada - + 1 occurrence was replaced Se reemplazó 1 incidencia - + No more occurrences were found No se encontraron más incidencias - + Found %Ln matches Se ha encontrado %Ln incidencia Se han encontrado %Ln incidencias + + + Select Directory + + FolderAsWorkspaceDock @@ -1449,7 +1477,7 @@ Find in Files... - Buscar en archivos... + Buscar en archivos... diff --git a/i18n/NotepadNext_pl.ts b/i18n/NotepadNext_pl.ts index a5761818c..ede5436e9 100644 --- a/i18n/NotepadNext_pl.ts +++ b/i18n/NotepadNext_pl.ts @@ -499,125 +499,140 @@ FindReplaceDialog - - - + + + Find Znajdź - + Search Mode Tryb wyszukiwania - + &Normal &Normalny - + E&xtended (\n, \r, \t, \0, \x...) Rozsz&erzony (\n, \r, \t, \0, \x...) - + Re&gular expression Wyrażenia re&gularne - + &. matches newline &. nowy wiersz - + Transparenc&y Przeźrocz&ystość - + On losing focus Po utracie skupienia - + Always Zawsze - + Coun&t Policz - + &Replace Zamień - + Replace &All Zamień wszystko - + Replace All in &Opened Documents Zamień wszystko w &otwartych plikach - + + Replace All in Files + + + + Find All in All &Opened Documents Znajdź wszystko w &otwartych plikach - + Find All in Current Document Znajdź wszystko w bieżącym pliku - + Close Zamknij - + &Find: Znajdź: - + Replace: Zamień: - + + Path of directory containing files to be replaced: + + + + + Select Containing Directory + + + + Backward direction Wstecz - + Match &whole word only Całe sło&wa - + Match &case Wielkość liter - + Wra&p Around Zawijanie dokumentu - + Replace Zamień - - + + Replaced %Ln matches Zamieniono %Ln wystąpienie @@ -625,28 +640,37 @@ Zamieniono %Ln wystąpień + + + Replaced matches in %Ln files + + + + + + - + The end of the document has been reached. Found 1st occurrence from the top. Osiągnięto koniec dokumentu. Znaleziono pierwsze wystąpienie od góry. - + No matches found. Nie znaleziono żadnego wystąpienia. - + 1 occurrence was replaced 1 wystąpienie zostało zamienione - + No more occurrences were found Nie znaleziono więcej wystąpień - + Found %Ln matches Znaleziono %Ln wystąpienie @@ -654,6 +678,11 @@ Znaleziono %Ln wystąpień + + + Select Directory + + FolderAsWorkspaceDock @@ -1451,7 +1480,7 @@ Find in Files... - Znajdź w plikach... + Znajdź w plikach... diff --git a/i18n/NotepadNext_pt_BR.ts b/i18n/NotepadNext_pt_BR.ts index 4ace78419..68e144ab0 100644 --- a/i18n/NotepadNext_pt_BR.ts +++ b/i18n/NotepadNext_pt_BR.ts @@ -499,159 +499,187 @@ FindReplaceDialog - - - + + + Find Localizar - + Search Mode Modo de pesquisa - + &Normal &Normal - + E&xtended (\n, \r, \t, \0, \x...) E&stendida (\n, \r, \t, \0, \x...) - + Re&gular expression Expressão re&gular - + &. matches newline &. corresponde a uma nova linha - + Transparenc&y Transparênc&ia - + On losing focus Ao perder o foco - + Always Sempre - + Coun&t Con&tar - + &Replace &Substituir - + Replace &All Substituir &tudo - + Replace All in &Opened Documents Substituir tudo nos arquivos &abertos - + + Replace All in Files + + + + Find All in All &Opened Documents Localizar tudo em todos os arquivos &abertos - + Find All in Current Document Localizar tudo no arquivo atual - + Close Fechar - + &Find: &Localizar: - + Replace: Substituir: - + + Path of directory containing files to be replaced: + + + + + Select Containing Directory + + + + Backward direction No sentido inverso - + Match &whole word only Corresponder apenas à palavra &inteira - + Match &case Corresponder as letras &minúsculas/maiúsculas - + Wra&p Around Pesquisar e circular - + Replace Substituir - - + + Replaced %Ln matches Foi substituída %Ln correspondência Foram substituídas %Ln correspondências + + + Replaced matches in %Ln files + + + + + - + The end of the document has been reached. Found 1st occurrence from the top. O fim do arquivo foi alcançado. Foi localizada a 1ª ocorrência de cima para baixo. - + No matches found. Nenhuma correspondência foi encontrada - + 1 occurrence was replaced Uma ocorrência foi substituída - + No more occurrences were found Não foram localizadas outras ocorrências - + Found %Ln matches Foi localizada %Ln correspondência Foram localizadas %Ln correspondências + + + Select Directory + + FolderAsWorkspaceDock @@ -1449,7 +1477,7 @@ Find in Files... - Localizar nos arquivos... + Localizar nos arquivos... diff --git a/i18n/NotepadNext_pt_PT.ts b/i18n/NotepadNext_pt_PT.ts index f7c4cf66b..aa345b100 100644 --- a/i18n/NotepadNext_pt_PT.ts +++ b/i18n/NotepadNext_pt_PT.ts @@ -501,159 +501,187 @@ FindReplaceDialog - - - + + + Find Localizar - + Search Mode Modo de pesquisa - + &Normal &Normal - + E&xtended (\n, \r, \t, \0, \x...) A&largada (\n, \r, \t, \0, \x...) - + Re&gular expression Expressão re&gular - + &. matches newline &. corresponde a uma nova linha - + Transparenc&y Transparênc&ia - + On losing focus Sobre perder o foco - + Always Sempre - + Coun&t Con&tar - + &Replace &Substituir - + Replace &All Substituir &tudo - + Replace All in &Opened Documents Substituir tudo em documentos &abertos - + + Replace All in Files + + + + Find All in All &Opened Documents Localizar tudo em todos os documentos &abertos - + Find All in Current Document Localizar tudo no documento atual - + Close Fechar - + &Find: &Localizar: - + Replace: Substituir: - + + Path of directory containing files to be replaced: + + + + + Select Containing Directory + + + + Backward direction Sentido inverso - + Match &whole word only Corresponder apenas à palavra &inteira - + Match &case Corresponder &minúsculas/maiúsculas - + Wra&p Around En&volvente - + Replace Substituir - - + + Replaced %Ln matches Substituído %Ln correspondência Substituído %Ln correspondências + + + Replaced matches in %Ln files + + + + + - + The end of the document has been reached. Found 1st occurrence from the top. O fim do documento foi atingido. Localizada a 1ª ocorrência a partir do topo. - + No matches found. Não foram localizadas correspondências. - + 1 occurrence was replaced 1 ocorrência foi substituída - + No more occurrences were found - + Found %Ln matches Localizado %Ln correspondência Localizado %Ln correspondências + + + Select Directory + + FolderAsWorkspaceDock @@ -1451,7 +1479,7 @@ Find in Files... - Localizar em Ficheiros... + Localizar em Ficheiros... diff --git a/i18n/NotepadNext_ru.ts b/i18n/NotepadNext_ru.ts index e24131235..1a185890d 100644 --- a/i18n/NotepadNext_ru.ts +++ b/i18n/NotepadNext_ru.ts @@ -495,125 +495,140 @@ FindReplaceDialog - - - + + + Find Поиск - + Search Mode Режим поиска - + &Normal &Нормальный - + E&xtended (\n, \r, \t, \0, \x...) Р&асширенный (\n, \r, \t, \0, \x...) - + Re&gular expression &Регулярное выражение - + &. matches newline &. - новая строка - + Transparenc&y Про&зрачность - + On losing focus При потере фокуса - + Always Всегда - + Coun&t &Подсчитать - + &Replace &Заменить - + Replace &All Заменить &все - + Replace All in &Opened Documents Заменить все во всех о&ткрытых документах - + + Replace All in Files + + + + Find All in All &Opened Documents Найти все во всех откр&ытых документах - + Find All in Current Document Найти все в текущем документе - + Close Закрыть - + &Find: &Найти: - + Replace: Заменить: - + + Path of directory containing files to be replaced: + + + + + Select Containing Directory + + + + Backward direction Обратное направление поиска - + Match &whole word only Только целые &слова - + Match &case Учитывать &регистр - + Wra&p Around За&циклить поиск - + Replace Замена - - + + Replaced %Ln matches Заменено %Ln соответствие @@ -621,28 +636,37 @@ Заменено %Ln соответствий + + + Replaced matches in %Ln files + + + + + + - + The end of the document has been reached. Found 1st occurrence from the top. Достигнут конец документа. Обнаружено первое соответствие сверху. - + No matches found. Не найдено соответствий. - + 1 occurrence was replaced 1 совпадение заменено - + No more occurrences were found Больше совпадений не обнаружено - + Found %Ln matches Найдено %Ln соответствие @@ -650,6 +674,11 @@ Найдено %Ln соответствий + + + Select Directory + + FolderAsWorkspaceDock @@ -1447,7 +1476,7 @@ Find in Files... - Найти в файлах... + Найти в файлах... diff --git a/i18n/NotepadNext_sv.ts b/i18n/NotepadNext_sv.ts index 933df266b..c52112f18 100644 --- a/i18n/NotepadNext_sv.ts +++ b/i18n/NotepadNext_sv.ts @@ -511,97 +511,112 @@ FindReplaceDialog - - - + + + Find Sök - + Search Mode Sökläge - + &Normal &Normal - + E&xtended (\n, \r, \t, \0, \x...) &Utökat (\n, \r, \t, \0, \x...) - + Re&gular expression &Regular expression - + &. matches newline &. matchar ny rad - + Transparenc&y &Transparens - + On losing focus Vid förlorat fokus - + Always Alltid - + Coun&t &Räkna - + &Replace &Ersätt - + Replace &All Ersätt &alla - + Replace All in &Opened Documents Ersätt alla i &öppna dokument - + + Replace All in Files + + + + Find All in All &Opened Documents Sök alla i &öppna dokument - + Find All in Current Document Sök alla i aktuellt dokument - + Close Stäng - + &Find: &Sök: - + Replace: Ersätt: + + + Path of directory containing files to be replaced: + + + + + Select Containing Directory + + &Find what: &Sök vad: @@ -611,27 +626,27 @@ Ersätt med: - + Backward direction Bakåtriktning - + Match &whole word only Matcha endast &hela ord - + Match &case Matcha &skiftläge - + Wra&p Around &Radbryt - + Replace Ersätt @@ -640,42 +655,55 @@ Ersatte %L1 träffar - - + + Replaced %Ln matches Ersatte %Ln träff Ersatte %Ln träffar + + + Replaced matches in %Ln files + + + + + - + The end of the document has been reached. Found 1st occurrence from the top. Slutet på dokumentet har nåtts. Hittade 1:a förekomsten från toppen. - + No matches found. Inga träffar. - + 1 occurrence was replaced 1 förekomst ersattes - + No more occurrences were found Inga fler förekomster hittades - + Found %Ln matches Hittade %Ln träff Hittade %Ln träffar + + + Select Directory + + Found %L1 matches Hittade %L1 träffar @@ -1952,7 +1980,7 @@ Find in Files... - Sök i filer... + Sök i filer... diff --git a/i18n/NotepadNext_tr.ts b/i18n/NotepadNext_tr.ts index c6d133b1d..afb3829a3 100644 --- a/i18n/NotepadNext_tr.ts +++ b/i18n/NotepadNext_tr.ts @@ -500,157 +500,184 @@ FindReplaceDialog - - - + + + Find Bul - + Search Mode Arama Modu - + &Normal &Normal - + E&xtended (\n, \r, \t, \0, \x...) G&eliştirilmiş (\n, \r, \t, \0, \x..) - + Re&gular expression RE&GEX - + &. matches newline &. satırsonu satırıyla eşleşir - + Transparenc&y Şeffaflı&k - + On losing focus Fokus kaybolduğunda - + Always Her Zaman - + Coun&t Sa&y - + &Replace &Değiştir - + Replace &All &Tümünü Değiştir - + Replace All in &Opened Documents &Açık Olan Tüm Dosyalardakileri Değiştir - + + Replace All in Files + + + + Find All in All &Opened Documents &Açık Olan Tüm Dosyalardakileri Bul - + Find All in Current Document Aktif Dosyadaki Hepsini Bul - + Close Kapat - + &Find: &Değiştir: - + Replace: Değiştir: - + + Path of directory containing files to be replaced: + + + + + Select Containing Directory + + + + Backward direction Geriye doğru yön - + Match &whole word only Sadece &tüm kelimeyi eşleştir - + Match &case Eşleşme &durumu - + Wra&p Around E&trafını Sat - + Replace Değiştir - - + + Replaced %Ln matches %Ln eşleşme değiştirildi + + + Replaced matches in %Ln files + + + + - + The end of the document has been reached. Found 1st occurrence from the top. Belgenin sonuna ulaşıldı. Üstten 1. eşleşme bulundu. - + No matches found. Eşleşme Bulunamadı. - + 1 occurrence was replaced 1 eşleşen değiştirildi - + No more occurrences were found Başka eşleşen bulunamadı - + Found %Ln matches %Ln eşleşme bulundu + + + Select Directory + + FolderAsWorkspaceDock diff --git a/i18n/NotepadNext_uk.ts b/i18n/NotepadNext_uk.ts index 81dafd469..cebf1a5dd 100644 --- a/i18n/NotepadNext_uk.ts +++ b/i18n/NotepadNext_uk.ts @@ -495,119 +495,134 @@ FindReplaceDialog - - - + + + Find Шукати - + Search Mode Режим пошуку - + &Normal З&а замовчуванням - + E&xtended (\n, \r, \t, \0, \x...) Р&озширений(\n, \r, \t, \0, \x...) - + Re&gular expression Р&егулярні вирази - + &. matches newline &. - новий рядок - + Transparenc&y &Прозорість вікна - + On losing focus При втраті фокусу - + Always Завжди - + Coun&t &Кількість - + &Replace &Замінити - + Replace &All Замінити &всі - + Replace All in &Opened Documents За&мінити всі у відкритих документах - + + Replace All in Files + + + + Find All in All &Opened Documents З&найти всі у всіх відкритих документах - + Find All in Current Document Знайти всі у поточному документі - + Close Закрити - + &Find: &Шукати: - + Replace: Замінити: - + + Path of directory containing files to be replaced: + + + + + Select Containing Directory + + + + Backward direction Зворотній напрям - + Match &whole word only Ш&укати ціле слово - + Match &case Враховувати рег&істр - + Wra&p Around &Циклічний пошук - + Replace Замінити @@ -616,8 +631,8 @@ Замінено %L1 відповідність - - + + Replaced %Ln matches Замінено %Ln співпадінь @@ -625,28 +640,37 @@ + + + Replaced matches in %Ln files + + + + + + - + The end of the document has been reached. Found 1st occurrence from the top. Досягнуто кінець документу. Знайдено 1 збіг. - + No matches found. Нічого не знайдено. - + 1 occurrence was replaced Був замінений 1 збіг - + No more occurrences were found Більше збігів не знайдено - + Found %Ln matches Знайдено %Ln співпадінь @@ -654,6 +678,11 @@ + + + Select Directory + + Found %L1 matches Знайдено %L1 збігів @@ -1455,7 +1484,7 @@ Find in Files... - Знайти в файлах... + Знайти в файлах... diff --git a/i18n/NotepadNext_zh_CN.ts b/i18n/NotepadNext_zh_CN.ts index 823c37535..1515f085b 100644 --- a/i18n/NotepadNext_zh_CN.ts +++ b/i18n/NotepadNext_zh_CN.ts @@ -512,120 +512,135 @@ FindReplaceDialog - - - + + + Find 查找 - + Search Mode 搜索模式 - + &Normal 正常模式(&N) - + E&xtended (\n, \r, \t, \0, \x...) 扩展模式(&E) (\n, \r, \t, \0, \x...) - + Re&gular expression 正则表达式 (&g) - + &. matches newline &. 匹配换行 - + Transparenc&y 透明度(&y) - + On losing focus 失去焦点时 - + Always 总是 - + Coun&t 计数(&t) - + &Replace 替换(&R) - + Replace &All 全部替换(&A) - + Replace All in &Opened Documents 替换所有打开文件(&O) - + + Replace All in Files + + + + Find All in All &Opened Documents 查找所有打开文件(&O) - + Find All in Current Document 查找当前文档 - + Close 关闭 - + &Find: &查找: - + Replace: 替换: - + + Path of directory containing files to be replaced: + + + + + Select Containing Directory + + + + Backward direction 反向搜索 - + Match &whole word only 全词匹配(&w) - + Match &case 匹配大小写(&c) - + Wra&p Around 开启此选项,搜索达到文件末尾后,会自动从头继续搜索。 循环搜索(&p) - + Replace 替换 @@ -634,40 +649,52 @@ 已替换 %L1 个匹配项 - - + + Replaced %Ln matches 已替换 %Ln 个匹配项 + + + Replaced matches in %Ln files + + + + - + The end of the document has been reached. Found 1st occurrence from the top. 已经到达文档的末尾。从顶部找到第一个匹配项。 - + No matches found. 没有找到匹配项。 - + 1 occurrence was replaced 已替换 1 个匹配项 - + No more occurrences were found 没有找到更多匹配项 - + Found %Ln matches 找到 %Ln 个匹配项 + + + Select Directory + + Found %L1 matches 查找了 %L1 个匹配项 @@ -1928,7 +1955,7 @@ Find in Files... - 在文件中查找... + 在文件中查找... diff --git a/i18n/NotepadNext_zh_TW.ts b/i18n/NotepadNext_zh_TW.ts index c83335f1b..957c4d192 100644 --- a/i18n/NotepadNext_zh_TW.ts +++ b/i18n/NotepadNext_zh_TW.ts @@ -499,157 +499,184 @@ FindReplaceDialog - - - + + + Find 查詢 - + Search Mode 搜尋模式 - + &Normal 正常模式(&N) - + E&xtended (\n, \r, \t, \0, \x...) 擴充套件模式(&E) (\n, \r, \t, \0, \x...) - + Re&gular expression 正則表達式 (&g) - + &. matches newline &. 符合換行符號 - + Transparenc&y 透明度(&y) - + On losing focus 失去焦點時 - + Always 總是 - + Coun&t 計數(&t) - + &Replace 取代(&R) - + Replace &All 全部取代(&A) - + Replace All in &Opened Documents 取代所有開啟檔案(&O) - + + Replace All in Files + + + + Find All in All &Opened Documents 查詢所有開啟檔案(&O) - + Find All in Current Document 查詢目前文件 - + Close 關閉 - + &Find: &查詢: - + Replace: 取代: - + + Path of directory containing files to be replaced: + + + + + Select Containing Directory + + + + Backward direction 反向搜尋 - + Match &whole word only 全詞符合(&w) - + Match &case 大小寫相符(&c) - + Wra&p Around 迴圈搜尋(&p) - + Replace 取代 - - + + Replaced %Ln matches 已取代 %Ln 個符合項目 + + + Replaced matches in %Ln files + + + + - + The end of the document has been reached. Found 1st occurrence from the top. 已經到達文件的末尾。從頂端找到第一個符合項目。 - + No matches found. 沒有找到符合項目。 - + 1 occurrence was replaced 已取代 1 個符合項目 - + No more occurrences were found 沒有找到更多符合項目 - + Found %Ln matches 找到 %Ln 個符合項目 + + + Select Directory + + FolderAsWorkspaceDock @@ -1894,7 +1921,7 @@ Find in Files... - 在檔案中尋找... + 在檔案中尋找... diff --git a/src/NotepadNext/dialogs/FindReplaceDialog.cpp b/src/NotepadNext/dialogs/FindReplaceDialog.cpp index a8d8d5ad6..cb29307ad 100644 --- a/src/NotepadNext/dialogs/FindReplaceDialog.cpp +++ b/src/NotepadNext/dialogs/FindReplaceDialog.cpp @@ -24,6 +24,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include "ScintillaNext.h" #include "MainWindow.h" @@ -39,6 +45,26 @@ static void convertToExtended(QString &str) // TODO: more } +bool isBinary(QString filename, int maxBytesToCheck = 1024){ + QFile file(filename); + if (!file.open(QFile::ReadOnly)) { + qDebug() << "File " << filename << " is binary"; + return true; + } + + QByteArray data = file.read(maxBytesToCheck); + file.close(); + + for (char c : data) { + if ((c < 0x09) || (c > 0x0D && c < 0x20) || c == 0x7F) { + qDebug() << "File" << filename << "is binary (non-text bytes detected)"; + return true; + } + } + + return false; +} + FindReplaceDialog::FindReplaceDialog(ISearchResultsHandler *searchResults, MainWindow *window) : QDialog(window, Qt::Dialog), ui(new Ui::FindReplaceDialog), @@ -143,6 +169,42 @@ FindReplaceDialog::FindReplaceDialog(ISearchResultsHandler *searchResults, MainW showMessage(tr("Replaced %Ln matches", "", count), "green"); }); + connect(ui->buttonReplaceAllInFiles, &QPushButton::clicked, this, [=]() { + int count = 0; + QString dirname = ui->comboReplaceInFiles->currentText(); + QString toFind = ui->comboFind->currentText(); + QString toReplace = ui->comboReplace->currentText(); + QStringList fileList; + + QDirIterator it(dirname, QDir::Files, QDirIterator::Subdirectories); + while (it.hasNext()) { + fileList.append(it.next()); // Add file path to the list + } + + qDebug() << "Obtained filelist for replacement from user:"; + for (const QString &file : fileList){ + qDebug() << file; + } + + for (const QString &file : fileList){ + if (isBinary(file)){ + qDebug() << "Skipping likely binary file: " << file; + continue; + } + + QFile toModifyFile(file); + toModifyFile.open(QIODevice::ReadWrite); + QByteArray text = toModifyFile.readAll(); + text.replace(toFind.toUtf8(), toReplace.toUtf8()); + toModifyFile.seek(0); + toModifyFile.write(text); + toModifyFile.close(); + + count += 1; + } + + showMessage(tr("Replaced matches in %Ln files", "", count), "green"); + }); connect(ui->buttonClose, &QPushButton::clicked, this, &FindReplaceDialog::close); loadSettings(); @@ -435,6 +497,10 @@ void FindReplaceDialog::changeTab(int index) ui->buttonReplace->hide(); ui->buttonReplaceAll->hide(); ui->buttonReplaceAllInDocuments->hide(); + ui->comboReplaceInFiles->hide(); + ui->labelReplaceinFiles->hide(); + ui->buttonReplaceAllInFiles->hide(); + ui->buttonFindInFilesSelector->hide(); ui->buttonCount->show(); ui->buttonFindAllInCurrent->show(); @@ -448,6 +514,12 @@ void FindReplaceDialog::changeTab(int index) ui->buttonReplace->show(); ui->buttonReplaceAll->show(); ui->buttonReplaceAllInDocuments->show(); + ui->comboReplaceInFiles->show(); + ui->labelReplaceinFiles->show(); + ui->comboReplaceInFiles->show(); + ui->labelReplaceinFiles->show(); + ui->buttonReplaceAllInFiles->show(); + ui->buttonFindInFilesSelector->show(); ui->buttonCount->hide(); ui->buttonFindAllInCurrent->hide(); @@ -627,3 +699,22 @@ void FindReplaceDialog::showMessage(const QString &message, const QString &color statusBar->setStyleSheet(QStringLiteral("color: %1").arg(color)); statusBar->showMessage(message); } + +void FindReplaceDialog::on_buttonFindInFilesSelector_clicked() +{ + QString dir = QFileDialog::getExistingDirectory( + this, + tr("Select Directory"), + "", + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks + ); + + int currentIndex = ui->comboReplaceInFiles->currentIndex(); + if (currentIndex != -1) { + ui->comboReplaceInFiles->setItemText(currentIndex, dir); + } else { + ui->comboReplaceInFiles->addItem(dir); + ui->comboReplaceInFiles->setCurrentIndex(ui->comboReplaceInFiles->count() - 1); + } +} + diff --git a/src/NotepadNext/dialogs/FindReplaceDialog.h b/src/NotepadNext/dialogs/FindReplaceDialog.h index a85b3ea0a..d21288a02 100644 --- a/src/NotepadNext/dialogs/FindReplaceDialog.h +++ b/src/NotepadNext/dialogs/FindReplaceDialog.h @@ -86,6 +86,8 @@ private slots: void changeTab(int index); + void on_buttonFindInFilesSelector_clicked(); + private: QString findString(); void prepareToPerformSearch(bool replace=false); diff --git a/src/NotepadNext/dialogs/FindReplaceDialog.ui b/src/NotepadNext/dialogs/FindReplaceDialog.ui index cdcddd654..5d18604fe 100644 --- a/src/NotepadNext/dialogs/FindReplaceDialog.ui +++ b/src/NotepadNext/dialogs/FindReplaceDialog.ui @@ -7,9 +7,15 @@ 0 0 600 - 325 + 350 + + + 600 + 350 + + Find @@ -282,6 +288,13 @@ + + + + Replace All in Files + + + @@ -328,7 +341,7 @@ - + 11 @@ -418,6 +431,27 @@ + + + + Path of directory containing files to be replaced: + + + + + + + true + + + + + + + Select Containing Directory + + + @@ -483,7 +517,6 @@ buttonCount buttonReplace buttonReplaceAll - buttonReplaceAllInDocuments buttonFindAllInDocuments buttonFindAllInCurrent buttonClose diff --git a/src/NotepadNext/dialogs/MainWindow.cpp b/src/NotepadNext/dialogs/MainWindow.cpp index 655843ed3..92d2208e5 100644 --- a/src/NotepadNext/dialogs/MainWindow.cpp +++ b/src/NotepadNext/dialogs/MainWindow.cpp @@ -361,6 +361,10 @@ MainWindow::MainWindow(NotepadNextApplication *app) : showFindReplaceDialog(FindReplaceDialog::REPLACE_TAB); }); + connect(ui->actionFindInFiles, &QAction::triggered, this, [=]() { + showFindReplaceDialog(FindReplaceDialog::REPLACE_TAB); + }); + connect(ui->actionGoToLine, &QAction::triggered, this, [=]() { ScintillaNext *editor = currentEditor(); const int currentLine = editor->lineFromPosition(editor->currentPos()) + 1; diff --git a/src/NotepadNext/dialogs/MainWindow.ui b/src/NotepadNext/dialogs/MainWindow.ui index a0564b35b..664fe0342 100644 --- a/src/NotepadNext/dialogs/MainWindow.ui +++ b/src/NotepadNext/dialogs/MainWindow.ui @@ -40,7 +40,7 @@ 0 0 855 - 21 + 23 @@ -224,10 +224,10 @@ - + @@ -886,7 +886,7 @@ - Find in Files... + Replace in Files...