Centralise generation of the control sequences for arrow keys into a
[u/mdw/putty] / unix / gtkwin.c
index ff6e80c..93e96da 100644 (file)
@@ -1052,19 +1052,8 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
              case GDK_Begin: case GDK_KP_Begin: xkey = 'G'; break;
            }
            if (xkey) {
-               /*
-                * The arrow keys normally do ESC [ A and so on. In
-                * app cursor keys mode they do ESC O A instead.
-                * Ctrl toggles the two modes.
-                */
-               if (inst->term->vt52_mode) {
-                   end = 1 + sprintf(output+1, "\033%c", xkey);
-               } else if (!inst->term->app_cursor_keys ^
-                          !(event->state & GDK_CONTROL_MASK)) {
-                   end = 1 + sprintf(output+1, "\033O%c", xkey);
-               } else {                    
-                   end = 1 + sprintf(output+1, "\033[%c", xkey);
-               }
+               end = 1 + format_arrow_key(output+1, inst->term, xkey,
+                                          event->state & GDK_CONTROL_MASK);
                use_ucsoutput = FALSE;
                goto done;
            }
@@ -1291,14 +1280,14 @@ void notify_remote_exit(void *frontend)
 
 static gint timer_trigger(gpointer data)
 {
-    long now = GPOINTER_TO_INT(data);
+    long now = GPOINTER_TO_SIZE(data);
     long next;
     long ticks;
 
     if (run_timers(now, &next)) {
        ticks = next - GETTICKCOUNT();
        timer_id = gtk_timeout_add(ticks > 0 ? ticks : 1, timer_trigger,
-                                  GINT_TO_POINTER(next));
+                                  GSIZE_TO_POINTER(next));
     }
 
     /*
@@ -1320,7 +1309,7 @@ void timer_change_notify(long next)
        ticks = 1;                     /* just in case */
 
     timer_id = gtk_timeout_add(ticks, timer_trigger,
-                              GINT_TO_POINTER(next));
+                              GSIZE_TO_POINTER(next));
 }
 
 void fd_input_func(gpointer data, gint sourcefd, GdkInputCondition condition)