aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/events.lua9
-rw-r--r--core/ui.lua4
2 files changed, 12 insertions, 1 deletions
diff --git a/core/events.lua b/core/events.lua
index 849c4302..dcaf5716 100644
--- a/core/events.lua
+++ b/core/events.lua
@@ -218,6 +218,13 @@ local M = {}
-- Emitted when suspending Textadept. If any handler returns `true`, Textadept
-- does not suspend.
-- This event is only emitted by the terminal version.
+-- @field TAB_CLICKED (string)
+-- Emitted when the user clicks on a buffer tab.
+-- When connecting to this event, connect with an index of 1 if the handler
+-- needs to run before Textadept switches between buffers.
+-- Arguments:
+--
+-- * _`index`_: The numeric index of the clicked tab.
-- @field UPDATE_UI (string)
-- Emitted after the view is visually updated.
-- Arguments:
@@ -366,7 +373,7 @@ local textadept_events = {
'buffer_deleted', 'buffer_new', 'csi', 'error', 'find', 'focus',
'initialized', 'keypress', 'menu_clicked', 'mouse', 'quit', 'replace',
'replace_all', 'reset_after', 'reset_before', 'resume', 'suspend',
- 'view_after_switch', 'view_before_switch', 'view_new'
+ 'tab_clicked', 'view_after_switch', 'view_before_switch', 'view_new'
}
for _, e in pairs(textadept_events) do M[e:upper()] = e end
diff --git a/core/ui.lua b/core/ui.lua
index a30b5e7a..06d68776 100644
--- a/core/ui.lua
+++ b/core/ui.lua
@@ -302,6 +302,10 @@ events_connect(events.BUFFER_NEW, function()
buffer:private_lexer_call(SETLEXERLANGUAGE, 'text')
end)
+-- Switches between buffers when a tab is clicked.
+events_connect(events.TAB_CLICKED,
+ function(index) view:goto_buffer(_BUFFERS[index]) end)
+
-- Sets the title of the Textadept window to the buffer's filename.
local function set_title()
local filename = buffer.filename or buffer._type or _L['Untitled']