diff options
Diffstat (limited to 'modules/textadept')
-rw-r--r-- | modules/textadept/editing.lua | 38 | ||||
-rw-r--r-- | modules/textadept/find.lua | 13 | ||||
-rw-r--r-- | modules/textadept/keys.lua | 6 | ||||
-rw-r--r-- | modules/textadept/menu.lua | 1 |
4 files changed, 15 insertions, 43 deletions
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 5aafe964..20b0c0bd 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -17,15 +17,12 @@ local M = {} -- The default value is `false`. -- @field INDIC_BRACEMATCH (number) -- The matching brace highlight indicator number. --- @field INDIC_HIGHLIGHT (number) --- The word highlight indicator number. module('textadept.editing')]] M.auto_indent = true M.strip_trailing_spaces = false M.autocomplete_all_words = false M.INDIC_BRACEMATCH = _SCINTILLA.next_indic_number() -M.INDIC_HIGHLIGHT = _SCINTILLA.next_indic_number() --- -- Map of image names to registered image numbers. @@ -538,41 +535,6 @@ function M.convert_indentation() buffer:end_undo_action() end --- Clears highlighted word indicators and markers. -local function clear_highlighted_words() - buffer.indicator_current = M.INDIC_HIGHLIGHT - buffer:indicator_clear_range(1, buffer.length) -end -events.connect(events.KEYPRESS, function(code) - if keys.KEYSYMS[code] == 'esc' then clear_highlighted_words() end -end, 1) - ---- --- Highlights all occurrences of the selected text or all occurrences of the --- current word. --- @see buffer.word_chars --- @name highlight_word -function M.highlight_word() - clear_highlighted_words() - local buffer = buffer - local s, e = buffer.selection_start, buffer.selection_end - if s == e then - s = buffer:word_start_position(s, true) - e = buffer:word_end_position(s, true) - end - if s == e then return end - local word = buffer:text_range(s, e) - local flags = buffer.FIND_MATCHCASE - if buffer:is_range_word(s, e) then flags = flags | buffer.FIND_WHOLEWORD end - buffer.search_flags = flags - buffer:target_whole_document() - while buffer:search_in_target(word) ~= -1 do - buffer:indicator_fill_range( - buffer.target_start, buffer.target_end - buffer.target_start) - buffer:set_target_range(buffer.target_end, buffer.length + 1) - end -end - --- -- Passes the selected text or all buffer text to string shell command *command* -- as standard input (stdin) and replaces the input text with the command's diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index c34ce370..22a6a376 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -124,6 +124,19 @@ local function find(text, next, flags, no_wrap, wrapped) if flags >= 1 << 31 then M.find_in_files() return end -- not performed here local first_visible_line = view.first_visible_line -- for 'no results found' + -- Highlight all occurrences first, otherwise regex tags will be overwritten. + buffer.indicator_current = ui.INDIC_HIGHLIGHT + buffer:indicator_clear_range(1, buffer.length) + if ui.highlight_words and #text > 1 then + buffer.search_flags = flags + buffer:target_whole_document() + while buffer:search_in_target(text) ~= -1 do + buffer:indicator_fill_range( + buffer.target_start, buffer.target_end - buffer.target_start) + buffer:set_target_range(buffer.target_end, buffer.length + 1) + end + end + -- If text is selected, assume it is from the current search and move the -- caret appropriately for the next search. buffer:goto_pos(next and buffer.selection_end or buffer.selection_start) diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua index 938cb0af..f70a7027 100644 --- a/modules/textadept/keys.lua +++ b/modules/textadept/keys.lua @@ -38,7 +38,6 @@ local M = {} -- Ctrl+A |⌘A |M-A |Select all -- Ctrl+M |^M |M-M |Match brace -- Ctrl+Enter |^Esc |M-Enter^(‡) |Complete word --- Ctrl+Alt+Shift+H |⌘⇧H |None |Highlight word -- Ctrl+/ |^/ |M-/ |Toggle block comment -- Ctrl+T |^T |^T |Transpose characters -- Ctrl+Shift+J |^J |M-J |Join lines @@ -222,7 +221,7 @@ module('textadept.keys')]] -- Unassigned keys (~ denotes keys reserved by the operating system): -- c: C H I p Q T ~ V Y _ ) ] } + -- a: aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ_ ) ] } *+-/=\n\s --- ca: aAbBcCdD F jJkKlLmM N qQ t xXy zZ_"'()[]{}<>* / \s +-- ca: aAbBcCdD F H jJkKlLmM N qQ t xXy zZ_"'()[]{}<>* / \s -- -- c = 'ctrl' (Control ^) -- a = 'alt' (Alt) @@ -233,7 +232,7 @@ module('textadept.keys')]] -- Mac OSX key bindings. -- -- Unassigned keys (~ denotes keys reserved by the operating system): --- m: C ~ I JkK ~M p ~ tT V yY _ ) ] } + ~~\n +-- m: C ~H I JkK ~M p ~ tT V yY _ ) ] } + ~~\n -- c: cC D gG H J K L oO qQ xXyYzZ_ ) ] } * / -- cm: aAbBcC~D F ~HiIjJkKlL~MnN p q~rRsStTuUvVwWxXyYzZ_"'()[]{}<>*+-/=\t\n -- @@ -313,7 +312,6 @@ local bindings = { [m_edit[_L['Match Brace']][2]] = {'ctrl+m', 'ctrl+m', 'meta+m'}, [m_edit[_L['Complete Word']][2]] = {'ctrl+\n', 'ctrl+esc', {'ctrl+meta+j', 'ctrl+\n'}}, - [textadept.editing.highlight_word] = {'ctrl+alt+H', 'cmd+H', nil}, [textadept.editing.block_comment] = {'ctrl+/', 'ctrl+/', 'meta+/'}, [textadept.editing.transpose_chars] = {'ctrl+t', 'ctrl+t', 'ctrl+t'}, [textadept.editing.join_lines] = {'ctrl+J', 'ctrl+j', 'meta+j'}, diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua index c84e2bd7..4d461abb 100644 --- a/modules/textadept/menu.lua +++ b/modules/textadept/menu.lua @@ -97,7 +97,6 @@ local default_menubar = { {_L['Complete Word'], function() textadept.editing.autocomplete('word') end}, - {_L['Highlight Word'], textadept.editing.highlight_word}, {_L['Toggle Block Comment'], textadept.editing.block_comment}, {_L['Transpose Characters'], textadept.editing.transpose_chars}, {_L['Join Lines'], textadept.editing.join_lines}, |