OS X Leopard, it turns out, has a new and exciting strategy for
[sgt/putty] / unix / gtkwin.c
index 430e2b5..d31037b 100644 (file)
@@ -663,13 +663,12 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
            end = 2;
        }
 
-       /* Control-Break is the same as Control-C */
+       /* Control-Break sends a Break special to the backend */
        if (event->keyval == GDK_Break &&
            (event->state & GDK_CONTROL_MASK)) {
-           output[1] = '\003';
-           use_ucsoutput = FALSE;
-           end = 2;
-           special = TRUE;
+           if (inst->back)
+               inst->back->special(inst->backhandle, TS_BRK);
+           return TRUE;
        }
 
        /* We handle Return ourselves, because it needs to be flagged as
@@ -724,6 +723,13 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
            end = 1 + sprintf(output+1, "\033[Z");
            use_ucsoutput = FALSE;
        }
+       /* And normal Tab is Tab, if the keymap hasn't already told us.
+        * (Curiously, at least one version of the MacOS 10.5 X server
+        * doesn't translate Tab for us. */
+       if (event->keyval == GDK_Tab && end <= 1) {
+           output[1] = '\t';
+           end = 2;
+       }
 
        /*
         * NetHack keypad mode.
@@ -1435,7 +1441,7 @@ void palette_reset(void *frontend)
            int r = i / 36, g = (i / 6) % 6, b = i % 6;
            inst->cols[i+16].red = r ? r * 0x2828 + 0x3737 : 0;
            inst->cols[i+16].green = g ? g * 0x2828 + 0x3737 : 0;
-           inst->cols[i+16].blue = b ? b + 0x2828 + 0x3737 : 0;
+           inst->cols[i+16].blue = b ? b * 0x2828 + 0x3737 : 0;
        } else {
            int shade = i - 216;
            shade = shade * 0x0a0a + 0x0808;
@@ -1868,7 +1874,7 @@ void sys_cursor(void *frontend, int x, int y)
  */
 void do_beep(void *frontend, int mode)
 {
-    if (mode != BELL_VISUAL)
+    if (mode == BELL_DEFAULT)
        gdk_beep();
 }
 
@@ -2409,7 +2415,7 @@ static void help(FILE *fp) {
     }
 }
 
-int do_cmdline(int argc, char **argv, int do_everything,
+int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
                struct gui_data *inst, Config *cfg)
 {
     int err = 0;
@@ -2615,7 +2621,8 @@ int do_cmdline(int argc, char **argv, int do_everything,
             exit(1);
 
        } else if(p[0] != '-' && (!do_everything ||
-                                  process_nonoption_arg(p, cfg))) {
+                                  process_nonoption_arg(p, cfg,
+                                                       allow_launch))) {
             /* do nothing */
 
        } else {
@@ -3478,15 +3485,23 @@ int pt_main(int argc, char **argv)
        /* Splatter this argument so it doesn't clutter a ps listing */
        memset(argv[1], 0, strlen(argv[1]));
     } else {
-       if (do_cmdline(argc, argv, 0, inst, &inst->cfg))
+       /* By default, we bring up the config dialog, rather than launching
+        * a session. This gets set to TRUE if something happens to change
+        * that (e.g., a hostname is specified on the command-line). */
+       int allow_launch = FALSE;
+       if (do_cmdline(argc, argv, 0, &allow_launch, inst, &inst->cfg))
            exit(1);                   /* pre-defaults pass to get -class */
        do_defaults(NULL, &inst->cfg);
-       if (do_cmdline(argc, argv, 1, inst, &inst->cfg))
+       if (do_cmdline(argc, argv, 1, &allow_launch, inst, &inst->cfg))
            exit(1);                   /* post-defaults, do everything */
 
        cmdline_run_saved(&inst->cfg);
 
-       if (!cfg_launchable(&inst->cfg) && !cfgbox(&inst->cfg))
+       if (loaded_session)
+           allow_launch = TRUE;
+
+       if ((!allow_launch || !cfg_launchable(&inst->cfg)) &&
+           !cfgbox(&inst->cfg))
            exit(0);                   /* config box hit Cancel */
     }