Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rectangular selection for Textadept
-- Rectangular selection
-- Add the following to your init.lua
keys.ar = { function()
local events = events
local gui = gui
local KEYSYMS = _m.textadept.keys.KEYSYMS
gui.statusbar_text = 'Rectangular selection'
events.emit('update_ui')
rselect = events.connect('keypress',
function(code, shift, control, alt)
if alt and KEYSYMS[code] == 'left' then
buffer:char_left_rect_extend()
return true
elseif alt and KEYSYMS[code] == 'up' then
buffer:line_up_rect_extend()
return true
elseif alt and KEYSYMS[code] == 'right' then
buffer:char_right_rect_extend()
return true
elseif alt and KEYSYMS[code] == 'down' then
buffer:line_down_rect_extend()
return true
else
events.disconnect('keypress', rselect)
gui.statusbar_text = ''
events.emit('update_ui')
return
end
end, 1)
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment