aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md20
-rw-r--r--core/file_io.lua4
-rw-r--r--core/lfs_ext.lua73
-rw-r--r--doc/manual.md3
-rw-r--r--init.lua1
-rw-r--r--modules/lua/ta_api32
-rw-r--r--modules/lua/ta_tags2
-rw-r--r--modules/textadept/find.lua7
-rw-r--r--test/test.lua103
9 files changed, 125 insertions, 120 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a59d9f8f..9f3439b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -467,7 +467,6 @@ Changes:
[`os.spawn()`]: api.html#os.spawn
[`textadept.editing.show_documentation()`]: api.html#textadept.editing.show_documentation
[`textadept.editing.highlight_word()`]: api.html#textadept.editing.highlight_word
-[file filter]: api.html#lfs.dir_foreach
[PDCurses]: https://pdcurses.sourceforge.io/
## 10.2 (01 Nov 2018)
@@ -1227,7 +1226,7 @@ Download:
Bugfixes:
* Check range bounds for [`buffer:text_range()`][].
-* Fixed inability to properly halt [`lfs.dir_foreach()`][].
+* Fixed inability to properly halt `lfs.dir_foreach()`.
Changes:
@@ -1246,7 +1245,6 @@ Changes:
[PGP -- 9.0 alpha 2 Linux x86_64]: download/textadept_9.0_alpha_2.x86_64.tgz.asc
[PGP -- 9.0 alpha 2 Modules]: download/textadept_9.0_alpha_2.modules.zip.asc
[`buffer:text_range()`]: api.html#buffer.text_range
-[`lfs.dir_foreach()`]: api.html#lfs.dir_foreach
[regular expressions]: manual.html#Regular.Expressions
## 9.0 alpha (01 Jul 2016)
@@ -1279,7 +1277,7 @@ Changes:
* Key and menu commands [must be Lua functions][]; the table syntax is no longer
recognized.
* Renamed `lfs.FILTER` to [`lfs.default_filter`][] and tweaked arguments to
- [`lfs.dir_foreach()`][].
+ `lfs.dir_foreach()`.
* Locale files can optionally use `#` for comments instead of `%`.
* Renamed `ui.SILENT_PRINT` to [`ui.silent_print`][].
* Renamed all [`textadept.editing`]`.[A-Z]+` options to their lower-case
@@ -1323,7 +1321,6 @@ Changes:
[`io.quick_open_filters`]: api.html#io.quick_open_filters
[must be Lua functions]: manual.html#Key.and.Menu.Command.Changes
[`lfs.default_filter`]: api.html#lfs.default_filter
-[`lfs.dir_foreach()`]: api.html#lfs.dir_foreach
[`ui.silent_print`]: api.html#ui.silent_print
[`textadept.editing`]: api.html#textadept.editing
[`textadept.editing.brace_matches`]: api.html#textadept.editing.brace_matches
@@ -1759,7 +1756,7 @@ Bugfixes:
Changes:
* Added `symlink` filter option for ignoring symlinked files and folders to
- [`io.snapopen()`][], [`lfs.dir_foreach()`][], and [`ui.find.FILTER`][].
+ [`io.snapopen()`][], `lfs.dir_foreach()`, and [`ui.find.FILTER`][].
* Added [`_FOLDBYINDENTATION`][] field for lexers that fold by indentation.
* Updated to [Scintilla][] 3.5.5.
@@ -1774,7 +1771,6 @@ Changes:
[PGP -- 8.0 beta Linux x86_64]: download/textadept_8.0_beta.x86_64.tgz.asc
[PGP -- 8.0 beta Modules]: download/textadept_8.0_beta.modules.zip.asc
[`io.snapopen()`]: api.html#io.quick_open
-[`lfs.dir_foreach()`]: api.html#lfs.dir_foreach
[`ui.find.FILTER`]: api.html#ui.find.find_in_files_filter
[`_FOLDBYINDENTATION`]: api.html#lexer.Fold.by.Indentation
[Scintilla]: http://scintilla.org
@@ -2016,8 +2012,7 @@ Bugfixes:
* Ensure "find in files" is off when activating normal find.
* Fixed return values from [`ui.dialogs.optionselect()`][].
* The command entry does not hide when the window loses focus.
-* Fixed '//' bug when iterating over root directory with
- [`lfs.dir_foreach()`][].
+* Fixed '//' bug when iterating over root directory with `lfs.dir_foreach()`.
* Fixed bug in jumping to compile/run errors and clear annotations before
building projects.
* Fixed memory leaks in [`ui.dialog()`][].
@@ -2063,7 +2058,6 @@ Changes:
[`_G.BSD`]: api.html#BSD
[Rectangular selections]: manual.html#Rectangular.Selection
[`ui.dialogs.optionselect()`]: api.html#ui.dialogs.optionselect
-[`lfs.dir_foreach()`]: api.html#lfs.dir_foreach
[`_SCINTILLA.next_image_type()`]: api.html#_SCINTILLA.next_image_type
## 7.7 (01 Oct 2014)
@@ -2124,7 +2118,7 @@ Changes:
* Added Linux .desktop files for menus and launchers.
* Indicate presence of a BOM in the statusbar.
* Switch to previous buffer after closing a buffer.
-* More options for [`lfs.dir_foreach()`][].
+* More options for `lfs.dir_foreach()`.
* Updated to [Scintilla][] 3.5.0.
[Textadept 7.6 -- Win32]: download/textadept_7.6.win32.zip
@@ -2139,7 +2133,6 @@ Changes:
[PGP -- 7.6 Modules]: download/textadept_7.6.modules.zip.asc
[`buffer:del_word_right()`]: api.html#buffer.del_word_right
[`os.spawn()`]: api.html#os.spawn
-[`lfs.dir_foreach()`]: api.html#lfs.dir_foreach
[Scintilla]: http://scintilla.org
## 7.5 (11 Jul 2014)
@@ -3101,7 +3094,7 @@ Bugfixes:
Changes:
* Reset Lua state after selecting a new theme.
-* Added [`lfs.dir_foreach()`][].
+* Added `lfs.dir_foreach()`.
* Added file and directory [filtering][] for Find in Files.
* Moved `_M.textadept.snapopen` into [`io`][].
* Renamed some [`lexer` constants][].
@@ -3124,7 +3117,6 @@ Changes:
[PGP -- 6.5 Modules]: download/textadept_6.5.modules.zip.asc
[`buffer:visible_from_doc_line()`]: api.html#buffer.visible_from_doc_line
[`buffer:line_scroll()`]: api.html#buffer.line_scroll
-[`lfs.dir_foreach()`]: api.html#lfs.dir_foreach
[filtering]: api.html#ui.find.find_in_files_filter
[`io`]: api.html#io.quick_open
[`lexer` constants]: api.html#lexer.FOLD_BASE
diff --git a/core/file_io.lua b/core/file_io.lua
index f90c51ab..99157cb0 100644
--- a/core/file_io.lua
+++ b/core/file_io.lua
@@ -426,10 +426,10 @@ function io.quick_open(paths, filter, opts)
assert_type(opts, 'table/nil', 3)
local utf8_list = {}
for i = 1, #paths do
- lfs.dir_foreach(paths[i], function(filename)
+ for filename in lfs.walk(paths[i], filter or lfs.default_filter) do
if #utf8_list >= io.quick_open_max then return false end
utf8_list[#utf8_list + 1] = filename:iconv('UTF-8', _CHARSET)
- end, filter or lfs.default_filter)
+ end
end
if #utf8_list >= io.quick_open_max then
ui.dialogs.msgbox{
diff --git a/core/lfs_ext.lua b/core/lfs_ext.lua
index abf74dc0..d4acbbb8 100644
--- a/core/lfs_ext.lua
+++ b/core/lfs_ext.lua
@@ -9,8 +9,8 @@ module('lfs')]]
---
-- The filter table containing common binary file extensions and version control
-- directories to exclude when iterating over files and directories using
--- `dir_foreach`.
--- @see dir_foreach
+-- `walk`.
+-- @see walk
-- @class table
-- @name default_filter
lfs.default_filter = {
@@ -22,36 +22,10 @@ lfs.default_filter = {
'!/%.bzr$', '!/%.git$', '!/%.hg$', '!/%.svn$', '!/node_modules$',
}
----
--- Iterates over all files and sub-directories (up to *n* levels deep) in
--- directory *dir*, calling function *f* with each file found.
--- String or list *filter* determines which files to pass through to *f*, with
--- the default filter being `lfs.default_filter`. A filter consists of Lua
--- patterns that match file and directory paths to include or exclude. Exclusive
--- patterns begin with a '!'. If no inclusive patterns are given, any path is
--- initially considered. As a convenience, file extensions can be specified
--- literally instead of as a Lua pattern (e.g. '.lua' vs. '%.lua$'), and '/'
--- also matches the Windows directory separator ('[/\\]' is not needed).
--- @param dir The directory path to iterate over.
--- @param f Function to call with each full file path found. If *f* returns
--- `false` explicitly, iteration ceases.
--- @param filter Optional filter for files and directories to include and
--- exclude. The default value is `lfs.default_filter`.
--- @param n Optional maximum number of directory levels to descend into.
--- The default value is `nil`, which indicates no limit.
--- @param include_dirs Optional flag indicating whether or not to call *f* with
--- directory names too. Directory names are passed with a trailing '/' or '\',
--- depending on the current platform.
--- The default value is `false`.
+-- Documentation is in `lfs.walk()`.
-- @param level Utility value indicating the directory level this function is
--- at. This value is used and set internally, and should not be set otherwise.
--- @see filter
--- @name dir_foreach
-function lfs.dir_foreach(dir, f, filter, n, include_dirs, level)
- assert_type(dir, 'string', 1)
- assert_type(f, 'function', 2)
- assert_type(filter, 'string/table/nil', 3)
- assert_type(n, 'number/nil', 4)
+-- at.
+local function walk(dir, filter, n, include_dirs, level)
if not level then
-- Convert filter to a table from nil or string arguments.
if not filter then filter = lfs.default_filter end
@@ -101,19 +75,46 @@ function lfs.dir_foreach(dir, f, filter, n, include_dirs, level)
local sep = not WIN32 and '/' or '\\'
local os_filename = not WIN32 and filename or filename:gsub('/', sep)
if include and mode == 'directory' then
- if include_dirs and f(os_filename .. sep) == false then return false end
+ if include_dirs then coroutine.yield(os_filename .. sep) end
if n and (level or 0) >= n then goto continue end
- local halt = lfs.dir_foreach(
- filename, f, filter, n, include_dirs, (level or 0) + 1) == false
- if halt then return false end
+ walk(filename, filter, n, include_dirs, (level or 0) + 1)
elseif include and mode == 'file' then
- if f(os_filename) == false then return false end
+ coroutine.yield(os_filename)
end
::continue::
end
end
---
+-- Returns an iterator that iterates over all files and sub-directories (up to
+-- *n* levels deep) in directory *dir* and yields each file found.
+-- String or list *filter* determines which files to yield, with the default
+-- filter being `lfs.default_filter`. A filter consists of Lua patterns that
+-- match file and directory paths to include or exclude. Exclusive patterns
+-- begin with a '!'. If no inclusive patterns are given, any path is initially
+-- considered. As a convenience, file extensions can be specified literally
+-- instead of as a Lua pattern (e.g. '.lua' vs. '%.lua$'), and '/' also matches
+-- the Windows directory separator ('[/\\]' is not needed).
+-- @param dir The directory path to iterate over.
+-- @param filter Optional filter for files and directories to include and
+-- exclude. The default value is `lfs.default_filter`.
+-- @param n Optional maximum number of directory levels to descend into.
+-- The default value is `nil`, which indicates no limit.
+-- @param include_dirs Optional flag indicating whether or not to yield
+-- directory names too. Directory names are passed with a trailing '/' or '\',
+-- depending on the current platform.
+-- The default value is `false`.
+-- @see filter
+-- @name walk
+function lfs.walk(dir, filter, n, include_dirs)
+ assert_type(dir, 'string', 1)
+ assert_type(filter, 'string/table/nil', 2)
+ assert_type(n, 'number/nil', 3)
+ local co = coroutine.create(function() walk(dir, filter, n, include_dirs) end)
+ return function() return select(2, coroutine.resume(co)) end
+end
+
+---
-- Returns the absolute path to string *filename*.
-- *prefix* or `lfs.currentdir()` is prepended to a relative filename. The
-- returned path is not guaranteed to exist.
diff --git a/doc/manual.md b/doc/manual.md
index 0021e971..3aeefdc6 100644
--- a/doc/manual.md
+++ b/doc/manual.md
@@ -2023,6 +2023,8 @@ N/A |Added |[to_eol()][]
delimited\_range() |Replaced|[range()][]
nested\_pair() |Replaced|[range()][]
N/A |Added |[number][]
+**lfs** | |
+dir\_foreach() |Replaced|for filename in [`lfs.walk()`][] do ... end
**textadept.bookmarks** | |
toggle(line, on) |Changed |[toggle()][]
**textadept.file_types**| |
@@ -2054,6 +2056,7 @@ section below.
[to_eol()]: api.html#lexer.to_eol
[range()]: api.html#lexer.range
[number]: api.html#lexer.number
+[`lfs.walk()`]: api.html#lfs.walk
[toggle()]: api.html#textadept.bookmarks.toggle
[insert()]: api.html#textadept.snippets.insert
[previous()]: api.html#textadept.snippets.previous
diff --git a/init.lua b/init.lua
index 5d2b7293..e5926334 100644
--- a/init.lua
+++ b/init.lua
@@ -44,6 +44,7 @@ view.set_theme = set_theme -- needed for the first view
if not arg then view:goto_buffer(buffer) end
-- Temporary compatibility.
+function lfs.dir_foreach(dir, f, filter, n, include_dirs) ui.dialogs.msgbox{text='Compatibility issue',text='Please change your use of "lfs.dir_foreach()" to "for filename in lfs.walk()"'}; for filename in lfs.walk(dir, filter, n, include_dirs) do if f(filename) == false then return end end end
setmetatable(_L, {__index = function(t, k) return rawget(t, k:gsub('_', '')) or 'No Localization:'..k end})
setmetatable(textadept.snippets, {__index = function(t, k) return rawget(t, k:gsub('^_', '')) end})
buffer.set_theme = function(...) view:set_theme(select(2, ...)); events.connect(events.INITIALIZED, function() ui.dialogs.msgbox{title='Compatibility issue',text='Please change your use of "buffer:set_theme()" to "view:set_theme()"'} end) end
diff --git a/modules/lua/ta_api b/modules/lua/ta_api
index 1f58a847..2a5830bd 100644
--- a/modules/lua/ta_api
+++ b/modules/lua/ta_api
@@ -428,9 +428,9 @@ back_tab buffer.back_tab(buffer)\nUn-indents the text on the selected lines.\n@p
begin_undo_action buffer.begin_undo_action(buffer)\nStarts a sequence of actions to be undone or redone as a single action.\nMay be nested.\n@param buffer A buffer.
block_comment textadept.editing.block_comment()\nComments or uncomments the selected lines based on the current language.\nAs long as any part of a line is selected, the entire line is eligible for\ncommenting/uncommenting.\n@see comment_string
bookmarks textadept.bookmarks (module)\nBookmarks for Textadept.
-brace_bad_light view.brace_bad_light(view, pos)\nHighlights the character at position *pos* as an unmatched brace character\nusing the `'style.bracebad'` style.\nRemoves highlighting when *pos* is `-1`.\n@param view A view.\n@param pos The position in *buffer* to highlight, or `-1` to remove the\n highlight.
+brace_bad_light view.brace_bad_light(view, pos)\nHighlights the character at position *pos* as an unmatched brace character\nusing the `'style.bracebad'` style.\nRemoves highlighting when *pos* is `-1`.\n@param view A view.\n@param pos The position in *view*'s buffer to highlight, or `-1` to remove\n the highlight.
brace_bad_light_indicator view.brace_bad_light_indicator(view, use_indicator, indicator)\nHighlights unmatched brace characters with indicator number *indicator*, in\nthe range of `1 to `32`, instead of the\n`view.STYLE_BRACEBAD` style if *use_indicator* is `true`.\n@param view A view.\n@param use_indicator Whether or not to use an indicator.\n@param indicator The indicator number to use.
-brace_highlight view.brace_highlight(view, pos1, pos2)\nHighlights the characters at positions *pos1* and *pos2* as matching braces\nusing the `'style.bracelight'` style.\nIf indent guides are enabled, locates the column with `buffer.column` and\nsets `view.highlight_guide` in order to highlight the indent guide.\n@param view A view.\n@param pos1 The first position in *buffer* to highlight.\n@param pos2 The second position in *buffer* to highlight.
+brace_highlight view.brace_highlight(view, pos1, pos2)\nHighlights the characters at positions *pos1* and *pos2* as matching braces\nusing the `'style.bracelight'` style.\nIf indent guides are enabled, locates the column with `buffer.column` and\nsets `view.highlight_guide` in order to highlight the indent guide.\n@param view A view.\n@param pos1 The first position in *view*'s buffer to highlight.\n@param pos2 The second position in *view*'s buffer to highlight.
brace_highlight_indicator view.brace_highlight_indicator(view, use_indicator, indicator)\nHighlights matching brace characters with indicator number *indicator*, in\nthe range of `1` to `32`, instead of the\n`view.STYLE_BRACELIGHT` style if *use_indicator* is `true`.\n@param view A view.\n@param use_indicator Whether or not to use an indicator.\n@param indicator The indicator number to use.
brace_match buffer.brace_match(buffer, pos, max_re_style)\nReturns the position of the matching brace for the brace character at\nposition *pos*, taking nested braces into account, or `-1`.\nThe brace characters recognized are '(', ')', '[', ']', '{', '}', '<', and\n'>' and must have the same style.\n@param buffer A buffer.\n@param pos The position of the brace in *buffer* to match.\n@param max_re_style Must be `0`. Reserved for expansion.\n@return number
brace_matches textadept.editing.brace_matches (table)\nTable of brace characters to highlight.\nThe ASCII values of brace characters are keys and are assigned non-`nil`\nvalues. The default brace characters are '(', ')', '[', ']', '{', and '}'.
@@ -499,7 +499,7 @@ constants _SCINTILLA.constants (table)\nMap of Scintilla constant names to their
context_menu textadept.menu.context_menu (table)\nThe default right-click context menu.\nSubmenus, and menu items can be retrieved by name in addition to table index\nnumber.
context_menu ui.context_menu (userdata)\nThe buffer's context menu, a `ui.menu()`.\nThis is a low-level field. You probably want to use the higher-level\n`textadept.menu.context_menu`.
continue debugger.continue(lexer, ...)\nContinue debugger execution unless the debugger is already executing (e.g.\nnot at a breakpoint).\nIf no debugger is running, starts one, then continues execution.\nEmits a `DEBUGGER_CONTINUE` event, passing along any arguments given.\n@param lexer Optional lexer name of the language to continue executing. The\n default value is the current lexer.
-contracted_fold_next view.contracted_fold_next(view, line)\nReturns the line number of the next contracted fold point starting from line\nnumber *line*, or `-1` if none exists.\n@param view A view.\n@param line The line number in *buffer* to start at.\n@return number
+contracted_fold_next view.contracted_fold_next(view, line)\nReturns the line number of the next contracted fold point starting from line\nnumber *line*, or `-1` if none exists.\n@param view A view.\n@param line The line number in *view* to start at.\n@return number
control_structure_patterns _M.ruby.control_structure_patterns (table)\nPatterns for auto `end` completion for control structures.\n@see try_to_autocomplete_end
convert_eols buffer.convert_eols(buffer, mode)\nConverts all end of line characters to those in end of line mode *mode*.\n@param buffer A buffer.\n@param mode The end of line mode to convert to. Valid values are:\n * `buffer.EOL_CRLF`\n * `buffer.EOL_CR`\n * `buffer.EOL_LF`
convert_indentation textadept.editing.convert_indentation()\nConverts indentation between tabs and spaces according to `buffer.use_tabs`.\nIf `buffer.use_tabs` is `true`, `buffer.tab_width` indenting spaces are\nconverted to tabs. Otherwise, all indenting tabs are converted to\n`buffer.tab_width` spaces.\n@see buffer.use_tabs
@@ -522,7 +522,7 @@ cycle_history_next lua_repl.cycle_history_next()\nCycle forward through command
cycle_history_prev lua_repl.cycle_history_prev()\nCycle backward through command history, taking into account commands with\nmultiple lines.
debugger _G.debugger (module)\n[Experimental]\nLanguage debugging support.\n\nAll this module does is emit debugger events. Submodules that implement\ndebuggers listen for these events and act on them.\n\nThis module is not loaded by default. `require('debugger')` must be called\nfrom *~/.textadept/init.lua*.
dec_num lexer.dec_num (pattern)\nA pattern that matches a decimal number.
-default_filter lfs.default_filter (table)\nThe filter table containing common binary file extensions and version control\ndirectories to exclude when iterating over files and directories using\n`dir_foreach`.\n@see dir_foreach
+default_filter lfs.default_filter (table)\nThe filter table containing common binary file extensions and version control\ndirectories to exclude when iterating over files and directories using\n`walk`.\n@see walk
del_line_left buffer.del_line_left(buffer)\nDeletes the range of text from the caret to the beginning of the current\nline.\n@param buffer A buffer.
del_line_right buffer.del_line_right(buffer)\nDeletes the range of text from the caret to the end of the current line.\n@param buffer A buffer.
del_word_left buffer.del_word_left(buffer)\nDeletes the word to the left of the caret, including any leading non-word\ncharacters.\n`buffer.word_chars` contains the set of characters that constitute words.\n@param buffer A buffer.
@@ -536,7 +536,6 @@ dialog ui.dialog(kind, ...)\nLow-level function for prompting the user with a gt
dialogs ui.dialogs (module)\nProvides a set of interactive dialog prompts for user input.
diff _G.diff(text1, text2)\nReturns a list that represents the differences between strings *text1* and\n*text2*.\nEach consecutive pair of elements in the returned list represents a "diff".\nThe first element is an integer: 0 for a deletion, 1 for an insertion, and 2\nfor equality. The second element is the associated diff text.\n@param text1 String to compare against.\n@param text2 String to compare.\n@usage diffs = diff(text1, text2)\n for i = 1, #diffs, 2 do print(diffs[i], diffs[i + 1]) end\n@return list of differences
digit lexer.digit (pattern)\nA pattern that matches any digit ('0'-'9').
-dir_foreach lfs.dir_foreach(dir, f, filter, n, include_dirs, level)\nIterates over all files and sub-directories (up to *n* levels deep) in\ndirectory *dir*, calling function *f* with each file found.\nString or list *filter* determines which files to pass through to *f*, with\nthe default filter being `lfs.default_filter`. A filter consists of Lua\npatterns that match file and directory paths to include or exclude. Exclusive\npatterns begin with a '!'. If no inclusive patterns are given, any path is\ninitially considered. As a convenience, file extensions can be specified\nliterally instead of as a Lua pattern (e.g. '.lua' vs. '%.lua$'), and '/'\nalso matches the Windows directory separator ('[/\\]' is not needed).\n@param dir The directory path to iterate over.\n@param f Function to call with each full file path found. If *f* returns\n `false` explicitly, iteration ceases.\n@param filter Optional filter for files and directories to include and\n exclude. The default value is `lfs.default_filter`.\n@param n Optional maximum number of directory levels to descend into.\n The default value is `nil`, which indicates no limit.\n@param include_dirs Optional flag indicating whether or not to call *f* with\n directory names too. Directory names are passed with a trailing '/' or '\',\n depending on the current platform.\n The default value is `false`.\n@param level Utility value indicating the directory level this function is\n at. This value is used and set internally, and should not be set otherwise.\n@see filter
disable_listening history.disable_listening()\nDisables recording of edit locations and clears all view history.
disconnect events.disconnect(event, f)\nRemoves function *f* from the set of handlers for event *event*.\n@param event The string event name.\n@param f The Lua function connected to *event*.\n@see connect
doc_line_from_visible view.doc_line_from_visible(view, display_line)\nReturns the actual line number of displayed line number *display_line*,\ntaking hidden lines into account.\nIf *display_line* is less than or equal to `1`, returns `1`. If\n*display_line* is greater than the number of displayed lines, returns\n`buffer.line_count`.\n@param view A view.\n@param display_line The display line number to use.\n@return number
@@ -562,8 +561,8 @@ encodings io.encodings (table)\nList of encodings to attempt to decode files as.
end_at_last_line view.end_at_last_line (bool)\nDisable scrolling past the last line.\nThe default value is `true`.
end_styled buffer.end_styled (number, Read-only)\nThe current styling position or the last correctly styled character's\nposition.
end_undo_action buffer.end_undo_action(buffer)\nEnds a sequence of actions to be undone or redone as a single action.\n@param buffer A buffer.
-ensure_visible view.ensure_visible(view, line)\nEnsures line number *line* is visible by expanding any fold points hiding it.\n@param view A view.\n@param line The line number in *buffer* to ensure visible.
-ensure_visible_enforce_policy view.ensure_visible_enforce_policy(view, line)\nEnsures line number *line* is visible by expanding any fold points hiding it\nbased on the vertical caret policy previously defined in\n`view.set_visible_policy()`.\n@param view A view.\n@param line The line number in *buffer* to ensure visible.
+ensure_visible view.ensure_visible(view, line)\nEnsures line number *line* is visible by expanding any fold points hiding it.\n@param view A view.\n@param line The line number in *view* to ensure visible.
+ensure_visible_enforce_policy view.ensure_visible_enforce_policy(view, line)\nEnsures line number *line* is visible by expanding any fold points hiding it\nbased on the vertical caret policy previously defined in\n`view.set_visible_policy()`.\n@param view A view.\n@param line The line number in *view* to ensure visible.
eol_mode buffer.eol_mode (number)\nThe current end of line mode. Changing the current mode does not convert\nany of the buffer's existing end of line characters.\nUse `buffer.convert_eols()` to do so.\n\n* `buffer.EOL_CRLF`\n Carriage return with line feed ("\r\\n").\n* `buffer.EOL_CR`\n Carriage return ("\r").\n* `buffer.EOL_LF`\n Line feed ("\\n").\n\nThe default value is `buffer.EOL_CRLF` on Windows platforms,\n`buffer.EOL_LF` otherwise.
error_patterns textadept.run.error_patterns (table)\nMap of file extensions and lexer names to their associated lists of string\npatterns that match warning and error messages emitted by compile and run\ncommands for those file extensions and lexers.\nPatterns match single lines and contain captures for a filename, line number,\ncolumn number (optional), and warning or error message (optional).\nDouble-clicking a warning or error message takes the user to the source of\nthat warning/error.\nNote: `(.-)` captures in patterns are interpreted as filenames; `(%d+)`\ncaptures are interpreted as line numbers first, and then column numbers; and\nany other capture is treated as warning/error message text.
evaluate_repl lua_repl.evaluate_repl()\nEvaluates as Lua code the current line or the text on the currently selected\nlines.\nIf the current line has a syntax error, it is ignored and treated as a line\ncontinuation.
@@ -603,13 +602,13 @@ focus ui.command_entry.focus()\nOpens the command entry.
focus ui.find.focus()\nDisplays and focuses the Find & Replace Pane.
fold lexer.fold(lexer, text, start_pos, start_line, start_level)\nDetermines fold points in a chunk of text *text* using lexer *lexer*,\nreturning a table of fold levels associated with line numbers.\n*text* starts at position *start_pos* on line number *start_line* with a\nbeginning fold level of *start_level* in the buffer.\n@param lexer The lexer to fold text with.\n@param text The text in the buffer to fold.\n@param start_pos The position in the buffer *text* starts at, counting from\n 1.\n@param start_line The line number *text* starts on, counting from 1.\n@param start_level The fold level *text* starts on.\n@return table of fold levels associated with line numbers.
fold_all view.fold_all(view, action)\nContracts, expands, or toggles all fold points, depending on *action*.\nWhen toggling, the state of the first fold point determines whether to\nexpand or contract.\n@param view A view.\n@param action The fold action to perform. Valid values are:\n * `view.FOLDACTION_CONTRACT`\n * `view.FOLDACTION_EXPAND`\n * `view.FOLDACTION_TOGGLE`
-fold_children view.fold_children(view, line, action)\nContracts, expands, or toggles the fold point on line number *line*, as well\nas all of its children, depending on *action*.\n@param view A view.\n@param line The line number in *buffer* to set the fold states for.\n@param action The fold action to perform. Valid values are:\n * `view.FOLDACTION_CONTRACT`\n * `view.FOLDACTION_EXPAND`\n * `view.FOLDACTION_TOGGLE`
+fold_children view.fold_children(view, line, action)\nContracts, expands, or toggles the fold point on line number *line*, as well\nas all of its children, depending on *action*.\n@param view A view.\n@param line The line number in *view* to set the fold states for.\n@param action The fold action to perform. Valid values are:\n * `view.FOLDACTION_CONTRACT`\n * `view.FOLDACTION_EXPAND`\n * `view.FOLDACTION_TOGGLE`
fold_display_text_style view.fold_display_text_style (number)\nThe fold display text mode.\n\n* `view.FOLDDISPLAYTEXT_HIDDEN`\n Fold display text is not shown.\n* `view.FOLDDISPLAYTEXT_STANDARD`\n Fold display text is shown with no decoration.\n* `view.FOLDDISPLAYTEXT_BOXED`\n Fold display text is shown outlined with a box.\n\nThe default value is `view.FOLDDISPLAYTEXT_HIDDEN`.
fold_expanded view.fold_expanded (table)\nTable of flags per line number that indicate whether or not fold points are\nexpanded for those line numbers.\nSetting expanded fold states does not toggle folds; it only updates fold\nmargin markers. Use `view.toggle_fold()` instead.
fold_flags view.fold_flags (number, Read-only)\nBit-mask of folding lines to draw in the buffer.\n\n* `view.FOLDFLAG_LINEBEFORE_EXPANDED`\n Draw lines above expanded folds.\n* `view.FOLDFLAG_LINEBEFORE_CONTRACTED`\n Draw lines above collapsed folds.\n* `view.FOLDFLAG_LINEAFTER_EXPANDED`\n Draw lines below expanded folds.\n* `view.FOLDFLAG_LINEAFTER_CONTRACTED`\n Draw lines below collapsed folds.\n* `view.FOLDFLAG_LEVELNUMBERS`\n Show hexadecimal fold levels in line margins.\n This option cannot be combined with `FOLDFLAG_LINESTATE`.\n* `view.FOLDFLAG_LINESTATE`\n Show line state in line margins.\n This option cannot be combined with `FOLDFLAG_LEVELNUMBERS`.\n\nThe default value is `0`.
fold_level buffer.fold_level (table)\nTable of fold level bit-masks per line number.\nFold level masks comprise of an integer level combined with any of the\nfollowing bit flags:\n\n* `buffer.FOLDLEVELBASE`\n The initial fold level.\n* `buffer.FOLDLEVELWHITEFLAG`\n The line is blank.\n* `buffer.FOLDLEVELHEADERFLAG`\n The line is a header, or fold point.
fold_level lexer.fold_level (table, Read-only)\nTable of fold level bit-masks for line numbers starting from 1.\nFold level masks are composed of an integer level combined with any of the\nfollowing bits:\n\n* `lexer.FOLD_BASE`\n The initial fold level.\n* `lexer.FOLD_BLANK`\n The line is blank.\n* `lexer.FOLD_HEADER`\n The line is a header, or fold point.
-fold_line view.fold_line(view, line, action)\nContracts, expands, or toggles the fold point on line number *line*,\ndepending on *action*.\n@param view A view.\n@param line The line number in *buffer* to set the fold state for.\n@param action The fold action to perform. Valid values are:\n * `view.FOLDACTION_CONTRACT`\n * `view.FOLDACTION_EXPAND`\n * `view.FOLDACTION_TOGGLE`
+fold_line view.fold_line(view, line, action)\nContracts, expands, or toggles the fold point on line number *line*,\ndepending on *action*.\n@param view A view.\n@param line The line number in *view* to set the fold state for.\n@param action The fold action to perform. Valid values are:\n * `view.FOLDACTION_CONTRACT`\n * `view.FOLDACTION_EXPAND`\n * `view.FOLDACTION_TOGGLE`
fold_line_comments lexer.fold_line_comments(prefix)\nReturns a fold function (to be passed to `lexer.add_fold_point()`) that folds\nconsecutive line comments that start with string *prefix*.\n@param prefix The prefix string defining a line comment.\n@usage lex:add_fold_point(lexer.COMMENT, '--',\n lexer.fold_line_comments('--'))\n@usage lex:add_fold_point(lexer.COMMENT, '//',\n lexer.fold_line_comments('//'))
fold_parent buffer.fold_parent (table, Read-only)\nTable of fold point line numbers per child line number.\nA line number of `-1` means no line was found.
fontselect ui.dialogs.fontselect(options)\nPrompts the user with a font selection dialog defined by dialog options\ntable *options*, returning the font selected (including style and size).\nIf the user canceled the dialog, returns `nil`.\n@param options Table of key-value option pairs for the option select dialog.\n\n * `title`: The dialog's title text.\n * `text`: The font preview text.\n * `font_name`: The initially selected font name.\n * `font_size`: The initially selected font size. The default value is `12`.\n * `font_style`: The initially selected font style. The available options\n are `"regular"`, `"bold"`, `"italic"`, and `"bold italic"`. The default\n value is `"regular"`.\n * `float`: Show the dialog on top of all desktop windows. The default value\n is `false`.\n@usage ui.dialogs.fontselect{title = 'Font', font_name = 'Monospace',\n font_size = 10}\n@return selected font, including style and size
@@ -651,7 +650,7 @@ handle_notification Server:handle_notification(method, params)\nHandles an unsol
handle_stdout Server:handle_stdout(output)\nProcesses unsolicited, incoming stdout from the Language Server, primarily to\nlook for notifications and act on them.\n@param output String stdout from the Language Server.
height ui.command_entry.height (number)\nThe height in pixels of the command entry.
hex_num lexer.hex_num (pattern)\nA pattern that matches a hexadecimal number.
-hide_lines view.hide_lines(view, start_line, end_line)\nHides the range of lines between line numbers *start_line* to *end_line*.\nThis has no effect on fold levels or fold flags and the first line cannot be\nhidden.\n@param view A view.\n@param start_line The start line of the range of lines in *buffer* to hide.\n@param end_line The end line of the range of lines in *buffer* to hide.
+hide_lines view.hide_lines(view, start_line, end_line)\nHides the range of lines between line numbers *start_line* to *end_line*.\nThis has no effect on fold levels or fold flags and the first line cannot be\nhidden.\n@param view A view.\n@param start_line The start line of the range of lines in *view* to hide.\n@param end_line The end line of the range of lines in *view* to hide.
highlight_guide view.highlight_guide (number)\nThe indentation guide column number to also highlight when highlighting\nmatching braces, or `0` to stop indentation guide highlighting.
highlight_word textadept.editing.highlight_word()\nHighlights all occurrences of the selected text or all occurrences of the\ncurrent word.\n@see buffer.word_chars
history _G.history (module)\n[Experimental]\nRecords buffer positions within Textadept views over time and allows for\nnavigating through that history.\n\nThis module is not loaded by default. `require('history')` must be called\nfrom *~/.textadept/init.lua*.\n\nBy default, this module listens for text edit events, and each time an\ninsertion or deletion occurs, its location is appended to the current view's\nlocation history. If the edit is close enough to the previous record, the\nprevious record is amended.
@@ -1003,7 +1002,7 @@ set_x_caret_policy view.set_x_caret_policy(view, policy, x)\nDefines scrolling p
set_y_caret_policy view.set_y_caret_policy(view, policy, y)\nDefines scrolling policy bit-mask *policy* as the policy for keeping the\ncaret *y* number of lines away from the vertical margins.\n@param view A view.\n@param policy The combination of `view.CARET_SLOP`, `view.CARET_STRICT`,\n `view.CARET_EVEN`, and `view.CARET_JUMPS` policy flags to set.\n@param y The number of lines from the vertical margins to keep the caret.
show_all_diagnostics lsp.show_all_diagnostics (bool)\nWhether or not to show all diagnostics.\nThe default value is `false`, and assumes any diagnostics on the current\nline or next line are due to an incomplete statement during something like\nan autocompletion, signature help, etc. request.
show_documentation textadept.editing.show_documentation(pos, case_insensitive)\nDisplays a call tip with documentation for the symbol under or directly\nbehind position *pos* or the caret position.\nDocumentation is read from API files in the `api_files` table.\nIf a call tip is already shown, cycles to the next one if it exists.\nSymbols are determined by using `buffer.word_chars`.\n@param pos Optional position of the symbol to show documentation for. If\n omitted, the caret position is used.\n@param case_insensitive Optional flag that indicates whether or not to search\n API files case-insensitively for symbols. The default value is `false`.\n@see api_files\n@see buffer.word_chars
-show_lines view.show_lines(view, start_line, end_line)\nShows the range of lines between line numbers *start_line* to *end_line*.\nThis has no effect on fold levels or fold flags and the first line cannot be\nhidden.\n@param view A view.\n@param start_line The start line of the range of lines in *buffer* to show.\n@param end_line The end line of the range of lines in *buffer* to show.
+show_lines view.show_lines(view, start_line, end_line)\nShows the range of lines between line numbers *start_line* to *end_line*.\nThis has no effect on fold levels or fold flags and the first line cannot be\nhidden.\n@param view A view.\n@param start_line The start line of the range of lines in *view* to show.\n@param end_line The end line of the range of lines in *view* to show.
signature_help lsp.signature_help()\nShows a calltip for the current function.\nIf a call tip is already shown, cycles to the next one if it exists.
silent_print ui.silent_print (bool)\nWhether or not to print messages to buffers silently.\nThis is not guaranteed to be a constant value, as Textadept may change it\nfor the editor's own purposes. This flag should be used only in conjunction\nwith a group of `ui.print()` and `ui._print()` function calls.\nThe default value is `false`, and focuses buffers when messages are printed\nto them.
size ui.size (table)\nA table containing the width and height pixel values of Textadept's window.
@@ -1079,7 +1078,7 @@ target_start buffer.target_start (number)\nThe position of the beginning of the
target_start_virtual_space buffer.target_start_virtual_space (number)\nThe position of the beginning of virtual space in the target range.\nThis is set to `1` when `buffer.target_start` or\n`buffer.target_end` is set, or when `buffer.set_target_range()` is\ncalled.
target_text buffer.target_text (string, Read-only)\nThe text in the target range.
target_whole_document buffer.target_whole_document(buffer)\nDefines the target range's beginning and end positions as the beginning and\nend positions of the document, respectively.\n@param buffer A buffer.
-text_height view.text_height(view, line)\nReturns the pixel height of line number *line*.\n@param view A view.\n@param line The line number in *buffer* to get the pixel height of.\n@return number
+text_height view.text_height(view, line)\nReturns the pixel height of line number *line*.\n@param view A view.\n@param line The line number in *view* to get the pixel height of.\n@return number
text_length buffer.text_length (number, Read-only)\nThe number of bytes in the buffer.
text_range buffer.text_range(buffer, start_pos, end_pos)\nReturns the range of text between positions *start_pos* and *end_pos*.\n@param buffer A buffer.\n@param start_pos The start position of the range of text to get in *buffer*.\n@param end_pos The end position of the range of text to get in *buffer*.
text_width view.text_width(view, style_num, text)\nReturns the pixel width string *text* would have when styled with style\nnumber *style_num*, in the range of `1` to `256`.\n@param view A view.\n@param style_num The style number between `1` and `256` to use.\n@param text The text to measure the width of.\n@return number
@@ -1094,8 +1093,8 @@ toggle textadept.bookmarks.toggle()\nToggles a bookmark on the current line.
toggle_block _M.ruby.toggle_block()\nToggles between `{ ... }` and `do ... end` Ruby blocks.\nIf the caret is inside a `{ ... }` single-line block, that block is converted\nto a multiple-line `do .. end` block. If the caret is on a line that contains\nsingle-line `do ... end` block, that block is converted to a single-line\n`{ ... }` block. If the caret is inside a multiple-line `do ... end` block,\nthat block is converted to a single-line `{ ... }` block with all newlines\nreplaced by a space. Indentation is important. The `do` and `end` keywords\nmust be on lines with the same level of indentation to toggle correctly.
toggle_breakpoint debugger.toggle_breakpoint(file, line)\nToggles a breakpoint on line number *line* in file *file*, or the current\nline in the current file.\nMay emit `DEBUGGER_BREAKPOINT_ADDED` and `DEBUGGER_BREAKPOINT_REMOVED` events\ndepending on circumstance.\nMay show an error message if the debugger is executing (e.g. not at a\nbreakpoint).\n@param file Optional filename of the breakpoint to toggle.\n@param line Optional 1-based line number of the breakpoint to toggle.\n@see remove_breakpoint
toggle_caret_sticky buffer.toggle_caret_sticky(buffer)\nCycles between `buffer.caret_sticky` option settings `buffer.CARETSTICKY_ON`\nand `buffer.CARETSTICKY_OFF`.\n@param buffer A buffer.\n@see caret_sticky
-toggle_fold view.toggle_fold(view, line)\nToggles the fold point on line number *line* between expanded (where all of\nits child lines are displayed) and contracted (where all of its child lines\nare hidden).\n@param view A view.\n@param line The line number in *buffer* to toggle the fold on.\n@see set_default_fold_display_text
-toggle_fold_show_text view.toggle_fold_show_text(view, line, text)\nToggles a fold point on line number *line* between expanded (where all of\nits child lines are displayed) and contracted (where all of its child lines\nare hidden), and shows string *text* after the line.\n*text* is drawn with style number `view.STYLE_FOLDDISPLAYTEXT`.\n@param view A view.\n@param line The line number in *buffer* to toggle the fold on and display\n *text* after.\n@param text The text to display after the line.
+toggle_fold view.toggle_fold(view, line)\nToggles the fold point on line number *line* between expanded (where all of\nits child lines are displayed) and contracted (where all of its child lines\nare hidden).\n@param view A view.\n@param line The line number in *view* to toggle the fold on.\n@see set_default_fold_display_text
+toggle_fold_show_text view.toggle_fold_show_text(view, line, text)\nToggles a fold point on line number *line* between expanded (where all of\nits child lines are displayed) and contracted (where all of its child lines\nare hidden), and shows string *text* after the line.\n*text* is drawn with style number `view.STYLE_FOLDDISPLAYTEXT`.\n@param view A view.\n@param line The line number in *view* to toggle the fold on and display\n *text* after.\n@param text The text to display after the line.
token lexer.token(name, patt)\nCreates and returns a token pattern with token name *name* and pattern\n*patt*.\nIf *name* is not a predefined token name, its style must be defined via\n`lexer.add_style()`.\n@param name The name of token. If this name is not a predefined token name,\n then a style needs to be assiciated with it via `lexer.add_style()`.\n@param patt The LPeg pattern associated with the token.\n@usage local ws = token(lexer.WHITESPACE, lexer.space^1)\n@usage local annotation = token('annotation', '@' * lexer.word)\n@return pattern
transpose_chars textadept.editing.transpose_chars()\nTransposes characters intelligently.\nIf the caret is at the end of a line, transposes the two characters before\nthe caret. Otherwise, the characters to the left and right are.
try_to_autocomplete_end _M.ruby.try_to_autocomplete_end()\nTries to autocomplete Ruby's `end` keyword for control structures like `if`,\n`while`, `for`, etc.\n@see control_structure_patterns
@@ -1123,8 +1122,9 @@ view _G.view (table)\nThe current view.
view_eol view.view_eol (bool)\nDisplay end of line characters.\nThe default value is `false`.
view_ws view.view_ws (number)\nThe whitespace visibility mode.\n\n* `view.WS_INVISIBLE`\n Whitespace is invisible.\n* `view.WS_VISIBLEALWAYS`\n Display all space characters as dots and tab characters as arrows.\n* `view.WS_VISIBLEAFTERINDENT`\n Display only non-indentation spaces and tabs as dots and arrows.\n* `view.WS_VISIBLEONLYININDENT`\n Display only indentation spaces and tabs as dots and arrows.\n\nThe default value is `view.WS_INVISIBLE`.
virtual_space_options buffer.virtual_space_options (number)\nThe virtual space mode.\n\n* `buffer.VS_NONE`\n Disable virtual space.\n* `buffer.VS_RECTANGULARSELECTION`\n Enable virtual space only for rectangular selections.\n* `buffer.VS_USERACCESSIBLE`\n Enable virtual space.\n* `buffer.VS_NOWRAPLINESTART`\n Prevent the caret from wrapping to the previous line via\n `buffer:char_left()` and `buffer:char_left_extend()`. This option is not\n restricted to virtual space and should be added to any of the above\n options.\n\nWhen virtual space is enabled, the caret may move into the space past end\nof line characters.\nThe default value is `buffer.VS_NONE`.
-visible_from_doc_line view.visible_from_doc_line(view, line)\nReturns the displayed line number of actual line number *line*, taking hidden\nlines into account, or `-1` if *line* is outside the range of lines in the\nbuffer.\nLines can occupy more than one display line if they wrap.\n@param view A view.\n@param line The line number in *buffer* to use.\n@return number
+visible_from_doc_line view.visible_from_doc_line(view, line)\nReturns the displayed line number of actual line number *line*, taking hidden\nlines into account, or `-1` if *line* is outside the range of lines in the\nbuffer.\nLines can occupy more than one display line if they wrap.\n@param view A view.\n@param line The line number in *view* to use.\n@return number
wait spawn_proc:wait()\nBlocks until process *spawn_proc* finishes (if it has not already done so)\nand returns its status code.\n@return integer status code
+walk lfs.walk(dir, filter, n, include_dirs)\nReturns an iterator that iterates over all files and sub-directories (up to\n*n* levels deep) in directory *dir* and yields each file found.\nString or list *filter* determines which files to yield, with the default\nfilter being `lfs.default_filter`. A filter consists of Lua patterns that\nmatch file and directory paths to include or exclude. Exclusive patterns\nbegin with a '!'. If no inclusive patterns are given, any path is initially\nconsidered. As a convenience, file extensions can be specified literally\ninstead of as a Lua pattern (e.g. '.lua' vs. '%.lua$'), and '/' also matches\nthe Windows directory separator ('[/\\]' is not needed).\n@param dir The directory path to iterate over.\n@param filter Optional filter for files and directories to include and\n exclude. The default value is `lfs.default_filter`.\n@param n Optional maximum number of directory levels to descend into.\n The default value is `nil`, which indicates no limit.\n@param include_dirs Optional flag indicating whether or not to yield\n directory names too. Directory names are passed with a trailing '/' or '\',\n depending on the current platform.\n The default value is `false`.\n@see filter
whitespace_chars buffer.whitespace_chars (string)\nThe string set of characters recognized as whitespace characters.\nSet this only after setting `buffer.word_chars`.\nThe default value is a string that contains all non-newline characters less\nthan ASCII value 33.
whitespace_size view.whitespace_size (number)\nThe pixel size of the dots that represent space characters when whitespace\nis visible.\nThe default value is `1`.
whole_word ui.find.whole_word (bool)\nMatch search text only when it is surrounded by non-word characters in\nsearches.\nThe default value is `false`.
@@ -1146,7 +1146,7 @@ word_right_end buffer.word_right_end(buffer)\nMoves the caret right one word, po
word_right_end_extend buffer.word_right_end_extend(buffer)\nLike `buffer.word_right_end()`, but extends the selected text to the new\nposition.\n@param buffer A buffer.
word_right_extend buffer.word_right_extend(buffer)\nMoves the caret right one word, extending the selected text to the new\nposition.\n`buffer.word_chars` contains the set of characters that constitute words.\n@param buffer A buffer.
word_start_position buffer.word_start_position(buffer, pos, only_word_chars)\nReturns the position of the beginning of the word at position *pos*.\n`buffer.word_chars` contains the set of characters that constitute words. If\n*pos* has a non-word character to its left and *only_word_chars* is `false`,\nreturns the last word character's position.\n@param buffer A buffer.\n@param pos The position in *buffer* of the word.\n@param only_word_chars If `true`, stops searching at the first non-word\n character in the search direction. Otherwise, the first character in the\n search direction sets the type of the search as word or non-word and the\n search stops at the first non-matching character. Searches are also\n terminated by the start or end of the buffer.
-wrap_count view.wrap_count(view, line)\nReturns the number of wrapped lines needed to fully display line number\n*line*.\n@param view A view.\n@param line The line number in *buffer* to use.\n@return number
+wrap_count view.wrap_count(view, line)\nReturns the number of wrapped lines needed to fully display line number\n*line*.\n@param view A view.\n@param line The line number in *view* to use.\n@return number
wrap_indent_mode view.wrap_indent_mode (number)\nThe wrapped line indent mode.\n\n* `view.WRAPINDENT_FIXED`\n Indent wrapped lines by `view.wrap_start_indent`.\n* `view.WRAPINDENT_SAME`\n Indent wrapped lines the same amount as the first line.\n* `view.WRAPINDENT_INDENT`\n Indent wrapped lines one more level than the level of the first line.\n* `view.WRAPINDENT_DEEPINDENT`\n Indent wrapped lines two more levels than the level of the first line.\n\nThe default value is `view.WRAPINDENT_FIXED`.
wrap_mode view.wrap_mode (number)\nLong line wrap mode.\n\n* `view.WRAP_NONE`\n Long lines are not wrapped.\n* `view.WRAP_WORD`\n Wrap long lines at word (and style) boundaries.\n* `view.WRAP_CHAR`\n Wrap long lines at character boundaries.\n* `view.WRAP_WHITESPACE`\n Wrap long lines at word boundaries (ignoring style boundaries).\n\nThe default value is `view.WRAP_NONE`.
wrap_start_indent view.wrap_start_indent (number)\nThe number of spaces of indentation to display wrapped lines with if\n`view.wrap_indent_mode` is `view.WRAPINDENT_FIXED`.\nThe default value is `0`.
diff --git a/modules/lua/ta_tags b/modules/lua/ta_tags
index 85a63c22..235db41f 100644
--- a/modules/lua/ta_tags
+++ b/modules/lua/ta_tags
@@ -546,7 +546,6 @@ dialog _HOME/core/ui.lua /^local dialog$/;" f class:ui
dialogs _HOME/core/.ui.dialogs.luadoc /^module('ui.dialogs')$/;" m class:ui
diff _HOME/modules/file_diff/init.lua /^function _G.diff(text1, text2) end$/;" f
digit _HOME/lexers/lexer.lua /^module('lexer')]=]$/;" F class:lexer
-dir_foreach _HOME/core/lfs_ext.lua /^function lfs.dir_foreach(dir, f, filter, n, include_dirs, level)$/;" f class:lfs
disable_listening _HOME/modules/history/init.lua /^function M.disable_listening()$/;" f class:history
disconnect _HOME/core/events.lua /^function M.disconnect(event, f)$/;" f class:events
doc_line_from_visible _HOME/core/.view.luadoc /^function doc_line_from_visible(view, display_line) end$/;" f class:view
@@ -1148,6 +1147,7 @@ view_ws _HOME/core/.view.luadoc /^module('view')$/;" F class:view
virtual_space_options _HOME/core/.buffer.luadoc /^module('buffer')$/;" F class:buffer
visible_from_doc_line _HOME/core/.view.luadoc /^function visible_from_doc_line(view, line) end$/;" f class:view
wait _HOME/core/.os.luadoc /^function spawn_proc:wait() end$/;" f class:spawn_proc
+walk _HOME/core/lfs_ext.lua /^function lfs.walk(dir, filter, n, include_dirs)$/;" f class:lfs
whitespace_chars _HOME/core/.buffer.luadoc /^module('buffer')$/;" F class:buffer
whitespace_size _HOME/core/.view.luadoc /^module('view')$/;" F class:view
whole_word _HOME/modules/textadept/find.lua /^module('ui.find')]]$/;" F class:ui.find
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index e98b1403..e04bf786 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -255,6 +255,9 @@ function M.find_in_files(dir, filter)
}
if not dir then return end
end
+ if not assert_type(filter, 'string/table/nil', 2) then
+ filter = M.find_in_files_filters[dir] or lfs.default_filter
+ end
if buffer._type ~= _L['[Files Found Buffer]'] then preferred_view = view end
ui.silent_print = false
@@ -265,10 +268,10 @@ function M.find_in_files(dir, filter)
-- Determine which files to search.
local filenames, utf8_filenames = {}, {}
- lfs.dir_foreach(dir, function(filename)
+ for filename in lfs.walk(dir, filter) do
filenames[#filenames + 1] = filename
utf8_filenames[#utf8_filenames + 1] = filename:iconv('UTF-8', _CHARSET)
- end, filter or M.find_in_files_filters[dir] or lfs.default_filter)
+ end
-- Perform the search in a temporary buffer and print results.
local orig_buffer, buffer = buffer, buffer.new()
diff --git a/test/test.lua b/test/test.lua
index 2874c415..d2ed74ed 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -223,11 +223,11 @@ local LOCALE_DIR = _HOME .. '/core/locales'
function test_locale_load()
local L = load_locale(LOCALE_CONF)
- lfs.dir_foreach(LOCALE_DIR, function(locale_conf)
+ for locale_conf in lfs.walk(LOCALE_DIR) do
local l = load_locale(locale_conf)
for id in pairs(L) do assert(l[id], 'locale missing id "%s"', id) end
for id in pairs(l) do assert(L[id], 'locale has extra id "%s"', id) end
- end)
+ end
end
function test_locale_use_core()
@@ -235,30 +235,35 @@ function test_locale_use_core()
local ta_dirs = {'core', 'modules/ansi_c', 'modules/lua', 'modules/textadept'}
for _, dir in ipairs(ta_dirs) do
dir = _HOME .. '/' .. dir
- lfs.dir_foreach(
- dir, function(filename) check_localizations(filename, L) end, '.lua')
+ for filename in lfs.walk(dir, '.lua') do
+ check_localizations(filename, L)
+ end
end
check_localizations(_HOME .. '/init.lua', L)
end
function test_locale_use_extra()
local L = load_locale(LOCALE_CONF)
- lfs.dir_foreach(
- _HOME, function(filename) load_extra_localizations(filename, L) end, '.lua')
- lfs.dir_foreach(
- _HOME, function(filename) check_localizations(filename, L) end, '.lua')
+ for filename in lfs.walk(_HOME, '.lua') do
+ load_extra_localizations(filename, L)
+ end
+ for filename in lfs.walk(_HOME, '.lua') do
+ check_localizations(filename, L)
+ end
end
function test_locale_use_userhome()
local L = load_locale(LOCALE_CONF)
- lfs.dir_foreach(
- _HOME, function(filename) load_extra_localizations(filename, L) end, '.lua')
- lfs.dir_foreach(_USERHOME, function(filename)
+ for filename in lfs.walk(_HOME, '.lua') do
load_extra_localizations(filename, L)
- end, '.lua')
+ end
+ for filename in lfs.walk(_USERHOME, '.lua') do
+ load_extra_localizations(filename, L)
+ end
L['%1'] = true -- snippet
- lfs.dir_foreach(
- _USERHOME, function(filename) check_localizations(filename, L) end, '.lua')
+ for filename in lfs.walk(_USERHOME, '.lua') do
+ check_localizations(filename, L)
+ end
end
function test_file_io_open_file_detect_encoding()
@@ -622,97 +627,95 @@ function test_keys_modes()
buffer:close()
end
-function test_lfs_ext_dir_foreach()
+function test_lfs_ext_walk()
local files, directories = 0, 0
- lfs.dir_foreach(_HOME .. '/core', function(filename)
+ for filename in lfs.walk(_HOME .. '/core', nil, nil, true) do
if not filename:find('/$') then
files = files + 1
else
directories = directories + 1
end
- end, nil, nil, true)
+ end
assert(files > 0, 'no files found')
assert(directories > 0, 'no directories found')
- assert_raises(function() lfs.dir_foreach() end, 'string expected, got nil')
- assert_raises(function() lfs.dir_foreach(_HOME) end, 'function expected, got nil')
- assert_raises(function() lfs.dir_foreach(_HOME, function() end, 1) end, 'string/table/nil expected, got number')
- assert_raises(function() lfs.dir_foreach(_HOME, function() end, nil, true) end, 'number/nil expected, got boolean')
+ assert_raises(function() lfs.walk() end, 'string expected, got nil')
+ assert_raises(function() lfs.walk(_HOME, 1) end, 'string/table/nil expected, got number')
+ assert_raises(function() lfs.walk(_HOME, nil, true) end, 'number/nil expected, got boolean')
end
-function test_lfs_ext_dir_foreach_filter_lua()
+function test_lfs_ext_walk_filter_lua()
local count = 0
- lfs.dir_foreach(_HOME .. '/core', function(filename)
+ for filename in lfs.walk(_HOME .. '/core', '.lua') do
assert(filename:find('%.lua$'), '"%s" not a Lua file', filename)
count = count + 1
- end, '.lua')
+ end
assert(count > 0, 'no Lua files found')
end
-function test_lfs_ext_dir_foreach_filter_exclusive()
+function test_lfs_ext_walk_filter_exclusive()
local count = 0
- lfs.dir_foreach(_HOME .. '/core', function(filename)
+ for filename in lfs.walk(_HOME .. '/core', '!.lua') do
assert(not filename:find('%.lua$'), '"%s" is a Lua file', filename)
count = count + 1
- end, '!.lua')
+ end
assert(count > 0, 'no non-Lua files found')
end
-function test_lfs_ext_dir_foreach_filter_dir()
+function test_lfs_ext_walk_filter_dir()
local count = 0
- lfs.dir_foreach(_HOME, function(filename)
+ for filename in lfs.walk(_HOME, '/core') do
assert(filename:find('/core/'), '"%s" is not in core/', filename)
count = count + 1
- end, '/core')
+ end
assert(count > 0, 'no core files found')
end
-expected_failure(test_lfs_ext_dir_foreach_filter_dir)
+expected_failure(test_lfs_ext_walk_filter_dir)
-function test_lfs_ext_dir_foreach_filter_mixed()
+function test_lfs_ext_walk_filter_mixed()
local count = 0
- lfs.dir_foreach(_HOME .. '/core', function(filename)
+ for filename in lfs.walk(_HOME .. '/core', {'!/locales', '.lua'}) do
assert(not filename:find('/locales/') and filename:find('%.lua$'), '"%s" should not match', filename)
count = count + 1
- end, {'!/locales', '.lua'})
+ end
assert(count > 0, 'no matching files found')
end
-function test_lfs_ext_dir_foreach_max_depth()
+function test_lfs_ext_walk_max_depth()
local count = 0
- lfs.dir_foreach(
- _HOME, function(filename) count = count + 1 end, '.lua', 0)
+ for filename in lfs.walk(_HOME, '.lua', 0) do count = count + 1 end
assert_equal(count, 1) -- init.lua
end
-function test_lfs_ext_dir_foreach_halt()
+function test_lfs_ext_walk_halt()
local count, count_at_halt = 0, 0
- lfs.dir_foreach(_HOME .. '/core', function(filename)
+ for filename in lfs.walk(_HOME .. '/core') do
count = count + 1
if filename:find('/locales/.') then
count_at_halt = count
- return false
+ break
end
- end)
+ end
assert_equal(count, count_at_halt)
- lfs.dir_foreach(_HOME .. '/core', function(filename)
+ for filename in lfs.walk(_HOME .. '/core', nil, nil, true) do
count = count + 1
if filename:find('[/\\]$') then
count_at_halt = count
- return false
+ break
end
- end, nil, nil, true)
+ end
assert_equal(count, count_at_halt)
end
-function test_lfs_ext_dir_foreach_win32()
+function test_lfs_ext_walk_win32()
local win32 = _G.WIN32
_G.WIN32 = true
local count = 0
- lfs.dir_foreach(_HOME, function(filename)
+ for filename in lfs.walk(_HOME, {'/core'}) do
assert(not filename:find('/'), '"%s" has /', filename)
if filename:find('\\core') then count = count + 1 end
- end, {'/core'})
+ end
assert(count > 0, 'no core files found')
_G.WIN32 = win32 -- reset just in case
end
@@ -2097,6 +2100,8 @@ function test_ui_find_find_in_files()
view:unsplit()
buffer:close()
-- TODO: ui.find.find_in_files() -- no param
+
+ assert_raises(function() ui.find.find_in_files('', 1) end, 'string/table/nil expected, got number')
end
function test_ui_find_replace()
@@ -3052,9 +3057,9 @@ function test_buffer_view_usage()
'!/modules/lua/lua.luadoc', '!/modules/debugger/lua/mobdebug.lua',
'!/modules/yaml/lyaml.lua', '!/scripts', '!/src'
}
- lfs.dir_foreach(_HOME, function(filename)
+ for filename in lfs.walk(_HOME, filter) do
check_property_usage(filename, buffer_props, view_props)
- end, filter)
+ end
end
--------------------------------------------------------------------------------