aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/events.lua14
-rw-r--r--core/ui.lua18
2 files changed, 27 insertions, 5 deletions
diff --git a/core/events.lua b/core/events.lua
index 144917a7..6dedc879 100644
--- a/core/events.lua
+++ b/core/events.lua
@@ -119,8 +119,7 @@ local M = {}
-- * _`next`_: Whether or not to search forward.
-- @field FOCUS (string)
-- Emitted when Textadept receives focus.
--- In the terminal, this event is only emitted after resuming from a suspended
--- state.
+-- This event is never emitted when Textadept is running in the terminal.
-- @field HOTSPOT_CLICK (string)
-- Emitted when clicking on text that is in a style that has the hotspot
-- attribute set.
@@ -230,10 +229,17 @@ local M = {}
-- @field RESET_BEFORE (string)
-- Emitted before resetting the Lua state.
-- Emitted by [`reset()`]().
+-- @field RESUME (string)
+-- Emitted when resuming Textadept from a suspended state.
+-- This event is only emitted by the terminal version.
-- @field SAVE_POINT_LEFT (string)
-- Emitted after leaving a save point.
-- @field SAVE_POINT_REACHED (string)
-- Emitted after reaching a save point.
+-- @field SUSPEND (string)
+-- Emitted when suspending Textadept. If a handler returns `true`, Textadept
+-- does not suspend.
+-- This event is only emitted by the terminal version.
-- @field UPDATE_UI (string)
-- Emitted after the view is visually updated.
-- Arguments:
@@ -383,8 +389,8 @@ local ta_events = {
'appleevent_odoc', 'buffer_after_switch', 'buffer_before_switch',
'buffer_deleted', 'buffer_new', 'csi', 'error', 'find', 'focus',
'initialized', 'keypress', 'menu_clicked', 'mouse', 'quit', 'replace',
- 'replace_all', 'reset_after', 'reset_before', 'view_after_switch',
- 'view_before_switch', 'view_new'
+ 'replace_all', 'reset_after', 'reset_before', 'resume', 'suspend',
+ 'view_after_switch', 'view_before_switch', 'view_new'
}
for _, e in pairs(ta_events) do M[e:upper()] = e end
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.