aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--core/.ui.dialogs.luadoc2
-rw-r--r--docs/api.md6
-rw-r--r--docs/manual.md9
-rw-r--r--modules/lua/ta_api2
-rw-r--r--modules/textadept/command_entry.lua15
-rw-r--r--test/test.lua11
6 files changed, 29 insertions, 16 deletions
diff --git a/core/.ui.dialogs.luadoc b/core/.ui.dialogs.luadoc
index c1f113ea..3b13b8cb 100644
--- a/core/.ui.dialogs.luadoc
+++ b/core/.ui.dialogs.luadoc
@@ -518,7 +518,7 @@ function optionselect(options) end
-- or as strings in "#RRGGBB" format. If `true` (no list was given), a
-- default palette is shown.
-- * `string_output`: Return the selected color in string "#RRGGBB" format
--- instead of numeric "0xBBGGRR" format. The default value is `false`.
+-- instead of as a number. The default value is `false`.
-- * `float`: Show the dialog on top of all desktop windows. The default value
-- is `false`.
-- @return selected color
diff --git a/docs/api.md b/docs/api.md
index 196e35f5..5748da17 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -5228,7 +5228,7 @@ mark fold points based on changes in indentation, create the lexer with a
### Using Lexers
-#### Textadept
+**Textadept**
Put your lexer in your *~/.textadept/lexers/* directory so you do not
overwrite it when upgrading Textadept. Also, lexers in this directory
@@ -5237,7 +5237,7 @@ the default *lua* lexer. This is convenient for tweaking a default lexer to
your liking. Then add a [file type](#textadept.file_types) for your lexer if
necessary.
-#### SciTE
+**SciTE**
Create a *.properties* file for your lexer and `import` it in either your
*SciTEUser.properties* or *SciTEGlobal.properties*. The contents of the
@@ -8010,7 +8010,7 @@ Parameters:
or as strings in "#RRGGBB" format. If `true` (no list was given), a
default palette is shown.
* `string_output`: Return the selected color in string "#RRGGBB" format
- instead of numeric "0xBBGGRR" format. The default value is `false`.
+ instead of as a number. The default value is `false`.
* `float`: Show the dialog on top of all desktop windows. The default value
is `false`.
diff --git a/docs/manual.md b/docs/manual.md
index c917027c..d090f323 100644
--- a/docs/manual.md
+++ b/docs/manual.md
@@ -626,10 +626,10 @@ You can open the Lua command entry via `Ctrl+E` on Windows, Linux, and BSD,
Lua's interactive prompt. Type in the Lua command or code to run and press
`Enter` to invoke or run it. Textadept's [Lua API][] contains all of the
application's built-in commands. For convenience, the contents of the
-[`buffer`][], [`view`][], and [`ui`][] tables are considered to be global
-variables, the first parameter to `buffer` and `view` functions may be omitted,
-and function call parentheses can also be omitted. For example, instead of
-entering `buffer:append_text('foo')`, you can enter `append_text('foo')`.
+[`buffer`][], [`view`][], [`ui`][], and [`textadept`][] tables are considered to
+be global variables, the first parameter to `buffer` and `view` functions may be
+omitted, and function call parentheses can also be omitted. For example, instead
+of entering `buffer:append_text('foo')`, you can enter `append_text('foo')`.
Instead of `view:split()`, you can simply use `split`. These convenience
facilities are not available in normally executed Lua code, such as code in
*~/.textadept/init.lua*.
@@ -666,6 +666,7 @@ file.
[`buffer`]: api.html#buffer
[`view`]: api.html#view
[`ui`]: api.html#ui
+[`textadept`]: api.html#textadept
##### Shell Command Entry and Filtering Text
diff --git a/modules/lua/ta_api b/modules/lua/ta_api
index 8af13d07..a2fbe09a 100644
--- a/modules/lua/ta_api
+++ b/modules/lua/ta_api
@@ -430,7 +430,7 @@ close_all_buffers io.close_all_buffers()\nCloses all open buffers, prompting the
cntrl lexer.cntrl (pattern)\nA pattern that matches any control character (ASCII codes 0 to 31).
colorize buffer.colorize(buffer, start_pos, end_pos)\nInstructs the lexer to style and mark fold points in the range of text\nbetween *start_pos* and *end_pos*.\nIf *end_pos* is `-1`, styles and marks to the end of the buffer.\n@param buffer A buffer.\n@param start_pos The start position of the range of text in *buffer* to\n process.\n@param end_pos The end position of the range of text in *buffer* to process,\n or `-1` to process from *start_pos* to the end of *buffer*.
colors lexer.colors (table)\nMap of color name strings to color values in `0xBBGGRR` or `"#RRGGBB"`\nformat.\nNote: for applications running within a terminal emulator, only 16 color\nvalues are recognized, regardless of how many colors a user's terminal\nactually supports. (A terminal emulator's settings determines how to actually\ndisplay these recognized color values, which may end up being mapped to a\ncompletely different color set.) In order to use the light variant of a\ncolor, some terminals require a style's `bold` attribute must be set along\nwith that normal color. Recognized color values are black (0x000000), red\n(0x000080), green (0x008000), yellow (0x008080), blue (0x800000), magenta\n(0x800080), cyan (0x808000), white (0xC0C0C0), light black (0x404040), light\nred (0x0000FF), light green (0x00FF00), light yellow (0x00FFFF), light blue\n(0xFF0000), light magenta (0xFF00FF), light cyan (0xFFFF00), and light white\n(0xFFFFFF).
-colorselect ui.dialogs.colorselect(options)\nPrompts the user with a color selection dialog defined by dialog options\ntable *options*, returning the color selected.\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 * `color`: The initially selected color as either a number in "0xBBGGRR"\n format, or as a string in "#RRGGBB" format.\n * `palette`: The list of colors to show in the dialog's color palette.\n Up to 20 colors can be specified as either numbers in "0xBBGGRR" format\n or as strings in "#RRGGBB" format. If `true` (no list was given), a\n default palette is shown.\n * `string_output`: Return the selected color in string "#RRGGBB" format\n instead of numeric "0xBBGGRR" format. The default value is `false`.\n * `float`: Show the dialog on top of all desktop windows. The default value\n is `false`.\n@usage ui.dialogs.colorselect{title = 'Foreground color', color = 0x000000,\n palette = {'#000000', 0x0000FF, '#00FF00', 0xFF0000}}\n@return selected color
+colorselect ui.dialogs.colorselect(options)\nPrompts the user with a color selection dialog defined by dialog options\ntable *options*, returning the color selected.\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 * `color`: The initially selected color as either a number in "0xBBGGRR"\n format, or as a string in "#RRGGBB" format.\n * `palette`: The list of colors to show in the dialog's color palette.\n Up to 20 colors can be specified as either numbers in "0xBBGGRR" format\n or as strings in "#RRGGBB" format. If `true` (no list was given), a\n default palette is shown.\n * `string_output`: Return the selected color in string "#RRGGBB" format\n instead of as a number. The default value is `false`.\n * `float`: Show the dialog on top of all desktop windows. The default value\n is `false`.\n@usage ui.dialogs.colorselect{title = 'Foreground color', color = 0x000000,\n palette = {'#000000', 0x0000FF, '#00FF00', 0xFF0000}}\n@return selected color
column buffer.column (table, Read-only)\nTable of column numbers (taking tab widths into account) per position.\nMulti-byte characters count as single characters.
command_entry ui.command_entry (module)\nTextadept's Command Entry.\nIt supports multiple modes that each have their own functionality (such as\nrunning Lua code and filtering text through shell commands) and history.
comment_string textadept.editing.comment_string (table)\nMap of lexer names to line comment strings for programming languages, used by\nthe `toggle_comment()` function.\nKeys are lexer names and values are either the language's line comment\nprefixes or block comment delimiters separated by a '|' character.\n@see toggle_comment
diff --git a/modules/textadept/command_entry.lua b/modules/textadept/command_entry.lua
index b67f8ef4..594b1e81 100644
--- a/modules/textadept/command_entry.lua
+++ b/modules/textadept/command_entry.lua
@@ -80,7 +80,7 @@ local env = setmetatable({}, {
elseif type(view[k]) == 'function' then
return function(...) view[k](view, ...) end -- do not return a value
end
- return buffer[k] or view[k] or ui[k] or _G[k]
+ return buffer[k] or view[k] or ui[k] or _G[k] or textadept[k]
end,
__newindex = function(self, k, v)
local ok, value = pcall(function() return buffer[k] end)
@@ -96,8 +96,8 @@ local env = setmetatable({}, {
-- Executes string *code* as Lua code that is subject to an "abbreviated"
-- environment.
--- In this environment, the contents of the `buffer`, `view`, and `ui` tables
--- are also considered as global functions and fields.
+-- In this environment, the contents of the `buffer`, `view`, `ui`, and
+-- `textadept` tables are also considered as global functions and fields.
-- Prints the results of expressions like in the Lua prompt. Also invokes bare
-- functions as commands.
-- @param code The Lua code to execute.
@@ -138,11 +138,12 @@ local function complete_lua()
part = '^' .. part
local sep = string.char(M.auto_c_type_separator)
local XPM = textadept.editing.XPM_IMAGES
- if not ok or symbol == 'buffer' then
+ if not ok or symbol == 'buffer' or symbol == 'view' then
local sci = _SCINTILLA
- local global_envs =
- not ok and {buffer, view, ui, _G, sci.functions, sci.properties} or
- op == ':' and {sci.functions} or {sci.properties, sci.constants}
+ local global_envs = not ok and {
+ buffer, view, ui, _G, textadept, sci.functions, sci.properties,
+ sci.constants
+ } or op == ':' and {sci.functions} or {sci.properties, sci.constants}
for _, env in ipairs(global_envs) do
for k, v in pairs(env) do
if type(k) == 'string' and k:find(part) then
diff --git a/test/test.lua b/test/test.lua
index 5f2fcb45..d89937a7 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -1242,6 +1242,11 @@ function test_command_entry_run_lua_abbreviated_env()
run_lua_command('foo="bar"')
run_lua_command('foo')
assert(buffer:get_text():find('bar%s*$'), 'foo result not "bar"')
+ -- textadept get/set.
+ run_lua_command('editing')
+ assert(buffer:get_text():find('%b{}%s*$'), 'textadept.editing result not a table')
+ run_lua_command('editing.select_paragraph')
+ assert(buffer.selection_start ~= buffer.selection_end, 'textadept.editing.select_paragraph() did not select paragraph')
buffer:close()
end
@@ -1263,10 +1268,16 @@ function test_command_entry_complete_lua()
ui.command_entry.run()
assert_lua_autocompletion('string.', 'byte')
assert_lua_autocompletion('auto', 'auto_c_active')
+ assert_lua_autocompletion('MARK', 'MARKER_MAX')
assert_lua_autocompletion('buffer.auto', 'auto_c_auto_hide')
assert_lua_autocompletion('buffer:auto', 'auto_c_active')
+ assert_lua_autocompletion('caret', 'caret_fore')
+ assert_lua_autocompletion('ANNO', 'ANNOTATION_BOXED')
+ assert_lua_autocompletion('view.margin', 'margin_back_n')
+ assert_lua_autocompletion('view:call', 'call_tip_active')
assert_lua_autocompletion('goto', 'goto_buffer')
assert_lua_autocompletion('_', '_BUFFERS')
+ assert_lua_autocompletion('fi', 'file_types')
-- TODO: textadept.editing.show_documentation key binding.
ui.command_entry:focus() -- hide
end