diff options
author | 2011-01-23 23:01:02 -0500 | |
---|---|---|
committer | 2011-01-23 23:01:02 -0500 | |
commit | 2d850989a2f3b6f5a8b16c64179ab394c9f0c332 (patch) | |
tree | 491b995f7652b7be3d88a2fb7c74719cf3872b13 | |
parent | 1c1e627ec05dd898bbd97f0e0cde055f34ff0f36 (diff) | |
download | textadept-2d850989a2f3b6f5a8b16c64179ab394c9f0c332.tar.gz textadept-2d850989a2f3b6f5a8b16c64179ab394c9f0c332.zip |
Send key modifiers to command_entry_keypress event.
-rw-r--r-- | core/.command_entry.luadoc | 7 | ||||
-rw-r--r-- | src/textadept.c | 14 |
2 files changed, 13 insertions, 8 deletions
diff --git a/core/.command_entry.luadoc b/core/.command_entry.luadoc index cfc33b36..d26da77a 100644 --- a/core/.command_entry.luadoc +++ b/core/.command_entry.luadoc @@ -19,9 +19,14 @@ module('gui.command_entry') -- * **command\_entry\_command** (command)<br /> -- Called when a command is entered into the Command Entry. -- - command: the string command. --- * **command\_entry\_keypress** (code)<br /> +-- * **command\_entry\_keypress** (code, shift, control, alt)<br /> -- Called when a key is pressed in the Command Entry. -- - code: the key code (according to `<gdk/gdkkeysyms.h>`). +-- - shift: flag indicating whether or not the Shift key is pressed. +-- - control: flag indicating whether or not the Control key is pressed. +-- - alt: flag indicating whether or not the Alt/Apple key is pressed. +-- <br /> +-- Note: The Alt-Option key in Mac OSX is not available. --- Focuses the command entry. function focus() end diff --git a/src/textadept.c b/src/textadept.c index 4bb1eb13..ef8516d3 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -36,6 +36,11 @@ lua_pushcfunction(l, f); \ lua_setfield(l, -2, k); \ } +#define l_emit_event_key(name, event) \ + l_emit_event(name, LUA_TNUMBER, event->keyval, LUA_TBOOLEAN, \ + event->state & GDK_SHIFT_MASK, LUA_TBOOLEAN, \ + event->state & GDK_CONTROL_MASK, LUA_TBOOLEAN, \ + event->state & GDK_MOD1_MASK, -1) #define l_mt(l, k, i, ni) { \ if (luaL_newmetatable(l, k)) { \ l_cfunc(l, i, "__index"); \ @@ -509,12 +514,7 @@ static void s_command(GtkWidget *editor, gint wParam, gpointer lParam, * Collects the modifier states as flags and calls Lua to handle the keypress. */ static gbool s_keypress(GtkWidget *editor, GdkEventKey *event, gpointer udata) { - return l_emit_event("keypress", - LUA_TNUMBER, event->keyval, - LUA_TBOOLEAN, event->state & GDK_SHIFT_MASK, - LUA_TBOOLEAN, event->state & GDK_CONTROL_MASK, - LUA_TBOOLEAN, event->state & GDK_MOD1_MASK, - -1) ? TRUE : FALSE; + return l_emit_event_key("keypress", event) ? TRUE : FALSE; } /** @@ -817,7 +817,7 @@ static void c_activated(GtkWidget *entry, gpointer udata) { * Signal for a keypress inside the Command Entry. */ static gbool c_keypress(GtkWidget *entry, GdkEventKey *event, gpointer udata) { - return l_emit_event("command_entry_keypress", LUA_TNUMBER, event->keyval, -1); + return l_emit_event_key("command_entry_keypress", event); } /******************************************************************************/ |