aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept
diff options
context:
space:
mode:
Diffstat (limited to 'modules/textadept')
-rw-r--r--modules/textadept/editing.lua22
-rw-r--r--modules/textadept/keys.lua10
-rw-r--r--modules/textadept/menu.lua3
3 files changed, 10 insertions, 25 deletions
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua
index eb9aa8c5..59799709 100644
--- a/modules/textadept/editing.lua
+++ b/modules/textadept/editing.lua
@@ -381,28 +381,20 @@ end
---
-- Selects the text in-between strings *left* and *right* containing the caret.
+-- If already selected, toggles between selecting the *left* and *right*
+-- enclosures too.
-- @param left The left part of the enclosure.
-- @param right The right part of the enclosure.
-- @name select_enclosed
function M.select_enclosed(left, right)
local buffer = buffer
+ local anchor, pos = buffer.anchor, buffer.current_pos
+ if anchor ~= pos then buffer:goto_pos(pos - #right) end
buffer:search_anchor()
local s, e = buffer:search_prev(0, left), buffer:search_next(0, right)
- if s >= 0 and e >= 0 then buffer:set_sel(s + 1, e) end
-end
-
----
--- Grows the selected text by *amount* number of characters on either end.
--- @param amount The number of characters to grow the selection by on either
--- end.
--- @name grow_selection
-function M.grow_selection(amount)
- local buffer = buffer
- local anchor, pos = buffer.anchor, buffer.current_pos
- if anchor < pos then
- buffer:set_sel(anchor - amount, pos + amount)
- else
- buffer:set_sel(anchor + amount, pos - amount)
+ if s >= 0 and e >= 0 then
+ if s + #left == anchor and e == pos then s, e = s - #left, e + #right end
+ buffer:set_sel(s + #left, e)
end
end
diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua
index e87bed56..e88bbb6e 100644
--- a/modules/textadept/keys.lua
+++ b/modules/textadept/keys.lua
@@ -63,8 +63,6 @@ local M = {}
-- Alt+( |^( |M-) |Enclose in parentheses
-- Alt+[ |^[ |M-] |Enclose in brackets
-- Alt+{ |^{ |M-} |Enclose in braces
--- Ctrl++ |⌘+ |M-+ |Grow selection bounds by 1
--- Ctrl+\_ |⌘\_ |M-\_ |Shrink selection bounds by 1
-- Ctrl+Shift+Up |^⇧⇡ |S-^Up |Move selected lines up
-- Ctrl+Shift+Down |^⇧⇣ |S-^Down |Move selected lines down
-- **Search** | | |
@@ -312,7 +310,7 @@ local utils = M.utils
-- Windows and Linux key bindings.
--
-- Unassigned keys (~ denotes keys reserved by the operating system):
--- c: A B C H p Q ~ V X Y ) ] }
+-- c: A B C H p Q ~ V X Y _ ) ] } +
-- a: aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ_ ) ] } *+-/=\n\s
-- ca: aAbBcCdD F jJkKlLmM N PqQ t xXy zZ_"'()[]{}<>* / \s
--
@@ -327,7 +325,7 @@ local utils = M.utils
-- Mac OSX key bindings.
--
-- Unassigned keys (~ denotes keys reserved by the operating system):
--- m: A B C ~ JkK ~M p ~ t U V XyY ) ] } ~~\n
+-- m: A B C ~ JkK ~M p ~ t U V XyY _ ) ] } + ~~\n
-- c: cC D gG H J K L oO qQ xXyYzZ_ ) ] } * /
-- cm: aAbBcC~D F ~HiIjJkKlL~MnN pPq~rRsStTuUvVwWxXyYzZ_"'()[]{}<>*+-/=\t\n
--
@@ -355,7 +353,7 @@ local utils = M.utils
-- Unassigned keys (~ denotes keys reserved by the operating system):
-- c: g~~ ~
-- cm: bcd g~~ k ~ pq t v xyz
--- m: e J qQ sS u vVw yYzZ
+-- m: e J qQ sS u vVw yYzZ_ +
-- Note: m[befhstv] may be used by Linux/BSD GUI terminals for menu access.
--
-- CTRL = 'c' (Control ^)
@@ -439,8 +437,6 @@ keys[not OSX and (not CURSES and 'a[' or 'm]')
or 'c['] = {m_editing.enclose, '[', ']'}
keys[not OSX and (not CURSES and 'a{' or 'm}')
or 'c{'] = {m_editing.enclose, '{', '}'}
-keys[not OSX and not CURSES and 'c+' or 'm+'] = {m_editing.grow_selection, 1}
-keys[not OSX and not CURSES and 'c_' or 'm_'] = {m_editing.grow_selection, -1}
keys.csup = buffer.move_selected_lines_up
keys.csdown = buffer.move_selected_lines_down
diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua
index 5dc77735..3115bdea 100644
--- a/modules/textadept/menu.lua
+++ b/modules/textadept/menu.lua
@@ -93,9 +93,6 @@ local menubar = {
{_L['Enclose in _Brackets'], {m_editing.enclose, '[', ']'}},
{_L['Enclose in B_races'], {m_editing.enclose, '{', '}'}},
SEPARATOR,
- {_L['_Grow Selection'], {m_editing.grow_selection, 1}},
- {_L['_Shrink Selection'], {m_editing.grow_selection, -1}},
- SEPARATOR,
{_L['_Move Selected Lines Up'], buffer.move_selected_lines_up},
{_L['Move Selected Lines Do_wn'], buffer.move_selected_lines_down},
},