diff options
Diffstat (limited to 'modules/textadept/editing.lua')
-rw-r--r-- | modules/textadept/editing.lua | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 839b70e8..e3b19e80 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -1,6 +1,6 @@ -- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE. -local locale = _G.locale +local L = _G.locale.localize local events = _G.events --- @@ -141,9 +141,6 @@ events.connect('char_added', end end) --- local functions -local get_preceding_number - --- -- Goes to a matching brace position, selecting the text inside if specified. -- @param select If true, selects the text between matching braces. @@ -233,8 +230,8 @@ function goto_line(line) local buffer = buffer if not line then line = gui.dialog('standard-inputbox', - '--title', locale.M_TEXTADEPT_EDITING_GOTO_TITLE, - '--text', locale.M_TEXTADEPT_EDITING_GOTO_TEXT, + '--title', L('Go To'), + '--text', L('Line Number:'), '--no-newline') line = tonumber(line:match('%-?%d+$')) if not line or line < 0 then return end @@ -323,6 +320,22 @@ function join_lines() buffer:lines_join() end +-- Returns the number to the left of the caret. +-- This is used for the enclose function. +-- @see enclose +local function get_preceding_number() + local buffer = buffer + local caret = buffer.current_pos + local char = buffer.char_at[caret - 1] + local txt = '' + while tonumber(string.char(char)) do + txt = txt..string.char(char) + caret = caret - 1 + char = buffer.char_at[caret - 1] + end + return tonumber(txt) or 1, #txt +end + --- -- Encloses text in an enclosure set. -- If text is selected, it is enclosed. Otherwise, the previous word is |