aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2014-06-20 12:02:35 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2014-06-20 12:02:35 -0400
commit5b292b2408f24479b8ce5eb4d8a295a559bf8481 (patch)
treed39e8eda6d4f5dc2bcf741b0fd3c5492b2ce20f3
parenta9f6d85ead8c83ce210e5ffb05f84361e029f419 (diff)
downloadtextadept-5b292b2408f24479b8ce5eb4d8a295a559bf8481.tar.gz
textadept-5b292b2408f24479b8ce5eb4d8a295a559bf8481.zip
Added `event.FOCUS` for when Textadept's window receives focus.
-rw-r--r--core/events.lua5
-rw-r--r--core/file_io.lua1
-rw-r--r--src/textadept.c2
3 files changed, 6 insertions, 2 deletions
diff --git a/core/events.lua b/core/events.lua
index f4f520c5..a79be38b 100644
--- a/core/events.lua
+++ b/core/events.lua
@@ -118,6 +118,9 @@ local M = {}
--
-- * _`text`_: The text to search for.
-- * _`next`_: Whether or not to search forward.
+-- @field FOCUS (string)
+-- Emitted when Textadept receives focus.
+-- 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.
@@ -376,7 +379,7 @@ for _, n in pairs(scnotifications) do M[n[1]:upper()] = n[1] end
local ta_events = {
'appleevent_odoc', 'buffer_after_switch', 'buffer_before_switch',
'buffer_deleted', 'buffer_new', 'command_entry_command',
- 'command_entry_keypress', 'error', 'find', 'initialized', 'keypress',
+ 'command_entry_keypress', 'error', 'find', 'focus', 'initialized', 'keypress',
'menu_clicked', 'quit', 'replace', 'replace_all', 'reset_after',
'reset_before', 'view_after_switch', 'view_before_switch', 'view_new'
}
diff --git a/core/file_io.lua b/core/file_io.lua
index 7ddfee00..eb91ed2a 100644
--- a/core/file_io.lua
+++ b/core/file_io.lua
@@ -305,6 +305,7 @@ local function update_modified_file()
end
events_connect(events.BUFFER_AFTER_SWITCH, update_modified_file)
events_connect(events.VIEW_AFTER_SWITCH, update_modified_file)
+events_connect(events.FOCUS, update_modified_file)
-- Prompts the user to reload the current file if it has been externally
-- modified.
diff --git a/src/textadept.c b/src/textadept.c
index bbf86d98..31959e2c 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -1687,7 +1687,7 @@ static int lL_init(lua_State *L, int argc, char **argv, int reinit) {
static int w_focus(GtkWidget*_, GdkEventFocus*__, void*___) {
if (focused_view && !gtk_widget_has_focus(focused_view))
gtk_widget_grab_focus(focused_view);
- return FALSE;
+ return (lL_event(lua, "focus", -1), FALSE);
}
/** Signal for a Textadept keypress. */