diff options
-rw-r--r-- | core/ext/key_commands.lua | 3 | ||||
-rw-r--r-- | core/ext/key_commands_std.lua | 3 | ||||
-rw-r--r-- | modules/cpp/commands.lua | 1 | ||||
-rw-r--r-- | modules/lua/commands.lua | 1 | ||||
-rw-r--r-- | modules/textadept/editing.lua | 17 |
5 files changed, 21 insertions, 4 deletions
diff --git a/core/ext/key_commands.lua b/core/ext/key_commands.lua index 3af58a59..f9c108db 100644 --- a/core/ext/key_commands.lua +++ b/core/ext/key_commands.lua @@ -6,7 +6,7 @@ module('textadept.key_commands', package.seeall) --[[ - C: G Q + C: G A: A C G J K L O Q W X Z CS: C D G J L Q R S T U W SA: A C D E G H I J K L M O Q R S T W X Z @@ -122,6 +122,7 @@ keys.csm = { m_editing.match_brace, 'select' } keys['c '] = { m_editing.autocomplete_word, '%w_' } keys['a '] = { m_editing.autocomplete_word_from_dict, '/usr/share/dict/cracklib-small' } +keys.cq = { m_editing.block_comment } keys.cl = { m_editing.goto_line } keys.ck = { m_editing.smart_cutcopy, } keys.csk = { m_editing.smart_cutcopy, 'copy' } diff --git a/core/ext/key_commands_std.lua b/core/ext/key_commands_std.lua index e73b6ce2..a8f730dd 100644 --- a/core/ext/key_commands_std.lua +++ b/core/ext/key_commands_std.lua @@ -7,7 +7,7 @@ module('textadept.key_commands_std', package.seeall) --[[ - C: B D H J K L Q R U + C: B D H J K L R U A: A B C D E F G H J K L M N P Q R S T U V W X Y Z CS: A B C D F G H J K L M N O Q R T U V X Y Z SA: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @@ -56,6 +56,7 @@ local m_editing = _m.textadept.editing keys.ce = { m_editing.match_brace } keys.cse = { m_editing.match_brace, 'select' } keys['c\n'] = { m_editing.autocomplete_word, '%w_' } +keys.cq = { m_editing.block_comment } -- TODO: { m_editing.current_word, 'delete' } -- TODO: { m_editing.transpose_chars } -- TODO: { m_editing.squeeze } diff --git a/modules/cpp/commands.lua b/modules/cpp/commands.lua index 4b35fcac..db4197c5 100644 --- a/modules/cpp/commands.lua +++ b/modules/cpp/commands.lua @@ -15,7 +15,6 @@ if type(keys) == 'table' then buffer:add_text(';') buffer:new_line() end }, - cq = { m_editing.block_comment, '//~' }, ['('] = { function() m_editing.show_call_tip(_m.cpp.api, true) return false diff --git a/modules/lua/commands.lua b/modules/lua/commands.lua index 96bac9ab..1b4ff90e 100644 --- a/modules/lua/commands.lua +++ b/modules/lua/commands.lua @@ -79,7 +79,6 @@ if type(keys) == 'table' then g = { goto_required } }, ['s\n'] = { try_to_autocomplete_end }, - cq = { m_editing.block_comment, '--~' }, cg = { run }, ['('] = { function() buffer.word_chars = diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index 3609aa34..9251a507 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -55,6 +55,19 @@ local enclosure = { single_tag = { left = '<', right = ' />' } } +--- +-- [Local table] Comment strings for various lexer languages. +-- Used for the block_comment function. +-- @class table +-- @name comment_strings +-- @see block_comment +local comment_strings = { + cpp = '//~', + lua = '--~', + python = '#~', + ruby = '#~', +} + textadept.events.add_handler('char_added', function(c) -- matches characters specified in char_matches if char_matches[c] then @@ -191,6 +204,10 @@ textadept.events.add_handler('call_tip_click', -- each line in the selection. function block_comment(comment) local buffer = buffer + if not comment then + comment = comment_strings[ buffer:get_lexer_language() ] + if not comment then return end + end local caret, anchor = buffer.current_pos, buffer.anchor if caret < anchor then anchor, caret = caret, anchor end local s = buffer:line_from_position(anchor) |