2 * Copyright (c) 1994-1996 Søren Schmidt
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * in this position and unchanged.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software withough specific prior written permission
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * $FreeBSD: src/usr.sbin/vidcontrol/vidcontrol.c,v 1.32.2.7 2002/09/15 22:31:50 dd Exp $
29 * $DragonFly: src/usr.sbin/vidcontrol/vidcontrol.c,v 1.6 2004/04/26 19:57:18 dillon Exp $
32 #include <machine/console.h>
34 #include <sys/consio.h>
35 #include <sys/errno.h>
36 #include <sys/types.h>
51 #define DATASIZE(x) ((x).w * (x).h * 256 / 8)
56 #define DUMP_FMT_REV 1
59 char legal_colors[16][16] = {
60 "black", "blue", "green", "cyan",
61 "red", "magenta", "brown", "white",
62 "grey", "lightblue", "lightgreen", "lightcyan",
63 "lightred", "lightmagenta", "yellow", "lightwhite"
68 vid_info_t console_info;
69 unsigned char screen_map[256];
70 int video_mode_number;
71 struct video_info video_mode_info;
80 int video_mode_changed;
81 int normal_fore_color, normal_back_color,
82 revers_fore_color, revers_back_color;
85 struct video_info new_mode_info;
89 * Initialize revert data.
91 * NOTE: the following parameters are not yet saved/restored:
93 * screen saver timeout
95 * mouse character and mouse show/hide state
96 * vty switching on/off state
105 if (ioctl(0, VT_GETACTIVE, &cur_info.active_vty) == -1)
106 errc(1, errno, "getting active vty");
108 cur_info.console_info.size = sizeof(cur_info.console_info);
110 if (ioctl(0, CONS_GETINFO, &cur_info.console_info) == -1)
111 errc(1, errno, "getting console information");
113 if (ioctl(0, GIO_SCRNMAP, &cur_info.screen_map) == -1)
114 errc(1, errno, "getting screen map");
116 if (ioctl(0, CONS_GET, &cur_info.video_mode_number) == -1)
117 errc(1, errno, "getting video mode number");
119 cur_info.video_mode_info.vi_mode = cur_info.video_mode_number;
121 if (ioctl(0, CONS_MODEINFO, &cur_info.video_mode_info) == -1)
122 errc(1, errno, "getting video mode parameters");
124 normal_fore_color = cur_info.console_info.mv_norm.fore;
125 normal_back_color = cur_info.console_info.mv_norm.back;
126 revers_fore_color = cur_info.console_info.mv_rev.fore;
127 revers_back_color = cur_info.console_info.mv_rev.back;
132 * If something goes wrong along the way we call revert() to go back to the
133 * console state we came from (which is assumed to be working).
135 * NOTE: please also read the comments of init().
143 ioctl(0, VT_ACTIVATE, (caddr_t) (long) cur_info.active_vty);
145 fprintf(stderr, "
\e[=%dA", cur_info.console_info.mv_ovscan);
146 fprintf(stderr, "
\e[=%dF", cur_info.console_info.mv_norm.fore);
147 fprintf(stderr, "
\e[=%dG", cur_info.console_info.mv_norm.back);
148 fprintf(stderr, "
\e[=%dH", cur_info.console_info.mv_rev.fore);
149 fprintf(stderr, "
\e[=%dI", cur_info.console_info.mv_rev.back);
151 ioctl(0, PIO_SCRNMAP, &cur_info.screen_map);
153 if (cur_info.video_mode_number >= M_VESA_BASE)
154 ioctl(0, _IO('V', cur_info.video_mode_number - M_VESA_BASE), NULL);
156 ioctl(0, _IO('S', cur_info.video_mode_number), NULL);
158 if (cur_info.video_mode_info.vi_flags & V_INFO_GRAPHICS) {
159 size[0] = cur_info.video_mode_info.vi_width / 8;
160 size[1] = cur_info.video_mode_info.vi_height /
161 cur_info.console_info.font_size;
162 size[2] = cur_info.console_info.font_size;
164 ioctl(0, KDRASTER, size);
170 * Print a short usage string describing all options, then exit.
177 "usage: vidcontrol [-CdLPpx] [-b color] [-c appearance] [-f [size]"
179 " [-g geometry] [-h size] [-i adapter | mode] [-l"
181 " [-M char] [-m on | off] [-r foreground"
183 " [-S on | off] [-s number] [-t N | off] [mode]\n"
184 " [foreground [background]] [show]\n");
191 * Retrieve the next argument from the command line (for options that require
192 * more than one argument).
196 nextarg(int ac, char **av, int *indp, int oc, int strict)
199 return(av[(*indp)++]);
203 errx(1, "option requires two arguments -- %c", oc);
211 * Guess which file to open. Try to open each combination of a specified set
212 * of file name components.
216 openguess(char *a[], char *b[], char *c[], char *d[], char **name)
221 for (i = 0; a[i] != NULL; i++) {
222 for (j = 0; b[j] != NULL; j++) {
223 for (k = 0; c[k] != NULL; k++) {
224 for (l = 0; d[l] != NULL; l++) {
225 asprintf(name, "%s%s%s%s", a[i], b[j], c[k], d[l]);
227 f = fopen(*name, "r");
243 * Load a screenmap from a file and set it.
247 load_scrnmap(char *filename)
253 char *a[] = {"", SCRNMAP_PATH, NULL};
254 char *b[] = {filename, NULL};
255 char *c[] = {"", ".scm", NULL};
256 char *d[] = {"", NULL};
258 fd = openguess(a, b, c, d, &name);
262 errx(1, "screenmap file not found");
265 size = sizeof(scrnmap);
267 if (decode(fd, (char *)&scrnmap, size) != size) {
270 if (fread(&scrnmap, 1, size, fd) != size) {
273 errx(1, "bad screenmap file");
277 if (ioctl(0, PIO_SCRNMAP, &scrnmap) == -1) {
279 errc(1, errno, "loading screenmap");
287 * Set the default screenmap.
291 load_default_scrnmap(void)
296 for (i = 0; i < 256; i++)
297 *((char*)&scrnmap + i) = i;
299 if (ioctl(0, PIO_SCRNMAP, &scrnmap) == -1) {
301 errc(1, errno, "loading default screenmap");
307 * Print the current screenmap to stdout.
313 unsigned char map[256];
316 if (ioctl(0, GIO_SCRNMAP, &map) == -1) {
318 errc(1, errno, "getting screenmap");
321 for (i=0; i<sizeof(map); i++) {
322 if (i > 0 && i % 16 == 0)
323 fprintf(stdout, "\n");
326 fprintf(stdout, " %02x", map[i]);
328 fprintf(stdout, " %03d", map[i]);
331 fprintf(stdout, "\n");
336 * Determine a file's size.
344 if (fstat(fileno(file), &sb) == 0)
352 * Load a font from file and set it.
356 load_font(char *type, char *filename)
360 unsigned long io = 0; /* silence stupid gcc(1) in the Wall mode */
361 char *name, *fontmap, size_sufx[6];
362 char *a[] = {"", FONT_PATH, NULL};
363 char *b[] = {filename, NULL};
364 char *c[] = {"", size_sufx, NULL};
365 char *d[] = {"", ".fnt", NULL};
372 } sizes[] = {{8, 16, PIO_FONT8x16},
373 {8, 14, PIO_FONT8x14},
377 info.size = sizeof(info);
379 if (ioctl(0, CONS_GETINFO, &info) == -1) {
381 errc(1, errno, "obtaining current video mode parameters");
384 snprintf(size_sufx, sizeof(size_sufx), "-8x%d", info.font_size);
386 fd = openguess(a, b, c, d, &name);
390 errx(1, "%s: can't load font file", filename);
395 if (sscanf(type, "%dx%d", &w, &h) == 2)
396 for (i = 0; sizes[i].w != 0; i++) {
397 if (sizes[i].w == w && sizes[i].h == h) {
398 size = DATASIZE(sizes[i]);
400 font_height = sizes[i].h;
407 errx(1, "%s: bad font size specification", type);
410 /* Apply heuristics */
415 size = DATASIZE(sizes[0]);
416 fontmap = (char*) malloc(size);
417 dsize[0] = decode(fd, fontmap, size);
418 dsize[1] = fsize(fd);
422 for (j = 0; j < 2; j++) {
423 for (i = 0; sizes[i].w != 0; i++) {
424 if (DATASIZE(sizes[i]) == dsize[j]) {
427 font_height = sizes[i].h;
437 errx(1, "%s: can't guess font size", filename);
443 fontmap = (char*) malloc(size);
445 if (decode(fd, fontmap, size) != size) {
447 if (fsize(fd) != size || fread(fontmap, 1, size, fd) != size) {
451 errx(1, "%s: bad font file", filename);
455 if (ioctl(0, io, fontmap) == -1) {
457 errc(1, errno, "loading font");
466 * Set the timeout for the screensaver.
470 set_screensaver_timeout(char *arg)
474 if (!strcmp(arg, "off")) {
479 if ((*arg == '\0') || (nsec < 1)) {
481 errx(1, "argument must be a positive number");
485 if (ioctl(0, CONS_BLANKTIME, &nsec) == -1) {
487 errc(1, errno, "setting screensaver period");
494 * Set the cursor's shape/type.
498 set_cursor_type(char *appearance)
502 if (!strcmp(appearance, "normal"))
504 else if (!strcmp(appearance, "blink"))
506 else if (!strcmp(appearance, "destructive"))
510 errx(1, "argument to -c must be normal, blink or destructive");
513 if (ioctl(0, CONS_CURSORTYPE, &type) == -1) {
515 errc(1, errno, "setting cursor type");
521 * Set the video mode.
525 video_mode(int argc, char **argv, int *index)
530 unsigned long mode_num;
531 } modes[] = {{ "80x25", SW_TEXT_80x25, M_TEXT_80x25 },
532 { "80x30", SW_TEXT_80x30, M_TEXT_80x30 },
533 { "80x43", SW_TEXT_80x43, M_TEXT_80x43 },
534 { "80x50", SW_TEXT_80x50, M_TEXT_80x50 },
535 { "80x60", SW_TEXT_80x60, M_TEXT_80x60 },
536 { "132x25", SW_TEXT_132x25, M_TEXT_132x25 },
537 { "132x30", SW_TEXT_132x30, M_TEXT_132x30 },
538 { "132x43", SW_TEXT_132x43, M_TEXT_132x43 },
539 { "132x50", SW_TEXT_132x50, M_TEXT_132x50 },
540 { "132x60", SW_TEXT_132x60, M_TEXT_132x60 },
541 { "VGA_40x25", SW_VGA_C40x25, M_VGA_C40x25 },
542 { "VGA_80x25", SW_VGA_C80x25, M_VGA_C80x25 },
543 { "VGA_80x30", SW_VGA_C80x30, M_VGA_C80x30 },
544 { "VGA_80x50", SW_VGA_C80x50, M_VGA_C80x50 },
545 { "VGA_80x60", SW_VGA_C80x60, M_VGA_C80x60 },
547 { "VGA_90x25", SW_VGA_C90x25, M_VGA_C90x25 },
548 { "VGA_90x30", SW_VGA_C90x30, M_VGA_C90x30 },
549 { "VGA_90x43", SW_VGA_C90x43, M_VGA_C90x43 },
550 { "VGA_90x50", SW_VGA_C90x50, M_VGA_C90x50 },
551 { "VGA_90x60", SW_VGA_C90x60, M_VGA_C90x60 },
553 { "VGA_320x200", SW_VGA_CG320, M_CG320 },
554 { "EGA_80x25", SW_ENH_C80x25, M_ENH_C80x25 },
555 { "EGA_80x43", SW_ENH_C80x43, M_ENH_C80x43 },
556 { "VESA_132x25", SW_VESA_C132x25, M_VESA_C132x25 },
557 { "VESA_132x43", SW_VESA_C132x43, M_VESA_C132x43 },
558 { "VESA_132x50", SW_VESA_C132x50, M_VESA_C132x50 },
559 { "VESA_132x60", SW_VESA_C132x60, M_VESA_C132x60 },
560 { "VESA_800x600", SW_VESA_800x600, M_VESA_800x600 },
564 int new_mode_num = 0;
565 unsigned long mode = 0;
570 * Parse the video mode argument...
574 if (!strncmp(argv[*index], "MODE_", 5)) {
575 if (!isnumber(argv[*index][5]))
576 errx(1, "invalid video mode number");
578 new_mode_num = atoi(&argv[*index][5]);
580 for (i = 0; modes[i].name != NULL; ++i) {
581 if (!strcmp(argv[*index], modes[i].name)) {
582 mode = modes[i].mode;
583 new_mode_num = modes[i].mode_num;
588 if (modes[i].name == NULL)
589 errx(1, "invalid video mode name");
593 * Collect enough information about the new video mode...
596 new_mode_info.vi_mode = new_mode_num;
598 if (ioctl(0, CONS_MODEINFO, &new_mode_info) == -1) {
600 errc(1, errno, "obtaining new video mode parameters");
604 if (new_mode_num >= M_VESA_BASE)
605 mode = _IO('V', new_mode_num - M_VESA_BASE);
607 mode = _IO('S', new_mode_num);
611 * Try setting the new mode.
614 if (ioctl(0, mode, NULL) == -1) {
616 errc(1, errno, "setting video mode");
620 * For raster modes it's not enough to just set the mode. We also
621 * need to explicitly set the raster mode.
624 if (new_mode_info.vi_flags & V_INFO_GRAPHICS) {
627 if (font_height == 0)
628 font_height = cur_info.console_info.font_size;
630 size[2] = font_height;
634 if ((vesa_cols * 8 > new_mode_info.vi_width) ||
637 size[0] = new_mode_info.vi_width / 8;
644 if ((vesa_rows * font_height > new_mode_info.vi_height) ||
647 size[1] = new_mode_info.vi_height / font_height;
652 /* set raster mode */
654 if (ioctl(0, KDRASTER, size)) {
656 errc(1, errno, "activating raster display");
660 video_mode_changed = 1;
670 * Return the number for a specified color name.
674 get_color_number(char *color)
678 for (i=0; i<16; i++) {
679 if (!strcmp(color, legal_colors[i]))
687 * Get normal text and background colors.
691 get_normal_colors(int argc, char **argv, int *index)
695 if (*index < argc && (color = get_color_number(argv[*index])) != -1) {
697 normal_fore_color = color;
700 if (*index < argc && (color = get_color_number(argv[*index])) != -1) {
702 normal_back_color = color;
709 * Get reverse text and background colors.
713 get_reverse_colors(int argc, char **argv, int *index)
717 if ((color = get_color_number(argv[*(index)-1])) != -1) {
718 revers_fore_color = color;
721 if (*index < argc && (color = get_color_number(argv[*index])) != -1) {
723 revers_back_color = color;
730 * Set normal and reverse foreground and background colors.
736 fprintf(stderr, "
\e[=%dF", normal_fore_color);
737 fprintf(stderr, "
\e[=%dG", normal_back_color);
738 fprintf(stderr, "
\e[=%dH", revers_fore_color);
739 fprintf(stderr, "
\e[=%dI", revers_back_color);
744 * Switch to virtual terminal #arg.
748 set_console(char *arg)
752 if(!arg || strspn(arg,"0123456789") != strlen(arg)) {
754 errx(1, "bad console number");
759 if (n < 1 || n > 16) {
761 errx(1, "console number out of range");
762 } else if (ioctl(0, VT_ACTIVATE, (caddr_t) (long) n) == -1) {
764 errc(1, errno, "switching vty");
770 * Sets the border color.
774 set_border_color(char *arg)
778 if ((color = get_color_number(arg)) != -1)
779 fprintf(stderr, "
\e[=%dA", color);
786 set_mouse_char(char *arg)
788 struct mouse_info mouse;
791 l = strtol(arg, NULL, 0);
793 if ((l < 0) || (l > UCHAR_MAX)) {
795 errx(1, "argument to -M must be 0 through %d", UCHAR_MAX);
798 mouse.operation = MOUSE_MOUSECHAR;
799 mouse.u.mouse_char = (int)l;
801 if (ioctl(0, CONS_MOUSECTL, &mouse) == -1) {
803 errc(1, errno, "setting mouse character");
809 * Show/hide the mouse.
815 struct mouse_info mouse;
817 if (!strcmp(arg, "on")) {
818 mouse.operation = MOUSE_SHOW;
819 } else if (!strcmp(arg, "off")) {
820 mouse.operation = MOUSE_HIDE;
823 errx(1, "argument to -m must be either on or off");
826 if (ioctl(0, CONS_MOUSECTL, &mouse) == -1) {
828 errc(1, errno, "%sing the mouse",
829 mouse.operation == MOUSE_SHOW ? "show" : "hid");
835 set_lockswitch(char *arg)
839 if (!strcmp(arg, "off")) {
841 } else if (!strcmp(arg, "on")) {
845 errx(1, "argument to -S must be either on or off");
848 if (ioctl(0, VT_LOCKSWITCH, &data) == -1) {
850 errc(1, errno, "turning %s vty switching",
851 data == 0x01 ? "off" : "on");
857 * Return the adapter name for a specified type.
861 *adapter_name(int type)
866 } names[] = {{ KD_MONO, "MDA" },
867 { KD_HERCULES, "Hercules" },
871 { KD_PC98, "PC-98xx" },
878 for (i = 0; names[i].type != -1; ++i) {
879 if (names[i].type == type)
883 return names[i].name;
888 * Show graphics adapter information.
892 show_adapter_info(void)
894 struct video_adapter_info ad;
898 if (ioctl(0, CONS_ADPINFO, &ad) == -1) {
900 errc(1, errno, "obtaining adapter information");
903 printf("fb%d:\n", ad.va_index);
904 printf(" %.*s%d, type:%s%s (%d), flags:0x%x\n",
905 (int)sizeof(ad.va_name), ad.va_name, ad.va_unit,
906 (ad.va_flags & V_ADP_VESA) ? "VESA " : "",
907 adapter_name(ad.va_type), ad.va_type, ad.va_flags);
908 printf(" initial mode:%d, current mode:%d, BIOS mode:%d\n",
909 ad.va_initial_mode, ad.va_mode, ad.va_initial_bios_mode);
910 printf(" frame buffer window:0x%x, buffer size:0x%x\n",
911 ad.va_window, ad.va_buffer_size);
912 printf(" window size:0x%x, origin:0x%x\n",
913 ad.va_window_size, ad.va_window_orig);
914 printf(" display start address (%d, %d), scan line width:%d\n",
915 ad.va_disp_start.x, ad.va_disp_start.y, ad.va_line_width);
916 printf(" reserved:0x%x\n", ad.va_unused0);
921 * Show video mode information.
927 struct video_info info;
932 printf(" mode# flags type size "
933 "font window linear buffer\n");
934 printf("---------------------------------------"
935 "---------------------------------------\n");
937 for (mode = 0; mode < M_VESA_MODE_MAX; ++mode) {
940 if (ioctl(0, CONS_MODEINFO, &info))
942 if (info.vi_mode != mode)
945 printf("%3d (0x%03x)", mode, mode);
946 printf(" 0x%08x", info.vi_flags);
948 if (info.vi_flags & V_INFO_GRAPHICS) {
951 snprintf(buf, sizeof(buf), "%dx%dx%d %d",
952 info.vi_width, info.vi_height,
953 info.vi_depth, info.vi_planes);
957 snprintf(buf, sizeof(buf), "%dx%d",
958 info.vi_width, info.vi_height);
961 printf(" %c %-15s", c, buf);
962 snprintf(buf, sizeof(buf), "%dx%d",
963 info.vi_cwidth, info.vi_cheight);
964 printf(" %-5s", buf);
965 printf(" 0x%05x %2dk %2dk",
966 info.vi_window, (int)info.vi_window_size / 1024,
967 (int)info.vi_window_gran/1024);
968 printf(" 0x%08x %dk\n",
969 info.vi_buffer, (int)info.vi_buffer_size / 1024);
977 if (!strcmp(arg, "adapter")) {
979 } else if (!strcmp(arg, "mode")) {
983 errx(1, "argument to -i must be either adapter or mode");
993 fprintf(stdout, "
\e[=0G\n\n");
995 for (i = 0; i < 8; i++) {
996 fprintf(stdout, "
\e[=15F
\e[=0G %2d
\e[=%dF%-16s"
997 "
\e[=15F
\e[=0G %2d
\e[=%dF%-16s "
998 "
\e[=15F %2d
\e[=%dGBACKGROUND
\e[=0G\n",
999 i, i, legal_colors[i], i+8, i+8,
1000 legal_colors[i+8], i, i);
1003 fprintf(stdout, "
\e[=%dF
\e[=%dG
\e[=%dH
\e[=%dI\n",
1004 info.mv_norm.fore, info.mv_norm.back,
1005 info.mv_rev.fore, info.mv_rev.back);
1010 * Snapshot the video memory of that terminal, using the CONS_SCRSHOT
1011 * ioctl, and writes the results to stdout either in the special
1012 * binary format (see manual page for details), or in the plain
1017 dump_screen(int mode)
1022 info.size = sizeof(info);
1024 if (ioctl(0, CONS_GETINFO, &info) == -1) {
1026 errc(1, errno, "obtaining current video mode parameters");
1029 shot.buf = alloca(info.mv_csz * info.mv_rsz * sizeof(u_int16_t));
1031 if (shot.buf == NULL) {
1033 errx(1, "failed to allocate memory for dump");
1036 shot.xsize = info.mv_csz;
1037 shot.ysize = info.mv_rsz;
1039 if (ioctl(0, CONS_SCRSHOT, &shot) == -1) {
1041 errc(1, errno, "dumping screen");
1044 if (mode == DUMP_RAW) {
1045 printf("SCRSHOT_%c%c%c%c", DUMP_FMT_REV, 2,
1046 shot.xsize, shot.ysize);
1050 (void)write(STDOUT_FILENO, shot.buf,
1051 shot.xsize * shot.ysize * sizeof(u_int16_t));
1057 line = alloca(shot.xsize + 1);
1061 errx(1, "failed to allocate memory for line buffer");
1064 for (y = 0; y < shot.ysize; y++) {
1065 for (x = 0; x < shot.xsize; x++) {
1066 ch = shot.buf[x + (y * shot.xsize)];
1069 if (isprint(ch) == 0)
1075 /* Trim trailing spaces */
1079 } while (line[x] == ' ' && x != 0);
1092 * Set the console history buffer size.
1096 set_history(char *opt)
1102 if ((*opt == '\0') || size < 0) {
1104 errx(1, "argument must be a positive number");
1107 if (ioctl(0, CONS_HISTORY, &size) == -1) {
1109 errc(1, errno, "setting history buffer size");
1115 * Clear the console history buffer.
1121 if (ioctl(0, CONS_CLRHIST) == -1) {
1123 errc(1, errno, "clearing history buffer");
1129 main(int argc, char **argv)
1139 info.size = sizeof(info);
1141 if (ioctl(0, CONS_GETINFO, &info) == -1)
1142 err(1, "must be on a virtual console");
1144 while((opt = getopt(argc, argv, "b:Cc:df:g:h:i:l:LM:m:pPr:S:s:t:x")) != -1) {
1147 set_border_color(optarg);
1153 set_cursor_type(optarg);
1160 font = nextarg(argc, argv, &optind, 'f', 0);
1167 load_font(type, font);
1170 if (sscanf(optarg, "%dx%d", &vesa_cols, &vesa_rows) != 2) {
1172 warnx("incorrect geometry: %s", optarg);
1177 set_history(optarg);
1183 load_scrnmap(optarg);
1186 load_default_scrnmap();
1189 set_mouse_char(optarg);
1195 dump_screen(DUMP_RAW);
1198 dump_screen(DUMP_TXT);
1201 get_reverse_colors(argc, argv, &optind);
1204 set_lockswitch(optarg);
1207 set_console(optarg);
1210 set_screensaver_timeout(optarg);
1220 video_mode(argc, argv, &optind);
1222 get_normal_colors(argc, argv, &optind);
1224 if (colors_changed || video_mode_changed) {
1225 if (!(new_mode_info.vi_flags & V_INFO_GRAPHICS)) {
1226 if ((normal_back_color < 8) && (revers_back_color < 8)) {
1230 errx(1, "background colors for text video modes must be < 8");
1237 if (optind < argc && !strcmp(argv[optind], "show")) {
1242 if ((optind != argc) || (argc == 1))