aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/keys.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2013-04-11 23:58:33 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2013-04-11 23:58:33 -0400
commita65f9ac0c460fba64b2d8ddde2149661c025ea65 (patch)
tree9f1d3e7b73756b264974d0be272a722fc92e483e /modules/textadept/keys.lua
parent2a54e9fcfd955b8cf63fa42f41292d1176026721 (diff)
downloadtextadept-a65f9ac0c460fba64b2d8ddde2149661c025ea65.tar.gz
textadept-a65f9ac0c460fba64b2d8ddde2149661c025ea65.zip
Added key modes and changed the command entry to use them.
Removed obsoleted `events.COMMAND_ENTRY_COMMAND`.
Diffstat (limited to 'modules/textadept/keys.lua')
-rw-r--r--modules/textadept/keys.lua28
1 files changed, 25 insertions, 3 deletions
diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua
index 8fa15a19..e2d41770 100644
--- a/modules/textadept/keys.lua
+++ b/modules/textadept/keys.lua
@@ -298,7 +298,8 @@ events.connect(events.BUFFER_NEW, constantize_menu_buffer_functions)
if not RESETTING then constantize_menu_buffer_functions() end
local keys = keys
-local io, gui, gui_find, buffer, view = io, gui, gui.find, buffer, view
+local io, gui, gui_find, gui_ce = io, gui, gui.find, gui.command_entry
+local buffer, view = buffer, view
local m_textadept, m_editing = _M.textadept, _M.textadept.editing
local m_bookmarks, m_snippets = m_textadept.bookmarks, m_textadept.snippets
local OSX, c = OSX, _SCINTILLA.constants
@@ -466,13 +467,13 @@ keys[not OSX and 'cj' or 'mj'] = m_editing.goto_line
-- Tools.
keys[not OSX and (not CURSES and 'ce' or 'mc')
- or 'me'] = gui.command_entry.focus
+ or 'me'] = {gui_ce.enter_mode, 'lua_command'}
keys[not OSX and (not CURSES and 'cE' or 'mC') or 'mE'] = utils.select_command
keys[not OSX and 'cr' or 'mr'] = m_textadept.run.run
keys[not OSX and (not CURSES and 'cR' or 'cmr')
or 'mR'] = m_textadept.run.compile
keys[not OSX and (not CURSES and 'c|' or 'c\\')
- or 'm|'] = m_textadept.filter_through.filter_through
+ or 'm|'] = {gui_ce.enter_mode, 'filter_through'}
-- Adeptsense.
keys[not OSX and (not CURSES and 'c ' or 'c@')
or 'aesc'] = m_textadept.adeptsense.complete
@@ -594,4 +595,25 @@ elseif CURSES then
keys.ck = utils.cut_to_eol
end
+-- Modes.
+keys.lua_command = {
+ ['\t'] = gui_ce.complete_lua,
+ ['\n'] = {gui_ce.finish_mode, gui_ce.execute_lua}
+}
+keys.filter_through = {
+ ['\n'] = {gui_ce.finish_mode, m_textadept.filter_through.filter_through},
+}
+keys.find_incremental = {
+ ['\n'] = gui_find.find_incremental_next,
+ ['cr'] = gui_find.find_incremental_prev,
+ ['\b'] = function()
+ gui_find.find_incremental(gui_ce.entry_text:sub(1, -2))
+ return false -- propagate
+ end
+}
+setmetatable(keys.find_incremental, {__index = function(t, k)
+ if #k > 1 and k:find('^[cams]*.+$') then return end
+ gui_find.find_incremental(gui_ce.entry_text..k)
+ end})
+
return M