From 317bca1fd4cdc3fd4b61990a308526358a2fac7d Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Thu, 15 Jan 2015 23:01:19 -0500 Subject: 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. --- core/ui.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'core/ui.lua') 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. -- cgit v1.2.3