From 363a3420d1eef11e753860d431912e2f8e4bea1a Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Mon, 21 Jul 2008 18:31:30 -0400 Subject: Moved block comment key commands from language modules to _m.textadept.editing. --- modules/textadept/editing.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'modules/textadept/editing.lua') 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) -- cgit v1.2.3