aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/locale.conf1
-rw-r--r--core/locales/locale.ar.conf1
-rw-r--r--core/locales/locale.de.conf1
-rw-r--r--core/locales/locale.es.conf1
-rw-r--r--core/locales/locale.fr.conf1
-rw-r--r--core/locales/locale.it.conf3
-rw-r--r--core/locales/locale.pl.conf1
-rw-r--r--core/locales/locale.ru.conf1
-rw-r--r--core/locales/locale.sv.conf1
-rw-r--r--modules/textadept/find.lua42
10 files changed, 38 insertions, 15 deletions
diff --git a/core/locale.conf b/core/locale.conf
index 4e4c9f3b..b37a3b05 100644
--- a/core/locale.conf
+++ b/core/locale.conf
@@ -82,6 +82,7 @@ Find in Files = Find in Files
Find: = Find:
No results found = No results found
[Files Found Buffer] = [Files Found Buffer]
+Binary file matches. = Binary file matches.
Search wrapped = Search wrapped
Error = Error
An error occured: = An error occured:
diff --git a/core/locales/locale.ar.conf b/core/locales/locale.ar.conf
index 75b9b6fc..2cbb6866 100644
--- a/core/locales/locale.ar.conf
+++ b/core/locales/locale.ar.conf
@@ -83,6 +83,7 @@ Find in Files = ابحث في الملفات
Find: = ا_بحث
No results found = عذرًا, لا يوجد نتائج
[Files Found Buffer] = [مذكرة الملفات التي بحثْتُ عنها]
+Binary file matches. = Binary file matches.
Search wrapped = تلقائيًا عُدْ إلى البداية
Error = خلل
An error occured: = حصل خلل ما:
diff --git a/core/locales/locale.de.conf b/core/locales/locale.de.conf
index 7f1d9f4b..9599bd87 100644
--- a/core/locales/locale.de.conf
+++ b/core/locales/locale.de.conf
@@ -83,6 +83,7 @@ Find in Files = In Dateien suchen
Find: = Suchen:
No results found = Keine Treffer gefunden
[Files Found Buffer] = [Gefundene Dateien-Buffer]
+Binary file matches. = Binary file matches.
Search wrapped = Suche beginnt von oben
Error = Fehler
An error occured: = Ein Fehler ist aufgetreten:
diff --git a/core/locales/locale.es.conf b/core/locales/locale.es.conf
index 9982b07a..0f05baf1 100644
--- a/core/locales/locale.es.conf
+++ b/core/locales/locale.es.conf
@@ -83,6 +83,7 @@ Find in Files = Buscar en ficheros
Find: = Buscar:
No results found = No se han encontrado coincidencias
[Files Found Buffer] = [Buffer de búsqueda en ficheros]
+Binary file matches. = Binary file matches.
Search wrapped = La búsqueda ha sobrepasado el final/inicio del documento
Error = Error
An error occured: = Ha ocurrido un error:
diff --git a/core/locales/locale.fr.conf b/core/locales/locale.fr.conf
index f5900410..4fa248f1 100644
--- a/core/locales/locale.fr.conf
+++ b/core/locales/locale.fr.conf
@@ -84,6 +84,7 @@ Find in Files = Rechercher dans les fichiers
Find: = Rechercher:
No results found = Aucun résultat trouvé
[Files Found Buffer] = [Onglet des fichiers trouvés]
+Binary file matches. = Binary file matches.
Search wrapped = La recherche a recommencé
Error = Erreur
An error occured: = Une erreur est survenue:
diff --git a/core/locales/locale.it.conf b/core/locales/locale.it.conf
index aaa4e084..9345edc4 100644
--- a/core/locales/locale.it.conf
+++ b/core/locales/locale.it.conf
@@ -83,6 +83,7 @@ Find in Files = Trova nei file
Find: = Cerca:
No results found = Nessun risultato trovato
[Files Found Buffer] = [Scheda dei file trovati]
+Binary file matches. = Binary file matches.
Search wrapped = La ricerca è ricominciata
Error = Errore
An error occured: = È avvenuto un errore:
@@ -231,7 +232,7 @@ Split View _Vertical = Sdoppia la vista _verticalmente
_Unsplit View = _Congiungi la vista
Unsplit _All Views = Congiungi _tutte le viste
_Grow View = _Aumenta la vista
-Shrin_k View = _Riduci la vista
+Shrin_k View = _Riduci la vista
Toggle Current _Fold = P_iega corrente sì/no
Toggle View _EOL = _Mostra la fine di linea sì/no
Toggle _Wrap Mode = _Accapo automatico sì/no
diff --git a/core/locales/locale.pl.conf b/core/locales/locale.pl.conf
index 67ef5552..336caa43 100644
--- a/core/locales/locale.pl.conf
+++ b/core/locales/locale.pl.conf
@@ -83,6 +83,7 @@ Find in Files = Znajdź w plikach
Find: = Znajdź:
No results found = Niczego nie znaleziono
[Files Found Buffer] = [Bufor szukania w plikach]
+Binary file matches. = Binary file matches.
Search wrapped = Automatyczny powrót do początku
Error = Błąd
An error occured: = Wystąpił błąd:
diff --git a/core/locales/locale.ru.conf b/core/locales/locale.ru.conf
index 19fb8fd4..e4b1536d 100644
--- a/core/locales/locale.ru.conf
+++ b/core/locales/locale.ru.conf
@@ -83,6 +83,7 @@ Find in Files = Найти в файлах
Find: = Найти:
No results found = Ничего не найдено
[Files Found Buffer] = [Буфер поиска в файлах]
+Binary file matches. = Binary file matches.
Search wrapped = Искать по кругу
Error = Ошибка
An error occured: = Произошла ошибка:
diff --git a/core/locales/locale.sv.conf b/core/locales/locale.sv.conf
index 17d9ab6d..ade27a4b 100644
--- a/core/locales/locale.sv.conf
+++ b/core/locales/locale.sv.conf
@@ -83,6 +83,7 @@ Find in Files = Sök i filer
Find: = Sök:
No results found = Inga resultat hittades
[Files Found Buffer] = [Files Found Buffer]
+Binary file matches. = Binary file matches.
Search wrapped = Sökningen slog runt
Error = Fel
An error occured: = Ett fel inträffade:
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index 6e234dbd..a7ca40a0 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -274,28 +274,42 @@ function M.find_in_files(dir)
local found = false
lfs.dir_foreach(dir, function(filename)
local match_case = M.match_case
- local line_num = 1
- for line in io.lines(filename) do
+ local f = io.open(filename, 'rb')
+ local binary, line_num = nil, 1
+ for line in f:lines() do
local s, e = lib_find(match_case and line or line:lower(), text)
if s and e then
+ found = true
+ if binary == nil then
+ local pos = f:seek()
+ f:seek('set') -- rewind
+ binary = f:read(65536):find('\0')
+ f:seek('set', pos) -- restore
+ end
local utf8_filename = filename:iconv('UTF-8', _CHARSET)
- buffer:append_text(string.format('%s:%d:%s\n', utf8_filename, line_num,
- line))
- local pos = buffer:position_from_line(buffer.line_count - 2) +
- #utf8_filename + #tostring(line_num) + 2
- if lib_find == string.find then
- -- Positions are bytes.
- buffer:indicator_fill_range(pos + s - 1, e - s + 1)
+ if not binary then
+ buffer:append_text(string.format('%s:%d:%s\n', utf8_filename,
+ line_num, line))
+ local pos = buffer:position_from_line(buffer.line_count - 2) +
+ #utf8_filename + #tostring(line_num) + 2
+ if lib_find == string.find then
+ -- Positions are bytes.
+ buffer:indicator_fill_range(pos + s - 1, e - s + 1)
+ else
+ -- Positions are characters, which may be multiple bytes.
+ s = buffer:position_relative(pos, s - 1)
+ e = buffer:position_relative(pos, e)
+ buffer:indicator_fill_range(s, e - s)
+ end
else
- -- Positions are characters, which may be multiple bytes.
- s = buffer:position_relative(pos, s - 1)
- e = buffer:position_relative(pos, e)
- buffer:indicator_fill_range(s, e - s)
+ buffer:append_text(string.format('%s:1:%s\n', utf8_filename,
+ _L['Binary file matches.']))
+ break
end
- found = true
end
line_num = line_num + 1
end
+ f:close()
end, M.FILTER, true)
if not found then buffer:append_text(_L['No results found']) end
ui._print(_L['[Files Found Buffer]'], '') -- goto end, set save pos, etc.