diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/keys.lua | 98 | ||||
-rw-r--r-- | core/locale.conf | 95 |
2 files changed, 105 insertions, 88 deletions
diff --git a/core/keys.lua b/core/keys.lua index 1ce7be82..9bdc5e93 100644 --- a/core/keys.lua +++ b/core/keys.lua @@ -52,15 +52,15 @@ module('keys', package.seeall) -- -- ## Settings -- --- * `CTRL` [string]: The string representing the Control/Command key. The +-- + `CTRL` [string]: The string representing the Control/Command key. The -- default is 'c'. --- * `ALT` [string]: The string representing the Alt/option key. The default is +-- + `ALT` [string]: The string representing the Alt/option key. The default is -- 'a' --- * `META` [string]: The string representing the Control key on Mac OSX. The +-- + `META` [string]: The string representing the Control key on Mac OSX. The -- default is 'm'. --- * `SHIFT` [string]: The string representing the Shift key. The default is +-- + `SHIFT` [string]: The string representing the Shift key. The default is -- 's'. --- * `ADD` [string]: The string representing used to join together a sequence of +-- + `ADD` [string]: The string representing used to join together a sequence of -- Control, Alt, Meta, or Shift modifier keys. The default is ''. -- * `CLEAR` [string]: The string representing the key sequence that clears the -- current keychain. The default is 'esc' (Escape). @@ -142,30 +142,6 @@ KEYSYMS = { -- from <gdk/gdkkeysyms.h> [0xFFC6] = 'f9', [0xFFC7] = 'f10', [0xFFC8] = 'f11', [0xFFC9] = 'f12', } ---- --- Returns the GDK integer keycode and modifier mask for a key sequence. --- This is used internally for creating menu accelerators. --- @param key_seq The string key sequence. --- @return keycode and modifier mask -function get_gdk_key(key_seq) - if not key_seq then return nil end - local mods, key = key_seq:match('^([cams]*)(.+)$') - if not mods or not key then return nil end - local modifiers = ((mods:find('s') or key:lower() ~= key) and 1 or 0) + - (mods:find('c') and 4 or 0) + (mods:find('a') and 8 or 0) + - (mods:find('m') and 128 or 0) - local byte = string_byte(key) - if #key > 1 or byte < 32 then - for i, s in pairs(KEYSYMS) do - if s == key and i ~= 0xFE20 then - byte = i - break - end - end - end - return byte, modifiers -end - -- The current key sequence. local keychain = {} @@ -175,6 +151,30 @@ local function clear_key_sequence() gui.statusbar_text = '' end +-- Runs a given command. +-- This is also used by menu.lua. +-- @param command A function or table as described above. +-- @param command_type The type() of command. +-- @return the value the command returns. +local function run_command(command, command_type) + local f, args = command_type == 'function' and command or command[1], no_args + if command_type == 'table' then + args = command + -- If the argument is a view or buffer, use the current one instead. + if type(args[2]) == 'table' then + local mt, buffer, view = getmetatable(args[2]), buffer, view + if mt == getmetatable(buffer) then + args[2] = buffer + elseif mt == getmetatable(view) then + args[2] = view + end + end + end + local _, ret = xpcall(function() return f(unpack(args, 2)) end, error) + return ret +end +_M.run_command = run_command -- export for menu.lua without creating LuaDoc + -- Return codes for run_key_command(). local INVALID = -1 local PROPAGATE = 0 @@ -202,21 +202,7 @@ local function run_key_command(lexer) return CHAIN end - local f, args = key_type == 'function' and key or key[1], no_args - if key_type == 'table' then - args = key - -- If the argument is a view or buffer, use the current one instead. - if type(args[2]) == 'table' then - local mt, buffer, view = getmetatable(args[2]), buffer, view - if mt == getmetatable(buffer) then - args[2] = buffer - elseif mt == getmetatable(view) then - args[2] = view - end - end - end - local _, ret = xpcall(function() return f(unpack(args, 2)) end, error) - return ret == false and PROPAGATE or HALT + return run_command(key, key_type) == false and PROPAGATE or HALT end -- Handles Textadept keypresses. @@ -278,3 +264,27 @@ local function keypress(code, shift, control, alt, meta) -- PROPAGATE otherwise. end events.connect(events.KEYPRESS, keypress, 1) + +-- Returns the GDK integer keycode and modifier mask for a key sequence. +-- This is used for creating menu accelerators. +-- @param key_seq The string key sequence. +-- @return keycode and modifier mask +local function get_gdk_key(key_seq) + if not key_seq then return nil end + local mods, key = key_seq:match('^([cams]*)(.+)$') + if not mods or not key then return nil end + local modifiers = ((mods:find('s') or key:lower() ~= key) and 1 or 0) + + (mods:find('c') and 4 or 0) + (mods:find('a') and 8 or 0) + + (mods:find('m') and 128 or 0) + local byte = string_byte(key) + if #key > 1 or byte < 32 then + for i, s in pairs(KEYSYMS) do + if s == key and i ~= 0xFE20 then + byte = i + break + end + end + end + return byte, modifiers +end +_M.get_gdk_key = get_gdk_key -- export for menu.lua without generating LuaDoc diff --git a/core/locale.conf b/core/locale.conf index 6b343f1c..eab424a0 100644 --- a/core/locale.conf +++ b/core/locale.conf @@ -107,7 +107,7 @@ gtk-redo = gtk-redo gtk-cut = gtk-cut gtk-copy = gtk-copy gtk-paste = gtk-paste -Duplicate = Duplicat_e +Duplicate Line = Duplicat_e Line gtk-delete = gtk-delete gtk-select-all = gtk-select-all Match Brace = _Match Brace @@ -122,29 +122,28 @@ Transpose Characters = T_ranspose Characters Join Lines = _Join Lines Convert Indentation = Convert _Indentation Selection = Selectio_n -Enclose in... = _Enclose in... -HTML Tags = _HTML Tags -HTML Single Tag = HTML Single _Tag -Double Quotes = _Double Quotes -Single Quotes = _Single Quotes -Parentheses = _Parentheses -Brackets = _Brackets -Braces = B_races +Enclose as XML Tags = Enclose as _XML Tags +Enclose as Single XML Tag = Enclose as Single XML _Tag +Enclose in Double Quotes = Enclose in _Double Quotes +Enclose in Single Quotes = Enclose in _Single Quotes +Enclose in Parentheses = Enclose in _Parentheses +Enclose in Brackets = Enclose in _Brackets +Enclose in Braces = Enclose in B_races Grow Selection = _Grow Selection Shrink Selection = _Shrink Selection -Select in... = _Select in... -Between Tags = Between _Tags -HTML Tag = _HTML Tag -Double Quote = _Double Quote -Single Quote = _Single Quote -Parenthesis = _Parenthesis -Bracket = _Bracket -Brace = B_race -Word = _Word -Line = _Line -Paragraph = Para_graph -Indented Block = _Indented Block -Scope = S_cope +Select = _Select +Select between XML Tags = Select between _XML Tags +Select in XML Tag = Select in XML _Tag +Select in Double Quotes = Select in _Double Quotes +Select in Single Quotes = Select in _Single Quotes +Select in Parentheses = Select in _Parentheses +Select in Brackets = Select in _Brackets +Select in Braces = Select in B_races +Select Word = Select _Word +Select Line = Select _Line +Select Paragraph = Select Para_graph +Select Indented Block = Select _Indented Block +Select Style = Select St_yle Search = _Search gtk-find = gtk-find %Find Next = Find _Next @@ -158,24 +157,25 @@ Goto Previous File Found = Goto Previous File Found gtk-jump-to = gtk-jump-to Tools = _Tools Command Entry = Command _Entry +Select Command = Select Co_mmand Run = _Run Compile = _Compile Filter Through = Fi_lter Through Snippets = _Snippets -Expand = _Expand -Insert... = _Insert... -Previous Placeholder = _Previous Placeholder -Cancel = _Cancel +Insert Snippet... = _Insert Snippet... +Expand Snippet/Next Placeholder = _Expand Snippet/Next Placeholder +Previous Snippet Placeholder = _Previous Snippet Placeholder +Cancel Snippet = _Cancel Snippet Bookmark = _Bookmark -Toggle on Current Line = _Toggle on Current Line -Clear All = _Clear All -Next = _Next -Previous = _Previous +Toggle Bookmark = _Toggle Bookmark +Clear Bookmarks = _Clear Bookmarks +Next Bookmark = _Next Bookmark +Previous Bookmark = _Previous Bookmark Goto Bookmark... = _Goto Bookmark... Snapopen = Snap_open -User Home = _User Home -Textadept Home = _Textadept Home -Current Directory = _Current Directory +Snapopen User Home = Snapopen _User Home +Snapopen Textadept Home = Snapopen _Textadept Home +Snapopen Current Directory = Snapopen _Current Directory Show Style = Show St_yle Buffer = _Buffer Next Buffer = _Next Buffer @@ -188,36 +188,43 @@ Toggle Use Tabs = Toggle Use _Tabs Toggle View Whitespace = Toggle View White_space Toggle Virtual Space = Toggle _Virtual Space Indentation = _Indentation +Tab width: 2 = Tab width: _2 +Tab width: 3 = Tab width: _3 +Tab width: 4 = Tab width: _4 +Tab width: 8 = Tab width: _8 EOL Mode = EOL _Mode %CRLF = CRLF %CR = CR %LF = LF Encoding = En_coding -UTF-8 = UTF-8 -ASCII = ASCII -ISO-8859-1 = ISO-8859-1 -MacRoman = MacRoman -UTF-16 = UTF-16 +UTF-8 Encoding = UTF-8 Encoding +ASCII Encoding = ASCII Encoding +ISO-8859-1 Encoding = ISO-8859-1 Encoding +MacRoman Encoding = MacRoman Encoding +UTF-16 Encoding = UTF-16 Encoding Refresh Syntax Highlighting = _Refresh Syntax Highlighting Select Lexer... = Select _Lexer... View = _View Next View = _Next View Previous View = _Previous View -Split Vertical = Split _Vertical -Split Horizontal = Split _Horizontal -Unsplit = _Unsplit -Unsplit All = Unsplit _All +Split View Vertical = Split View _Vertical +Split View Horizontal = Split View _Horizontal +Unsplit View = _Unsplit View +Unsplit All Views = Unsplit _All Views Grow View = _Grow View Shrink View = _Shrink View Zoom In = Zoom _In Zoom Out = Zoom _Out Reset Zoom = _Reset Zoom Help = _Help -Manual = _Manual -LuaDoc = _LuaDoc +Show Manual = Show _Manual +Show LuaDoc = Show _LuaDoc gtk-about = gtk-about Lexers = _Lexers Unknown command: = Unknown command: +Run Command = Run Command +Command = Command +Key Command = Key Command % modules/textadept/mime_types.lua Select Lexer = Select Lexer |