diff options
author | 2016-07-04 22:18:02 -0400 | |
---|---|---|
committer | 2016-07-04 22:18:02 -0400 | |
commit | c80bfcbe4cb347998faf690c658e75d8b847e5f6 (patch) | |
tree | 2f36bf7ad966859ff2aed6664562f07d22fdbc7e | |
parent | 033ff6510da63d87582c00b297bb5cb32c3eeac4 (diff) | |
download | textadept-c80bfcbe4cb347998faf690c658e75d8b847e5f6.tar.gz textadept-c80bfcbe4cb347998faf690c658e75d8b847e5f6.zip |
Added timeout prompt for "Find in Files".
It is now possible to cancel a "Find in Files" search part-way through.
-rw-r--r-- | core/locale.conf | 3 | ||||
-rw-r--r-- | core/locales/locale.ar.conf | 3 | ||||
-rw-r--r-- | core/locales/locale.de.conf | 3 | ||||
-rw-r--r-- | core/locales/locale.es.conf | 3 | ||||
-rw-r--r-- | core/locales/locale.fr.conf | 3 | ||||
-rw-r--r-- | core/locales/locale.it.conf | 3 | ||||
-rw-r--r-- | core/locales/locale.pl.conf | 3 | ||||
-rw-r--r-- | core/locales/locale.ru.conf | 3 | ||||
-rw-r--r-- | core/locales/locale.sv.conf | 3 | ||||
-rw-r--r-- | doc/manual.md | 22 | ||||
-rw-r--r-- | modules/textadept/find.lua | 22 |
11 files changed, 61 insertions, 10 deletions
diff --git a/core/locale.conf b/core/locale.conf index 2101982f..eb168f81 100644 --- a/core/locale.conf +++ b/core/locale.conf @@ -83,6 +83,9 @@ No results found = No results found [Files Found Buffer] = [Files Found Buffer] Binary file matches. = Binary file matches. Search wrapped = Search wrapped +Continue? = Continue? +Still searching in files... Continue waiting? = Still searching in files... Continue waiting? +Find in Files aborted = Find in Files aborted Error = Error An error occurred: = An error occurred: #_OK = _OK diff --git a/core/locales/locale.ar.conf b/core/locales/locale.ar.conf index 93556bd5..a278f5b8 100644 --- a/core/locales/locale.ar.conf +++ b/core/locales/locale.ar.conf @@ -84,6 +84,9 @@ No results found = عذرًا, لا يوجد نتائج [Files Found Buffer] = [مذكرة الملفات التي بحثْتُ عنها] Binary file matches. = Binary file matches. Search wrapped = تلقائيًا عُدْ إلى البداية +Continue? = Continue? +Still searching in files... Continue waiting? = Still searching in files... Continue waiting? +Find in Files aborted = Find in Files aborted Error = خلل An error occurred: = حصل خلل ما: #_OK = _موافق diff --git a/core/locales/locale.de.conf b/core/locales/locale.de.conf index f71de9d8..b749fc51 100644 --- a/core/locales/locale.de.conf +++ b/core/locales/locale.de.conf @@ -84,6 +84,9 @@ No results found = Keine Treffer gefunden [Files Found Buffer] = [Gefundene Dateien-Buffer] Binary file matches. = Übereinstimmungen in Binärdatei. Search wrapped = Suche beginnt von oben +Continue? = Continue? +Still searching in files... Continue waiting? = Still searching in files... Continue waiting? +Find in Files aborted = Find in Files aborted Error = Fehler An error occurred: = Ein Fehler ist aufgetreten: #_OK = _OK diff --git a/core/locales/locale.es.conf b/core/locales/locale.es.conf index 67628165..51d17893 100644 --- a/core/locales/locale.es.conf +++ b/core/locales/locale.es.conf @@ -84,6 +84,9 @@ No results found = No se han encontrado coincidencias [Files Found Buffer] = [Buffer de búsqueda en ficheros] Binary file matches. = Coincidencia en fichero binario. Search wrapped = La búsqueda ha sobrepasado el final/inicio del documento +Continue? = Continue? +Still searching in files... Continue waiting? = Still searching in files... Continue waiting? +Find in Files aborted = Find in Files aborted Error = Error An error occurred: = Ha ocurrido un error: #_OK = _Aceptar diff --git a/core/locales/locale.fr.conf b/core/locales/locale.fr.conf index 642dc59a..d08c934c 100644 --- a/core/locales/locale.fr.conf +++ b/core/locales/locale.fr.conf @@ -85,6 +85,9 @@ No results found = Aucun résultat trouvé [Files Found Buffer] = [Onglet des fichiers trouvés] Binary file matches. = Correspondances dans un fichier binaire Search wrapped = La recherche a recommencé +Continue? = Continue? +Still searching in files... Continue waiting? = Still searching in files... Continue waiting? +Find in Files aborted = Find in Files aborted Error = Erreur An error occurred: = Une erreur est survenue: #_OK = _OK diff --git a/core/locales/locale.it.conf b/core/locales/locale.it.conf index c5c29481..192caf63 100644 --- a/core/locales/locale.it.conf +++ b/core/locales/locale.it.conf @@ -84,6 +84,9 @@ No results found = Nessun risultato trovato [Files Found Buffer] = [Scheda dei file trovati] Binary file matches. = Corrispondenze in un file binario. Search wrapped = La ricerca è ricominciata +Continue? = Continue? +Still searching in files... Continue waiting? = Still searching in files... Continue waiting? +Find in Files aborted = Find in Files aborted Error = Errore An error occurred: = È avvenuto un errore: #_OK = _OK diff --git a/core/locales/locale.pl.conf b/core/locales/locale.pl.conf index df052245..98ed42f7 100644 --- a/core/locales/locale.pl.conf +++ b/core/locales/locale.pl.conf @@ -84,6 +84,9 @@ 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 +Continue? = Continue? +Still searching in files... Continue waiting? = Still searching in files... Continue waiting? +Find in Files aborted = Find in Files aborted Error = Błąd An error occurred: = Wystąpił błąd: #_OK = _OK diff --git a/core/locales/locale.ru.conf b/core/locales/locale.ru.conf index 081dec03..e59ae521 100644 --- a/core/locales/locale.ru.conf +++ b/core/locales/locale.ru.conf @@ -84,6 +84,9 @@ No results found = Ничего не найдено [Files Found Buffer] = [Буфер поиска в файлах] Binary file matches. = Соответствие в двоичном файле. Search wrapped = Искать по кругу +Continue? = Continue? +Still searching in files... Continue waiting? = Still searching in files... Continue waiting? +Find in Files aborted = Find in Files aborted Error = Ошибка An error occurred: = Произошла ошибка: #_OK = _OK diff --git a/core/locales/locale.sv.conf b/core/locales/locale.sv.conf index c67ef832..7a621017 100644 --- a/core/locales/locale.sv.conf +++ b/core/locales/locale.sv.conf @@ -84,6 +84,9 @@ No results found = Inga resultat hittades [Files Found Buffer] = [Files Found Buffer] Binary file matches. = Binär fil matchar. Search wrapped = Sökningen slog runt +Continue? = Continue? +Still searching in files... Continue waiting? = Still searching in files... Continue waiting? +Find in Files aborted = Find in Files aborted Error = Fel An error occurred: = Ett fel inträffade: #_OK = _Ok diff --git a/doc/manual.md b/doc/manual.md index 6d0ea5ba..4d297212 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -742,14 +742,14 @@ file-type filter. While the default filter excludes many common binary files and version control folders from searches, Find in Files could still scan unrecognized binary files or large, unwanted sub-directories. Searches also block Textadept from receiving additional input, making the interface -temporarily unresponsive. Searching large directories or projects can be very -time consuming and frustrating, so you may prefer to use a specialized, external -tool such as [ack][]. +temporarily unresponsive. By default, every 10 seconds or so, Textadept will +prompt you to continue a "Find in Files" search, allowing you to cancel one that +is taking too long. You can change this timeout in your +[preferences](#Module.Preferences).  [find API]: api.html#ui.find.find_in_files_filter -[ack]: http://betterthangrep.com/ ### Incremental Find @@ -999,11 +999,13 @@ the sections below. Theming is covered in a later section. Many of Textadept's default modules come with configurable settings that can be changed from your *~/.textadept/init.lua* (which is executed after those modules are loaded). Each module's [API documentation][] lists any configurable settings -it has. For example, in order to always hide the tab bar, disable character -autopairing with typeover, strip trailing whitespace on save, and use C99-style -line comments in C code, add the following to *~/.textadept/init.lua*: +it has. For example, in order to always hide the tab bar, shorten the "Find in +Files" timeout prompt, disable character autopairing with typeover, strip +trailing whitespace on save, and use C99-style line comments in C code, add the +following to *~/.textadept/init.lua*: ui.tabs = false + ui.find.find_in_files_timeout = 5 textadept.editing.auto_pair = nil textadept.editing.typeover_chars = nil textadept.editing.strip_trailing_spaces = true @@ -1024,6 +1026,10 @@ do so: textadept.run.build_commands['/path/to/project'] = 'shell command' +**Tip:** You can quickly view the documentation for the setting under the caret +by pressing `Ctrl+H` (`^H` on Mac OSX | `M-H` or `M-S-H` in curses). This +applies to pretty much any Lua identifier, not just settings. + [API documentation]: api.html ### Language Preferences @@ -2195,6 +2201,7 @@ goto\_view(n, relative) |Changed |[goto\_view][](view) **ui.find** | | FILTER |Renamed |[find\_in\_files\_filter][] find\_in\_files(dir) |Changed |[find\_in\_files][](dir, filter) +N/A |Added |[find\_in\_files\_timeout][] lua |Changed |[regex][] lua\_pattern\_label\_text |Changed |[regex\_label\_text][] **view** | | @@ -2239,6 +2246,7 @@ MAX\_RECENT\_FILES |Renamed |[max\_recent\_files][] [goto\_view]: api.html#ui.goto_view [find\_in\_files\_filter]: api.html#ui.find.find_in_files_filter [find\_in\_files]: api.html#ui.find.find_in_files +[find\_in\_files\_timeout]: api.html#ui.find.find_in_files_timeout [regex]: api.html#ui.find.regex [regex\_label\_text]: api.html#ui.find.regex_label_text [goto\_buffer]: api.html#view.goto_buffer diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index 6bb35d39..9652f474 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -52,6 +52,10 @@ local M = ui.find -- @field in_files_label_text (string, Write-only) -- The text of the "In files" label. -- This is primarily used for localization. +-- @field find_in_files_timeout (number) +-- The approximate interval in seconds between prompts for continuing an +-- "In files" search. +-- The default value is 10 seconds. -- @field INDIC_FIND (number) -- The find in files highlight indicator number. -- @field _G.events.FIND_WRAPPED (string) @@ -74,6 +78,7 @@ M.whole_word_label_text = not CURSES and _L['_Whole word'] or _L['Word(F2)'] M.regex_label_text = not CURSES and _L['Rege_x'] or _L['Regex(F3)'] M.in_files_label_text = not CURSES and _L['_In files'] or _L['Files(F4)'] +M.find_in_files_timeout = 10 M.INDIC_FIND = _SCINTILLA.next_indic_number() -- Events. @@ -241,13 +246,12 @@ function M.find_in_files(dir, filter) local ff_buffer = buffer local buffer = buffer.new() -- temporary buffer - local flags = 0 + buffer.code_page = 0 + local text, flags, found, ref_time = M.find_entry_text, 0, false, os.time() if M.match_case then flags = flags + buffer.FIND_MATCHCASE end if M.whole_word then flags = flags + buffer.FIND_WHOLEWORD end if M.regex then flags = flags + buffer.FIND_REGEXP end buffer.search_flags = flags - local text = M.find_entry_text - local found = false lfs.dir_foreach(dir, function(filename) buffer:clear_all() buffer:empty_undo_buffer() @@ -278,6 +282,18 @@ function M.find_in_files(dir, filter) end buffer:set_target_range(buffer.target_end, buffer.length) end + if os.difftime(os.time(), ref_time) >= M.find_in_files_timeout then + local continue = ui.dialogs.yesno_msgbox{ + title = _L['Continue?'], + text = _L['Still searching in files... Continue waiting?'], + icon = 'gtk-dialog-question', no_cancel = true + } == 1 + if not continue then + ff_buffer:append_text(_L['Find in Files aborted']..'\n') + return false + end + ref_time = os.time() + end end, filter or M.find_in_files_filter) if not found then ff_buffer:append_text(_L['No results found']) end buffer:delete() -- delete temporary buffer |