lib/textbringer/commands/isearch.rb in textbringer-1.0.1 vs lib/textbringer/commands/isearch.rb in textbringer-1.0.2
- old
+ new
@@ -1,8 +1,8 @@
module Textbringer
module Commands
- ISEARCH_MODE_MAP = Keymap.new
+ define_keymap :ISEARCH_MODE_MAP
(?\x20..?\x7e).each do |c|
ISEARCH_MODE_MAP.define_key(c, :isearch_printing_char)
end
ISEARCH_MODE_MAP.define_key(?\t, :isearch_printing_char)
ISEARCH_MODE_MAP.handle_undefined_key do |key|
@@ -17,10 +17,11 @@
ISEARCH_MODE_MAP.define_key(?\C-s, :isearch_repeat_forward)
ISEARCH_MODE_MAP.define_key(?\C-r, :isearch_repeat_backward)
ISEARCH_MODE_MAP.define_key(?\C-w, :isearch_yank_word_or_char)
ISEARCH_MODE_MAP.define_key(?\C-m, :isearch_exit)
ISEARCH_MODE_MAP.define_key(?\C-g, :isearch_abort)
+ ISEARCH_MODE_MAP.define_key(?\C-q, :isearch_quoted_insert)
ISEARCH_STATUS = {
forward: true,
string: "",
last_string: "",
@@ -110,9 +111,17 @@
buffer = Buffer.current
if buffer.looking_at?(/(\p{Letter}|\p{Number})+|\s+|./)
ISEARCH_STATUS[:string].concat(buffer.match_string(0))
isearch_search
end
+ end
+
+ define_command(:isearch_quoted_insert, doc: <<~EOD) do
+ Read a character, and add it to the search string and search.
+ EOD
+ c = Controller.current.read_event
+ ISEARCH_STATUS[:string].concat(c)
+ isearch_search
end
def isearch_search
forward = ISEARCH_STATUS[:forward]
options = if /\A[A-Z]/.match?(ISEARCH_STATUS[:string])