Also trigger the "command" signal on char input
authorPhilip Chimento <philip.chimento@gmail.com>
Tue, 11 Jan 2011 07:37:00 +0000 (02:37 -0500)
committerPhilip Chimento <philip.chimento@gmail.com>
Tue, 11 Jan 2011 07:37:00 +0000 (02:37 -0500)
Character input should also trigger the ChimaraIF::command signal.

libchimara/chimara-if.c

index efbd5297c41dcd008fc874da3c4e2e1f59db7c85..4e8c1d9490b4fcbc38f0e471703a2fcc35fd5c29 100644 (file)
@@ -125,6 +125,17 @@ chimara_if_stopped(ChimaraGlk *glk)
        priv->interpreter = CHIMARA_IF_INTERPRETER_NONE;
 }
 
+static void
+chimara_if_char_input(ChimaraGlk *glk, guint32 win_rock, guint keysym)
+{
+       CHIMARA_IF_USE_PRIVATE(glk, priv);
+       g_assert(priv->input == NULL);
+
+       gchar outbuf[6];
+       gint outbuflen = g_unichar_to_utf8(gdk_keyval_to_unicode(keysym), outbuf);
+       priv->input = g_strndup(outbuf, outbuflen);
+}
+
 static void
 chimara_if_line_input(ChimaraGlk *glk, guint32 win_rock, gchar *input)
 {
@@ -161,6 +172,7 @@ chimara_if_init(ChimaraIF *self)
        /* Connect to signals of ChimaraGlk parent */
        g_signal_connect(self, "stopped", G_CALLBACK(chimara_if_stopped), NULL);
        g_signal_connect(self, "waiting", G_CALLBACK(chimara_if_waiting), NULL);
+       g_signal_connect(self, "char-input", G_CALLBACK(chimara_if_char_input), NULL);
        g_signal_connect(self, "line-input", G_CALLBACK(chimara_if_line_input), NULL);
        g_signal_connect(self, "text-buffer-output", G_CALLBACK(chimara_if_text_buffer_output), NULL);
 }