aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/editing.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2014-10-18 21:14:14 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2014-10-18 21:14:14 -0400
commit322c18cfa38f060a7267d79d4562ab0df94cf30e (patch)
tree42e1ce310046bd38d252d6576d3640e66d36cf1f /modules/textadept/editing.lua
parent1a95f6cad42e99e477e2b1532f6a234b4b586006 (diff)
downloadtextadept-322c18cfa38f060a7267d79d4562ab0df94cf30e.tar.gz
textadept-322c18cfa38f060a7267d79d4562ab0df94cf30e.zip
Handle unknown CSI events and bracketed pasted in the terminal version.
For bracketed paste, turn off auto-pair and auto-indent.
Diffstat (limited to 'modules/textadept/editing.lua')
-rw-r--r--modules/textadept/editing.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua
index ce93dd54..cfc03f73 100644
--- a/modules/textadept/editing.lua
+++ b/modules/textadept/editing.lua
@@ -193,6 +193,27 @@ events.connect(events.CHAR_ADDED, function(char)
end
end)
+-- Enables and disables bracketed paste mode in curses and disables auto-pair
+-- and auto-indent while pasting.
+if CURSES and not WIN32 then
+ io.stdout:write('\x1b[?2004h') -- enable bracketed paste mode
+ io.stdout:flush()
+ events.connect(events.QUIT, function()
+ io.stdout:write('\x1b[?2004l') -- disable bracketed paste mode
+ io.stdout:flush()
+ end, 1)
+ local reenable_autopair, reenable_autoindent
+ events.connect('csi', function(cmd, args)
+ if cmd ~= string.byte('~') then return end
+ if args[1] == 200 then
+ reenable_autopair, M.AUTOPAIR = M.AUTOPAIR, false
+ reenable_autoindent, M.AUTOINDENT = M.AUTOINDENT, false
+ elseif args[1] == 201 then
+ M.AUTOPAIR, M.AUTOINDENT = reenable_autopair, reenable_autoindent
+ end
+ end)
+end
+
-- Prepares the buffer for saving to a file.
events.connect(events.FILE_BEFORE_SAVE, function()
if not M.STRIP_TRAILING_SPACES then return end