First attempt at a Unix port of Plink. Seems to basically work;
[u/mdw/putty] / unix / pterm.c
index 947e441..cc45962 100644 (file)
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
+#include <gdk/gdkx.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
 
 #define PUTTY_DO_GLOBALS              /* actually _define_ globals */
 #include "putty.h"
@@ -68,6 +69,13 @@ struct draw_ctx {
 
 static int send_raw_mouse;
 
+static char *app_name = "pterm";
+
+char *x_get_default(char *key)
+{
+    return XGetDefault(GDK_DISPLAY(), app_name, key);
+}
+
 void ldisc_update(void *frontend, int echo, int edit)
 {
     /*
@@ -1332,9 +1340,16 @@ void sys_cursor(void *frontend, int x, int y)
      */
 }
 
+/*
+ * This is still called when mode==BELL_VISUAL, even though the
+ * visual bell is handled entirely within terminal.c, because we
+ * may want to perform additional actions on any kind of bell (for
+ * example, taskbar flashing in Windows).
+ */
 void beep(void *frontend, int mode)
 {
-    gdk_beep();
+    if (mode != BELL_VISUAL)
+       gdk_beep();
 }
 
 int CharWidth(Context ctx, int uc)
@@ -1719,7 +1734,32 @@ char *get_x_display(void *frontend)
     return gdk_get_display();
 }
 
-char *app_name = "pterm";
+static void help(FILE *fp) {
+    if(fprintf(fp,
+"pterm option summary:\n"
+"\n"
+"  --display DISPLAY         Specify X display to use (note '--')\n"
+"  -name PREFIX              Prefix when looking up resources (default: pterm)\n"
+"  -fn FONT                  Normal text font\n"
+"  -fb FONT                  Bold text font\n"
+"  -geometry WIDTHxHEIGHT    Size of terminal in characters\n"
+"  -sl LINES                 Number of lines of scrollback\n"
+"  -fg COLOUR, -bg COLOUR    Foreground/background colour\n"
+"  -bfg COLOUR, -bbg COLOUR  Foreground/background bold colour\n"
+"  -cfg COLOUR, -bfg COLOUR  Foreground/background cursor colour\n"
+"  -T TITLE                  Window title\n"
+"  -ut, +ut                  Do(default) or do not update utmp\n"
+"  -ls, +ls                  Do(default) or do not make shell a login shell\n"
+"  -sb, +sb                  Do(default) or do not display a scrollbar\n"
+"  -log PATH                 Log all output to a file\n"
+"  -nethack                  Map numeric keypad to hjklyubn direction keys\n"
+"  -xrm RESOURCE-STRING      Set an X resource\n"
+"  -e COMMAND [ARGS...]      Execute command (consumes all remaining args)\n"
+        ) < 0 || fflush(fp) < 0) {
+       perror("output error");
+       exit(1);
+    }
+}
 
 int do_cmdline(int argc, char **argv, int do_everything)
 {
@@ -1874,6 +1914,10 @@ int do_cmdline(int argc, char **argv, int do_everything)
            EXPECTS_ARG;
            provide_xrm_string(val);
 
+       } else if(!strcmp(p, "-help") || !strcmp(p, "--help")) {
+           help(stdout);
+           exit(0);
+           
        } else {
            err = 1;
            fprintf(stderr, "pterm: unrecognized option '%s'\n", p);