aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/textadept/command_entry.lua16
-rw-r--r--modules/textadept/keys.lua2
-rw-r--r--modules/textadept/menu.lua2
3 files changed, 13 insertions, 7 deletions
diff --git a/modules/textadept/command_entry.lua b/modules/textadept/command_entry.lua
index 54971686..6ad48981 100644
--- a/modules/textadept/command_entry.lua
+++ b/modules/textadept/command_entry.lua
@@ -58,16 +58,21 @@ M.editing_keys = {__index = {
}}
---
--- Opens the command entry in key mode *mode*.
+-- Opens the command entry in key mode *mode*, highlighting text with lexer name
+-- *lexer*, and displaying *height* number of lines at a time.
-- Key bindings will be looked up in `keys[mode]` instead of `keys`. The `Esc`
-- key exits the current mode, closes the command entry, and restores normal key
-- lookup.
-- This function is useful for binding keys to enter a command entry mode.
-- @param mode The key mode to enter into, or `nil` to exit the current mode.
+-- @param lexer Optional string lexer name to use for command entry text. The
+-- default value is `'text'`.
+-- @param height Optional number of lines to display in the command entry. The
+-- default value is `1`.
-- @usage keys['ce'] = {ui.command_entry.enter_mode, 'command_entry'}
-- @see _G.keys.MODE
-- @name enter_mode
-function M.enter_mode(mode)
+function M.enter_mode(mode, lexer, height)
if M:auto_c_active() then M:auto_c_cancel() end -- may happen in curses
keys.MODE = mode
if mode then
@@ -77,7 +82,8 @@ function M.enter_mode(mode)
end
M:select_all()
M.focus()
- if not CURSES then M.height = M:text_height(0) end
+ M:set_lexer(lexer or 'text')
+ M.height = M:text_height(0) * (height or 1)
end
---
@@ -134,7 +140,8 @@ args.register('-e', '--execute', 1, run_lua, 'Execute Lua code')
-- "abbreviated" environment where the `buffer`, `view`, and `ui` tables are
-- also considered as globals.
local function complete_lua()
- local symbol, op, part = M:get_text():match('([%w_.]-)([%.:]?)([%w_]*)$')
+ local line, pos = M:get_cur_line()
+ local symbol, op, part = line:sub(1, pos):match('([%w_.]-)([%.:]?)([%w_]*)$')
local ok, result = pcall((load('return ('..symbol..')', nil, 'bt', env)))
local cmpls = {}
part = '^'..part
@@ -174,7 +181,6 @@ events.connect(events.INITIALIZED, function()
if not arg then return end -- no need to reconfigure on reset
M.h_scroll_bar, M.v_scroll_bar = false, false
M.margin_width_n[0], M.margin_width_n[1], M.margin_width_n[2] = 0, 0, 0
- M:set_lexer('lua')
end)
--[[ The function below is a Lua C function.
diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua
index b5fbaa45..3e463026 100644
--- a/modules/textadept/keys.lua
+++ b/modules/textadept/keys.lua
@@ -467,7 +467,7 @@ keys[not OSX and 'cj' or 'mj'] = editing.goto_line
-- Tools.
keys[not OSX and (not CURSES and 'ce' or 'mc')
- or 'me'] = {ui.command_entry.enter_mode, 'lua_command'}
+ or 'me'] = {ui.command_entry.enter_mode, 'lua_command', 'lua'}
keys[not OSX and (not CURSES and 'cE' or 'mC') or 'mE'] = utils.select_command
keys[not OSX and 'cr' or 'mr'] = textadept.run.run
keys[not OSX and (not CURSES and 'cR' or 'cmr') or 'mR'] = textadept.run.compile
diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua
index 0cbf4590..e427e072 100644
--- a/modules/textadept/menu.lua
+++ b/modules/textadept/menu.lua
@@ -103,7 +103,7 @@ local menubar = {
{_L['_Jump to'], editing.goto_line},
},
{ title = _L['_Tools'],
- {_L['Command _Entry'], {ui.command_entry.enter_mode, 'lua_command'}},
+ {_L['Command _Entry'], {ui.command_entry.enter_mode, 'lua_command', 'lua'}},
{_L['Select Co_mmand'], utils.select_command},
SEPARATOR,
{_L['_Run'], textadept.run.run},