Some minor cleanup
[rodin/chimara.git] / libchimara / input.c
index c740809a0f36c69a0b61e18f97bc5334ac8697de..648f44f03ae0a16c880071d433ec0093844ad123 100644 (file)
@@ -1,6 +1,7 @@
 #include "charset.h"
 #include "magic.h"
 #include "input.h"
+#include "pager.h"
 #include "chimara-glk-private.h"
 
 extern GPrivate *glk_data_key;
@@ -27,18 +28,6 @@ request_char_event_common(winid_t win, gboolean unicode)
        g_signal_handler_unblock( win->widget, win->char_input_keypress_handler );
 
        gdk_threads_enter();
-
-       /*
-       if(win->type == wintype_TextBuffer)
-       {
-               GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );
-               GtkTextIter iter;
-               gtk_text_buffer_get_end_iter(buffer, &iter);
-               gtk_text_buffer_place_cursor(buffer, &iter);
-               gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(win->widget), gtk_text_buffer_get_insert(buffer));
-               // Why doesn't this always work?? 
-       } */
-
        gtk_widget_grab_focus( GTK_WIDGET(win->widget) );
        gdk_threads_leave();
 
@@ -139,7 +128,11 @@ text_grid_request_line_event_common(winid_t win, glui32 maxlen, gboolean insert,
        /* Make the entry as small as possible to fit with the text */
        gtk_entry_set_has_frame(GTK_ENTRY(win->input_entry), FALSE);
        GtkBorder border = { 0, 0, 0, 0 };
+
+       /* COMPAT: */
+#if GTK_CHECK_VERSION(2,10,0)
        gtk_entry_set_inner_border(GTK_ENTRY(win->input_entry), &border);
+#endif
     gtk_entry_set_max_length(GTK_ENTRY(win->input_entry), win->input_length);
     gtk_entry_set_width_chars(GTK_ENTRY(win->input_entry), win->input_length);
 
@@ -193,9 +186,6 @@ text_buffer_request_line_event_common(winid_t win, glui32 maxlen, gboolean inser
                gtk_text_buffer_get_end_iter(buffer, &end_iter); /* update after text insertion */
        }
 
-    /* Scroll to input point */
-    gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(win->widget), input_position);
-
        /* Apply the correct style to the input prompt */
        GtkTextIter input_iter;
     gtk_text_buffer_get_iter_at_mark(buffer, &input_iter, input_position);
@@ -304,6 +294,8 @@ glk_request_line_event_uni(winid_t win, glui32 *buf, glui32 maxlen, glui32 initl
        if(glk_data->register_arr)
         win->buffer_rock = (*glk_data->register_arr)(buf, maxlen, "&+#!Iu");
 
+
+
        win->input_request_type = INPUT_REQUEST_LINE_UNICODE;
        win->line_input_buffer_unicode = buf;
        win->line_input_buffer_max_len = maxlen;
@@ -428,6 +420,15 @@ on_shutdown_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win)
 gboolean
 on_char_input_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win)
 {
+       /* Ignore modifier keys, otherwise the char input will already trigger on 
+       the shift key when the user tries to type a capital letter */
+       if(event->is_modifier)
+               return FALSE; /* don't stop the event */
+
+       /* All text up to the input position is now regarded as being read by the user */
+       if(win->type == wintype_TextBuffer)
+               pager_update(win);
+       
        glui32 keycode = keyval_to_glk_keycode(event->keyval, win->input_request_type == INPUT_REQUEST_CHARACTER_UNICODE);
 
        ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(widget, CHIMARA_TYPE_GLK));
@@ -448,6 +449,8 @@ on_line_input_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win
        switch(win->type)
        {
                case wintype_TextBuffer:
+                       /* All text up to the input position is now regarded as being read by the user */
+                       pager_update(win);
 
                        /* History up/down */
                        if(event->keyval == GDK_Up || event->keyval == GDK_KP_Up