diff options
author | 2014-10-18 21:14:14 -0400 | |
---|---|---|
committer | 2014-10-18 21:14:14 -0400 | |
commit | 322c18cfa38f060a7267d79d4562ab0df94cf30e (patch) | |
tree | 42e1ce310046bd38d252d6576d3640e66d36cf1f /modules | |
parent | 1a95f6cad42e99e477e2b1532f6a234b4b586006 (diff) | |
download | textadept-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')
-rw-r--r-- | modules/textadept/editing.lua | 21 |
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 |