aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2020-10-02 15:57:44 -0400
committerGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2020-10-02 15:57:44 -0400
commitfbdab8f56e606d28f74d26bc729c8f835aed23db (patch)
treea0f95afb6b175059bb58dad884d172affcb9b200 /modules
parent19ab592c17cb5c0fbf16de34ffba25d2f95f7cc4 (diff)
Command entry also considers contents of `textadept` as globals.
Include buffer/view constants as well, which should have been there anyway.
Diffstat (limited to 'modules')
-rw-r--r--modules/lua/ta_api2
-rw-r--r--modules/textadept/command_entry.lua15
2 files changed, 9 insertions, 8 deletions
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