+ if (inst->cfg.bold_colour && (attr & ATTR_BOLD)) {
+ if (nfg < 16) nfg |= 8;
+ else if (nfg >= 256) nfg |= 1;
+ }
+ if (inst->cfg.bold_colour && (attr & ATTR_BLINK)) {
+ if (nbg < 16) nbg |= 8;
+ else if (nbg >= 256) nbg |= 1;
+ }
+ if (attr & TATTR_ACTCURS) {
+ nfg = 260;
+ nbg = 261;
+ }
+
+ fontid = shadow = 0;
+
+ if (attr & ATTR_WIDE) {
+ widefactor = 2;
+ fontid |= 2;
+ } else {
+ widefactor = 1;
+ }
+
+ if ((attr & ATTR_BOLD) && !inst->cfg.bold_colour) {
+ if (inst->fonts[fontid | 1])
+ fontid |= 1;
+ else
+ shadow = 1;
+ }
+
+ if ((lattr & LATTR_MODE) != LATTR_NORM) {
+ x *= 2;
+ if (x >= inst->term->cols)
+ return;
+ if (x + len*2*widefactor > inst->term->cols)
+ len = (inst->term->cols-x)/2/widefactor;/* trim to LH half */
+ rlen = len * 2;
+ } else
+ rlen = len;
+
+ {
+ GdkRectangle r;
+
+ r.x = x*inst->font_width+inst->cfg.window_border;
+ r.y = y*inst->font_height+inst->cfg.window_border;
+ r.width = rlen*widefactor*inst->font_width;
+ r.height = inst->font_height;
+ gdk_gc_set_clip_rectangle(gc, &r);
+ }
+
+ gdk_gc_set_foreground(gc, &inst->cols[nbg]);
+ gdk_draw_rectangle(inst->pixmap, gc, 1,
+ x*inst->font_width+inst->cfg.window_border,
+ y*inst->font_height+inst->cfg.window_border,
+ rlen*widefactor*inst->font_width, inst->font_height);
+
+ gdk_gc_set_foreground(gc, &inst->cols[nfg]);
+ {
+ GdkWChar *gwcs;
+ gchar *gcs;
+ wchar_t *wcs;
+ int i;
+
+ wcs = snewn(len*ncombining+1, wchar_t);
+ for (i = 0; i < len*ncombining; i++) {
+ wcs[i] = text[i];
+ }
+
+ if (inst->fonts[fontid] == NULL) {
+ /*
+ * The font for this contingency does not exist.
+ * Typically this means we've been given ATTR_WIDE
+ * character and have no wide font. So we display
+ * nothing at all; such is life.
+ */
+ } else if (inst->fontinfo[fontid].is_wide) {
+ /*
+ * At least one version of gdk_draw_text_wc() has a
+ * weird bug whereby it reads `len' elements of the
+ * input string, but only draws `len/2'. Hence I'm
+ * going to make its input array twice as long as it
+ * theoretically needs to be, and pass in twice the
+ * actual number of characters. If a fixed gdk actually
+ * takes the doubled length seriously, then (a) the
+ * array will stand scrutiny up to the full length, (b)
+ * the spare elements of the array are full of zeroes
+ * which will probably be an empty glyph in the font,
+ * and (c) the clip rectangle should prevent it causing
+ * trouble anyway.
+ */
+ gwcs = snewn(len*2+1, GdkWChar);
+ memset(gwcs, 0, sizeof(GdkWChar) * (len*2+1));
+ /*
+ * FIXME: when we have a wide-char equivalent of
+ * from_unicode, use it instead of this.
+ */
+ for (combining = 0; combining < ncombining; combining++) {
+ for (i = 0; i <= len; i++)
+ gwcs[i] = wcs[i + combining];
+ gdk_draw_text_wc(inst->pixmap, inst->fonts[fontid], gc,
+ x*inst->font_width+inst->cfg.window_border,
+ y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
+ gwcs, len*2);
+ if (shadow)
+ gdk_draw_text_wc(inst->pixmap, inst->fonts[fontid], gc,
+ x*inst->font_width+inst->cfg.window_border+inst->cfg.shadowboldoffset,
+ y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
+ gwcs, len*2);
+ }
+ sfree(gwcs);
+ } else {
+ gcs = snewn(len+1, gchar);
+ for (combining = 0; combining < ncombining; combining++) {
+ wc_to_mb(inst->fontinfo[fontid].charset, 0,
+ wcs + combining, len, gcs, len, ".", NULL, NULL);
+ gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc,
+ x*inst->font_width+inst->cfg.window_border,
+ y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
+ gcs, len);
+ if (shadow)
+ gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc,
+ x*inst->font_width+inst->cfg.window_border+inst->cfg.shadowboldoffset,
+ y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
+ gcs, len);
+ }
+ sfree(gcs);
+ }
+ sfree(wcs);
+ }
+
+ if (attr & ATTR_UNDER) {
+ int uheight = inst->fonts[0]->ascent + 1;
+ if (uheight >= inst->font_height)
+ uheight = inst->font_height - 1;
+ gdk_draw_line(inst->pixmap, gc, x*inst->font_width+inst->cfg.window_border,
+ y*inst->font_height + uheight + inst->cfg.window_border,
+ (x+len)*widefactor*inst->font_width-1+inst->cfg.window_border,
+ y*inst->font_height + uheight + inst->cfg.window_border);
+ }
+
+ if ((lattr & LATTR_MODE) != LATTR_NORM) {
+ /*
+ * I can't find any plausible StretchBlt equivalent in the
+ * X server, so I'm going to do this the slow and painful
+ * way. This will involve repeated calls to
+ * gdk_draw_pixmap() to stretch the text horizontally. It's
+ * O(N^2) in time and O(N) in network bandwidth, but you
+ * try thinking of a better way. :-(
+ */
+ int i;
+ for (i = 0; i < len * widefactor * inst->font_width; i++) {
+ gdk_draw_pixmap(inst->pixmap, gc, inst->pixmap,
+ x*inst->font_width+inst->cfg.window_border + 2*i,
+ y*inst->font_height+inst->cfg.window_border,
+ x*inst->font_width+inst->cfg.window_border + 2*i+1,
+ y*inst->font_height+inst->cfg.window_border,
+ len * widefactor * inst->font_width - i, inst->font_height);
+ }
+ len *= 2;
+ if ((lattr & LATTR_MODE) != LATTR_WIDE) {
+ int dt, db;
+ /* Now stretch vertically, in the same way. */
+ if ((lattr & LATTR_MODE) == LATTR_BOT)
+ dt = 0, db = 1;
+ else
+ dt = 1, db = 0;
+ for (i = 0; i < inst->font_height; i+=2) {
+ gdk_draw_pixmap(inst->pixmap, gc, inst->pixmap,
+ x*inst->font_width+inst->cfg.window_border,
+ y*inst->font_height+inst->cfg.window_border+dt*i+db,
+ x*inst->font_width+inst->cfg.window_border,
+ y*inst->font_height+inst->cfg.window_border+dt*(i+1),
+ len * widefactor * inst->font_width, inst->font_height-i-1);
+ }
+ }
+ }
+}
+
+void do_text(Context ctx, int x, int y, wchar_t *text, int len,
+ unsigned long attr, int lattr)
+{
+ struct draw_ctx *dctx = (struct draw_ctx *)ctx;
+ struct gui_data *inst = dctx->inst;
+ GdkGC *gc = dctx->gc;
+ int widefactor;
+
+ do_text_internal(ctx, x, y, text, len, attr, lattr);
+
+ if (attr & ATTR_WIDE) {
+ widefactor = 2;
+ } else {
+ widefactor = 1;
+ }
+
+ if ((lattr & LATTR_MODE) != LATTR_NORM) {
+ x *= 2;
+ if (x >= inst->term->cols)
+ return;
+ if (x + len*2*widefactor > inst->term->cols)
+ len = (inst->term->cols-x)/2/widefactor;/* trim to LH half */
+ len *= 2;
+ }
+
+ gdk_draw_pixmap(inst->area->window, gc, inst->pixmap,
+ x*inst->font_width+inst->cfg.window_border,
+ y*inst->font_height+inst->cfg.window_border,
+ x*inst->font_width+inst->cfg.window_border,
+ y*inst->font_height+inst->cfg.window_border,
+ len*widefactor*inst->font_width, inst->font_height);
+}
+
+void do_cursor(Context ctx, int x, int y, wchar_t *text, int len,
+ unsigned long attr, int lattr)
+{
+ struct draw_ctx *dctx = (struct draw_ctx *)ctx;
+ struct gui_data *inst = dctx->inst;
+ GdkGC *gc = dctx->gc;
+
+ int active, passive, widefactor;
+
+ if (attr & TATTR_PASCURS) {
+ attr &= ~TATTR_PASCURS;
+ passive = 1;
+ } else
+ passive = 0;
+ if ((attr & TATTR_ACTCURS) && inst->cfg.cursor_type != 0) {
+ attr &= ~TATTR_ACTCURS;
+ active = 1;
+ } else
+ active = 0;
+ do_text_internal(ctx, x, y, text, len, attr, lattr);
+
+ if (attr & TATTR_COMBINING)
+ len = 1;
+
+ if (attr & ATTR_WIDE) {
+ widefactor = 2;
+ } else {
+ widefactor = 1;
+ }
+
+ if ((lattr & LATTR_MODE) != LATTR_NORM) {
+ x *= 2;
+ if (x >= inst->term->cols)
+ return;
+ if (x + len*2*widefactor > inst->term->cols)
+ len = (inst->term->cols-x)/2/widefactor;/* trim to LH half */
+ len *= 2;
+ }
+
+ if (inst->cfg.cursor_type == 0) {
+ /*
+ * An active block cursor will already have been done by
+ * the above do_text call, so we only need to do anything
+ * if it's passive.
+ */
+ if (passive) {
+ gdk_gc_set_foreground(gc, &inst->cols[261]);
+ gdk_draw_rectangle(inst->pixmap, gc, 0,
+ x*inst->font_width+inst->cfg.window_border,
+ y*inst->font_height+inst->cfg.window_border,
+ len*widefactor*inst->font_width-1, inst->font_height-1);
+ }
+ } else {
+ int uheight;
+ int startx, starty, dx, dy, length, i;
+
+ int char_width;
+
+ if ((attr & ATTR_WIDE) || (lattr & LATTR_MODE) != LATTR_NORM)
+ char_width = 2*inst->font_width;
+ else
+ char_width = inst->font_width;
+
+ if (inst->cfg.cursor_type == 1) {
+ uheight = inst->fonts[0]->ascent + 1;
+ if (uheight >= inst->font_height)
+ uheight = inst->font_height - 1;
+
+ startx = x * inst->font_width + inst->cfg.window_border;
+ starty = y * inst->font_height + inst->cfg.window_border + uheight;
+ dx = 1;
+ dy = 0;
+ length = len * widefactor * char_width;
+ } else {
+ int xadjust = 0;
+ if (attr & TATTR_RIGHTCURS)
+ xadjust = char_width - 1;
+ startx = x * inst->font_width + inst->cfg.window_border + xadjust;
+ starty = y * inst->font_height + inst->cfg.window_border;
+ dx = 0;
+ dy = 1;
+ length = inst->font_height;
+ }
+
+ gdk_gc_set_foreground(gc, &inst->cols[261]);
+ if (passive) {
+ for (i = 0; i < length; i++) {
+ if (i % 2 == 0) {
+ gdk_draw_point(inst->pixmap, gc, startx, starty);
+ }
+ startx += dx;
+ starty += dy;
+ }
+ } else if (active) {
+ gdk_draw_line(inst->pixmap, gc, startx, starty,
+ startx + (length-1) * dx, starty + (length-1) * dy);
+ } /* else no cursor (e.g., blinked off) */
+ }
+
+ gdk_draw_pixmap(inst->area->window, gc, inst->pixmap,
+ x*inst->font_width+inst->cfg.window_border,
+ y*inst->font_height+inst->cfg.window_border,
+ x*inst->font_width+inst->cfg.window_border,
+ y*inst->font_height+inst->cfg.window_border,
+ len*widefactor*inst->font_width, inst->font_height);
+}
+
+GdkCursor *make_mouse_ptr(struct gui_data *inst, int cursor_val)
+{
+ /*
+ * Truly hideous hack: GTK doesn't allow us to set the mouse
+ * cursor foreground and background colours unless we've _also_
+ * created our own cursor from bitmaps. Therefore, I need to
+ * load the `cursor' font and draw glyphs from it on to
+ * pixmaps, in order to construct my cursors with the fg and bg
+ * I want. This is a gross hack, but it's more self-contained
+ * than linking in Xlib to find the X window handle to
+ * inst->area and calling XRecolorCursor, and it's more
+ * futureproof than hard-coding the shapes as bitmap arrays.
+ */
+ static GdkFont *cursor_font = NULL;
+ GdkPixmap *source, *mask;
+ GdkGC *gc;
+ GdkColor cfg = { 0, 65535, 65535, 65535 };
+ GdkColor cbg = { 0, 0, 0, 0 };
+ GdkColor dfg = { 1, 65535, 65535, 65535 };
+ GdkColor dbg = { 0, 0, 0, 0 };
+ GdkCursor *ret;
+ gchar text[2];
+ gint lb, rb, wid, asc, desc, w, h, x, y;
+
+ if (cursor_val == -2) {
+ gdk_font_unref(cursor_font);
+ return NULL;
+ }
+
+ if (cursor_val >= 0 && !cursor_font)
+ cursor_font = gdk_font_load("cursor");
+
+ /*
+ * Get the text extent of the cursor in question. We use the
+ * mask character for this, because it's typically slightly
+ * bigger than the main character.
+ */
+ if (cursor_val >= 0) {
+ text[1] = '\0';
+ text[0] = (char)cursor_val + 1;
+ gdk_string_extents(cursor_font, text, &lb, &rb, &wid, &asc, &desc);
+ w = rb-lb; h = asc+desc; x = -lb; y = asc;
+ } else {
+ w = h = 1;
+ x = y = 0;
+ }
+
+ source = gdk_pixmap_new(NULL, w, h, 1);
+ mask = gdk_pixmap_new(NULL, w, h, 1);
+
+ /*
+ * Draw the mask character on the mask pixmap.
+ */
+ gc = gdk_gc_new(mask);
+ gdk_gc_set_foreground(gc, &dbg);
+ gdk_draw_rectangle(mask, gc, 1, 0, 0, w, h);
+ if (cursor_val >= 0) {
+ text[1] = '\0';
+ text[0] = (char)cursor_val + 1;
+ gdk_gc_set_foreground(gc, &dfg);
+ gdk_draw_text(mask, cursor_font, gc, x, y, text, 1);
+ }
+ gdk_gc_unref(gc);
+
+ /*
+ * Draw the main character on the source pixmap.
+ */
+ gc = gdk_gc_new(source);
+ gdk_gc_set_foreground(gc, &dbg);
+ gdk_draw_rectangle(source, gc, 1, 0, 0, w, h);
+ if (cursor_val >= 0) {
+ text[1] = '\0';
+ text[0] = (char)cursor_val;
+ gdk_gc_set_foreground(gc, &dfg);
+ gdk_draw_text(source, cursor_font, gc, x, y, text, 1);
+ }
+ gdk_gc_unref(gc);
+
+ /*
+ * Create the cursor.
+ */
+ ret = gdk_cursor_new_from_pixmap(source, mask, &cfg, &cbg, x, y);
+
+ /*
+ * Clean up.
+ */
+ gdk_pixmap_unref(source);
+ gdk_pixmap_unref(mask);
+
+ return ret;
+}
+
+void modalfatalbox(char *p, ...)
+{
+ va_list ap;
+ fprintf(stderr, "FATAL ERROR: ");
+ va_start(ap, p);
+ vfprintf(stderr, p, ap);
+ va_end(ap);
+ fputc('\n', stderr);
+ exit(1);
+}
+
+void cmdline_error(char *p, ...)
+{
+ va_list ap;
+ fprintf(stderr, "%s: ", appname);
+ va_start(ap, p);
+ vfprintf(stderr, p, ap);
+ va_end(ap);
+ fputc('\n', stderr);
+ exit(1);
+}
+
+char *get_x_display(void *frontend)
+{
+ return gdk_get_display();
+}
+
+long get_windowid(void *frontend)
+{
+ struct gui_data *inst = (struct gui_data *)frontend;
+ return (long)GDK_WINDOW_XWINDOW(inst->area->window);
+}
+
+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 GEOMETRY Position and size of window (size 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,
+ struct gui_data *inst, Config *cfg)
+{
+ int err = 0;
+ char *val;
+
+ /*
+ * Macros to make argument handling easier. Note that because
+ * they need to call `continue', they cannot be contained in
+ * the usual do {...} while (0) wrapper to make them
+ * syntactically single statements; hence it is not legal to
+ * use one of these macros as an unbraced statement between
+ * `if' and `else'.
+ */
+#define EXPECTS_ARG { \
+ if (--argc <= 0) { \
+ err = 1; \
+ fprintf(stderr, "%s: %s expects an argument\n", appname, p); \
+ continue; \
+ } else \
+ val = *++argv; \
+}
+#define SECOND_PASS_ONLY { if (!do_everything) continue; }
+
+ while (--argc > 0) {
+ char *p = *++argv;
+ int ret;
+
+ /*
+ * Shameless cheating. Debian requires all X terminal
+ * emulators to support `-T title'; but
+ * cmdline_process_param will eat -T (it means no-pty) and
+ * complain that pterm doesn't support it. So, in pterm
+ * only, we convert -T into -title.
+ */
+ if ((cmdline_tooltype & TOOLTYPE_NONNETWORK) &&
+ !strcmp(p, "-T"))
+ p = "-title";
+
+ ret = cmdline_process_param(p, (argc > 1 ? argv[1] : NULL),
+ do_everything ? 1 : -1, cfg);
+
+ if (ret == -2) {
+ cmdline_error("option \"%s\" requires an argument", p);
+ } else if (ret == 2) {
+ --argc, ++argv; /* skip next argument */
+ continue;
+ } else if (ret == 1) {
+ continue;
+ }
+
+ if (!strcmp(p, "-fn") || !strcmp(p, "-font")) {
+ EXPECTS_ARG;
+ SECOND_PASS_ONLY;
+ strncpy(cfg->font.name, val, sizeof(cfg->font.name));
+ cfg->font.name[sizeof(cfg->font.name)-1] = '\0';
+
+ } else if (!strcmp(p, "-fb")) {
+ EXPECTS_ARG;
+ SECOND_PASS_ONLY;
+ strncpy(cfg->boldfont.name, val, sizeof(cfg->boldfont.name));
+ cfg->boldfont.name[sizeof(cfg->boldfont.name)-1] = '\0';
+
+ } else if (!strcmp(p, "-fw")) {
+ EXPECTS_ARG;
+ SECOND_PASS_ONLY;
+ strncpy(cfg->widefont.name, val, sizeof(cfg->widefont.name));
+ cfg->widefont.name[sizeof(cfg->widefont.name)-1] = '\0';
+
+ } else if (!strcmp(p, "-fwb")) {
+ EXPECTS_ARG;
+ SECOND_PASS_ONLY;
+ strncpy(cfg->wideboldfont.name, val, sizeof(cfg->wideboldfont.name));
+ cfg->wideboldfont.name[sizeof(cfg->wideboldfont.name)-1] = '\0';
+
+ } else if (!strcmp(p, "-cs")) {
+ EXPECTS_ARG;
+ SECOND_PASS_ONLY;
+ strncpy(cfg->line_codepage, val, sizeof(cfg->line_codepage));
+ cfg->line_codepage[sizeof(cfg->line_codepage)-1] = '\0';
+
+ } else if (!strcmp(p, "-geometry")) {
+ int flags, x, y, w, h;
+ EXPECTS_ARG;
+ SECOND_PASS_ONLY;
+
+ flags = XParseGeometry(val, &x, &y, &w, &h);
+ if (flags & WidthValue)
+ cfg->width = w;
+ if (flags & HeightValue)
+ cfg->height = h;
+
+ if (flags & (XValue | YValue)) {
+ inst->xpos = x;
+ inst->ypos = y;
+ inst->gotpos = TRUE;
+ inst->gravity = ((flags & XNegative ? 1 : 0) |
+ (flags & YNegative ? 2 : 0));
+ }
+
+ } else if (!strcmp(p, "-sl")) {
+ EXPECTS_ARG;
+ SECOND_PASS_ONLY;
+ cfg->savelines = atoi(val);
+
+ } else if (!strcmp(p, "-fg") || !strcmp(p, "-bg") ||
+ !strcmp(p, "-bfg") || !strcmp(p, "-bbg") ||
+ !strcmp(p, "-cfg") || !strcmp(p, "-cbg")) {
+ GdkColor col;
+
+ EXPECTS_ARG;
+ SECOND_PASS_ONLY;
+ if (!gdk_color_parse(val, &col)) {
+ err = 1;
+ fprintf(stderr, "%s: unable to parse colour \"%s\"\n",
+ appname, val);
+ } else {
+ int index;
+ index = (!strcmp(p, "-fg") ? 0 :
+ !strcmp(p, "-bg") ? 2 :
+ !strcmp(p, "-bfg") ? 1 :
+ !strcmp(p, "-bbg") ? 3 :
+ !strcmp(p, "-cfg") ? 4 :
+ !strcmp(p, "-cbg") ? 5 : -1);
+ assert(index != -1);
+ cfg->colours[index][0] = col.red / 256;
+ cfg->colours[index][1] = col.green / 256;
+ cfg->colours[index][2] = col.blue / 256;
+ }
+
+ } else if (use_pty_argv && !strcmp(p, "-e")) {
+ /* This option swallows all further arguments. */
+ if (!do_everything)
+ break;
+
+ if (--argc > 0) {
+ int i;
+ pty_argv = snewn(argc+1, char *);
+ ++argv;
+ for (i = 0; i < argc; i++)
+ pty_argv[i] = argv[i];
+ pty_argv[argc] = NULL;
+ break; /* finished command-line processing */
+ } else
+ err = 1, fprintf(stderr, "%s: -e expects an argument\n",
+ appname);
+
+ } else if (!strcmp(p, "-title")) {
+ EXPECTS_ARG;
+ SECOND_PASS_ONLY;
+ strncpy(cfg->wintitle, val, sizeof(cfg->wintitle));
+ cfg->wintitle[sizeof(cfg->wintitle)-1] = '\0';
+
+ } else if (!strcmp(p, "-log")) {
+ EXPECTS_ARG;
+ SECOND_PASS_ONLY;
+ strncpy(cfg->logfilename.path, val, sizeof(cfg->logfilename.path));
+ cfg->logfilename.path[sizeof(cfg->logfilename.path)-1] = '\0';
+ cfg->logtype = LGTYP_DEBUG;
+
+ } else if (!strcmp(p, "-ut-") || !strcmp(p, "+ut")) {
+ SECOND_PASS_ONLY;
+ cfg->stamp_utmp = 0;
+
+ } else if (!strcmp(p, "-ut")) {
+ SECOND_PASS_ONLY;
+ cfg->stamp_utmp = 1;
+
+ } else if (!strcmp(p, "-ls-") || !strcmp(p, "+ls")) {
+ SECOND_PASS_ONLY;
+ cfg->login_shell = 0;
+
+ } else if (!strcmp(p, "-ls")) {
+ SECOND_PASS_ONLY;
+ cfg->login_shell = 1;
+
+ } else if (!strcmp(p, "-nethack")) {
+ SECOND_PASS_ONLY;
+ cfg->nethack_keypad = 1;
+
+ } else if (!strcmp(p, "-sb-") || !strcmp(p, "+sb")) {
+ SECOND_PASS_ONLY;
+ cfg->scrollbar = 0;
+
+ } else if (!strcmp(p, "-sb")) {
+ SECOND_PASS_ONLY;
+ cfg->scrollbar = 0;
+
+ } else if (!strcmp(p, "-name")) {
+ EXPECTS_ARG;
+ app_name = val;
+
+ } else if (!strcmp(p, "-xrm")) {
+ EXPECTS_ARG;
+ provide_xrm_string(val);
+
+ } else if(!strcmp(p, "-help") || !strcmp(p, "--help")) {
+ help(stdout);
+ exit(0);
+
+ } else if(p[0] != '-' && (!do_everything ||
+ process_nonoption_arg(p, cfg))) {
+ /* do nothing */
+
+ } else {
+ err = 1;
+ fprintf(stderr, "%s: unrecognized option '%s'\n", appname, p);
+ }