diff options
author | 2015-01-15 23:01:19 -0500 | |
---|---|---|
committer | 2015-01-15 23:01:19 -0500 | |
commit | 317bca1fd4cdc3fd4b61990a308526358a2fac7d (patch) | |
tree | 94ef07a8653c7ac17c72c2a3a53e74377c3fcdaf /core/ui.lua | |
parent | 14ee3e0bf143916f29b2fb05465b9e79707f4611 (diff) | |
download | textadept-317bca1fd4cdc3fd4b61990a308526358a2fac7d.tar.gz textadept-317bca1fd4cdc3fd4b61990a308526358a2fac7d.zip |
Added events for terminal suspend and resume.
Suspend can be prevented by an error handler, described in a new FAQ entry.
New `events.RESUME` replaces `events.FOCUS` for the terminal version.
Utilize these events to disable/enable bracketed paste and mouse modes.
Diffstat (limited to 'core/ui.lua')
-rw-r--r-- | core/ui.lua | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/core/ui.lua b/core/ui.lua index 46e1c311..6b6e91fc 100644 --- a/core/ui.lua +++ b/core/ui.lua @@ -402,8 +402,24 @@ events_connect(events.BUFFER_DELETED, function() if i and _BUFFERS[buffer] ~= i then view:goto_buffer(i) end end) --- Focuses and resizes views based on mouse events in curses. +-- Enables and disables mouse mode in curses and focuses and resizes views based +-- on mouse events. if CURSES then + if not WIN32 then + local function enable_mouse_mode() + io.stdout:write("\x1b[?1002h") + io.stdout:flush() + end + enable_mouse_mode() + local function disable_mouse_mode() + io.stdout:write("\x1b[?1002l") -- disable mouse mode + io.stdout:flush() + end + events.connect(events.SUSPEND, disable_mouse_mode) + events.connect(events.RESUME, enable_mouse_mode) + events.connect(events.QUIT, disable_mouse_mode) + end + -- Retrieves the view or split at the given terminal coordinates. -- @param view View or split to test for coordinates within. -- @param y The y terminal coordinate. |