aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2007-11-08 15:01:36 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2007-11-08 15:01:36 -0500
commit0853e00683b88605ba19598de2389bd391e0e9eb (patch)
treeca065f21dbc11e6a766cb8aeb1fd22ba05b81fc0
parentf112c01cd195685b2dfa9758e9d34b4444fe4926 (diff)
downloadtextadept-0853e00683b88605ba19598de2389bd391e0e9eb.tar.gz
textadept-0853e00683b88605ba19598de2389bd391e0e9eb.zip
Moved GTK/GDK keypress mask logic from lua_interface.c to textadept.c.
-rw-r--r--src/lua_interface.c8
-rw-r--r--src/textadept.c5
-rw-r--r--src/textadept.h2
3 files changed, 9 insertions, 6 deletions
diff --git a/src/lua_interface.c b/src/lua_interface.c
index 7f757d0a..ba6de56d 100644
--- a/src/lua_interface.c
+++ b/src/lua_interface.c
@@ -428,12 +428,12 @@ bool l_handle_event(const char *s, const char *arg) {
return l_call_function(1, 1);
}
-bool l_handle_keypress(int keyval, GdkEventKey *event) {
+bool l_handle_keypress(int keyval, bool shift, bool control, bool alt) {
if (!l_is_ta_table_function("events", "keypress")) return false;
lua_pushinteger(lua, keyval);
- lua_pushboolean(lua, (event->state & GDK_SHIFT_MASK) > 0 ? 1 : 0);
- lua_pushboolean(lua, (event->state & GDK_CONTROL_MASK) > 0 ? 1 : 0);
- lua_pushboolean(lua, (event->state & GDK_MOD1_MASK) > 0 ? 1 : 0);
+ lua_pushboolean(lua, shift);
+ lua_pushboolean(lua, control);
+ lua_pushboolean(lua, alt);
return l_call_function(4, 1);
}
diff --git a/src/textadept.c b/src/textadept.c
index ebe4666b..a2d8de70 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -275,7 +275,10 @@ static void t_command(GtkWidget *editor, gint wParam, gpointer, gpointer) {
}
static bool t_keypress(GtkWidget*, GdkEventKey *event, gpointer) {
- return l_handle_keypress(event->keyval, event);
+ bool shift = event->state & GDK_SHIFT_MASK;
+ bool control = event->state & GDK_CONTROL_MASK;
+ bool alt = event->state & GDK_MOD1_MASK;
+ return l_handle_keypress(event->keyval, shift, control, alt);
}
static bool w_focus(GtkWidget*, GdkEventFocus*, gpointer) {
diff --git a/src/textadept.h b/src/textadept.h
index 1b4344e9..af53d0f9 100644
--- a/src/textadept.h
+++ b/src/textadept.h
@@ -69,7 +69,7 @@ void l_set_buffer_global(ScintillaObject *sci);
void l_handle_error(lua_State *lua, const char *errmsg=0);
bool l_handle_event(const char *e);
bool l_handle_event(const char *e, const char *arg);
-bool l_handle_keypress(int keyval, GdkEventKey *event);
+bool l_handle_keypress(int keyval, bool shift, bool control, bool alt);
void l_handle_scnnotification(SCNotification *n);
void l_ta_command(const char *command);