- if (!strcmp(p, "-fn")) {
- if (--argc > 0) {
- strncpy(cfg.font, *++argv, sizeof(cfg.font));
- cfg.font[sizeof(cfg.font)-1] = '\0';
- } else
- err = 1, fprintf(stderr, "pterm: -fn expects an argument\n");
- }
- if (!strcmp(p, "-fb")) {
- if (--argc > 0) {
- strncpy(cfg.boldfont, *++argv, sizeof(cfg.boldfont));
- cfg.boldfont[sizeof(cfg.boldfont)-1] = '\0';
- } else
- err = 1, fprintf(stderr, "pterm: -fb expects an argument\n");
- }
- if (!strcmp(p, "-e")) {
+ 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;
+
+ /*
+ * Apparently setting the initial window position is
+ * difficult in GTK 1.2. Not entirely sure why this
+ * should be. 2.0 has gtk_window_parse_geometry(),
+ * which would help... For the moment, though, I can't
+ * be bothered with this.
+ */
+
+ } 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, "pterm: unable to parse colour \"%s\"\n", 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 (!strcmp(p, "-e")) {
+ /* This option swallows all further arguments. */
+ if (!do_everything)
+ break;
+