aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/find.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2019-09-22 19:15:04 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2019-09-22 19:15:04 -0400
commit8d691eedfb6c62c231fc95d1be786de6cc945cb7 (patch)
tree5aa4f0a77c403dad129b6ef7fcf4b0cbd6cf33a1 /modules/textadept/find.lua
parentf7cfaf74fb0170bc65671c493bccd49b11835256 (diff)
downloadtextadept-8d691eedfb6c62c231fc95d1be786de6cc945cb7.tar.gz
textadept-8d691eedfb6c62c231fc95d1be786de6cc945cb7.zip
Replaced `ui.command_entry.*_mode()` with simplified `ui.command_entry.run()`.
The command entry no longer uses named key modes. Instead, mode keys are supplied to `run()` if necessary. The command entry remains modal, though.
Diffstat (limited to 'modules/textadept/find.lua')
-rw-r--r--modules/textadept/find.lua23
1 files changed, 22 insertions, 1 deletions
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index b817289f..120abae5 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -204,10 +204,31 @@ function M.find_incremental(text, next, anchor)
if text then find_incremental(text, next, anchor) return end
incremental_start = buffer.current_pos
ui.command_entry:set_text('')
- ui.command_entry.enter_mode('find_incremental')
+ ui.command_entry.run(nil, M.find_incremental_keys)
end
---
+-- Table of key bindings used when searching for text incrementally.
+-- @class table
+-- @name find_incremental_keys
+M.find_incremental_keys = setmetatable({
+ ['\n'] = function()
+ M.find_entry_text = ui.command_entry:get_text() -- save
+ M.find_incremental(ui.command_entry:get_text(), true, true)
+ end,
+ ['\b'] = function()
+ local e = ui.command_entry:position_before(ui.command_entry.length)
+ M.find_incremental(ui.command_entry:text_range(0, e), true)
+ return false -- propagate
+ end
+}, {__index = function(_, k)
+ -- Add the character for any key pressed without modifiers to incremental
+ -- find.
+ if #k > 1 and k:find('^[cams]*.+$') then return end
+ M.find_incremental(ui.command_entry:get_text()..k, true)
+end})
+
+---
-- Searches directory *dir* or the user-specified directory for files that match
-- search text and search options (subject to optional filter *filter*), and
-- prints the results to a buffer titled "Files Found", highlighting found text.