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.4 2004/04/25 06:35:32 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
104 if (ioctl(0, VT_GETACTIVE, &cur_info.active_vty) == -1)
105 errc(1, errno, "getting active vty");
107 cur_info.console_info.size = sizeof(cur_info.console_info);
109 if (ioctl(0, CONS_GETINFO, &cur_info.console_info) == -1)
110 errc(1, errno, "getting console information");
112 if (ioctl(0, GIO_SCRNMAP, &cur_info.screen_map) == -1)
113 errc(1, errno, "getting screen map");
115 if (ioctl(0, CONS_GET, &cur_info.video_mode_number) == -1)
116 errc(1, errno, "getting video mode number");
118 cur_info.video_mode_info.vi_mode = cur_info.video_mode_number;
120 if (ioctl(0, CONS_MODEINFO, &cur_info.video_mode_info) == -1)
121 errc(1, errno, "getting video mode parameters");
123 normal_fore_color = cur_info.console_info.mv_norm.fore;
124 normal_back_color = cur_info.console_info.mv_norm.back;
125 revers_fore_color = cur_info.console_info.mv_rev.fore;
126 revers_back_color = cur_info.console_info.mv_rev.back;
131 * If something goes wrong along the way we call revert() to go back to the
132 * console state we came from (which is assumed to be working).
134 * NOTE: please also read the comments of init().
141 ioctl(0, VT_ACTIVATE, (caddr_t) (long) cur_info.active_vty);
143 fprintf(stderr, "
\e[=%dA", cur_info.console_info.mv_ovscan);
144 fprintf(stderr, "
\e[=%dF", cur_info.console_info.mv_norm.fore);
145 fprintf(stderr, "
\e[=%dG", cur_info.console_info.mv_norm.back);
146 fprintf(stderr, "
\e[=%dH", cur_info.console_info.mv_rev.fore);
147 fprintf(stderr, "
\e[=%dI", cur_info.console_info.mv_rev.back);
149 ioctl(0, PIO_SCRNMAP, &cur_info.screen_map);
151 if (cur_info.video_mode_number >= M_VESA_BASE)
152 ioctl(0, _IO('V', cur_info.video_mode_number - M_VESA_BASE), NULL);
154 ioctl(0, _IO('S', cur_info.video_mode_number), NULL);
156 if (cur_info.video_mode_info.vi_flags & V_INFO_GRAPHICS) {
157 size[0] = cur_info.video_mode_info.vi_width / 8;
158 size[1] = cur_info.video_mode_info.vi_height /
159 cur_info.console_info.font_size;
160 size[2] = cur_info.console_info.font_size;
162 ioctl(0, KDRASTER, size);
168 * Print a short usage string describing all options, then exit.
175 "usage: vidcontrol [-CdLPpx] [-b color] [-c appearance] [-f [size] file]\n"
176 " [-g geometry] [-h size] [-i adapter | mode] [-l screen_map]\n"
177 " [-M char] [-m on | off] [-r foreground background]\n"
178 " [-S on | off] [-s number] [-t N | off] [mode]\n"
179 " [foreground [background]] [show]\n");
186 * Retrieve the next argument from the command line (for options that require
187 * more than one argument).
191 nextarg(int ac, char **av, int *indp, int oc, int strict)
194 return(av[(*indp)++]);
198 errx(1, "option requires two arguments -- %c", oc);
206 * Guess which file to open. Try to open each combination of a specified set
207 * of file name components.
211 openguess(char *a[], char *b[], char *c[], char *d[], char **name)
216 for (i = 0; a[i] != NULL; i++) {
217 for (j = 0; b[j] != NULL; j++) {
218 for (k = 0; c[k] != NULL; k++) {
219 for (l = 0; d[l] != NULL; l++) {
220 asprintf(name, "%s%s%s%s", a[i], b[j], c[k], d[l]);
222 f = fopen(*name, "r");
238 * Load a screenmap from a file and set it.
242 load_scrnmap(char *filename)
248 char *a[] = {"", SCRNMAP_PATH, NULL};
249 char *b[] = {filename, NULL};
250 char *c[] = {"", ".scm", NULL};
251 char *d[] = {"", NULL};
253 fd = openguess(a, b, c, d, &name);
257 errx(1, "screenmap file not found");
260 size = sizeof(scrnmap);
262 if (decode(fd, (char *)&scrnmap, size) != size) {
265 if (fread(&scrnmap, 1, size, fd) != size) {
268 errx(1, "bad screenmap file");
272 if (ioctl(0, PIO_SCRNMAP, &scrnmap) == -1) {
274 errc(1, errno, "loading screenmap");
282 * Set the default screenmap.
286 load_default_scrnmap(void)
291 for (i = 0; i < 256; i++)
292 *((char*)&scrnmap + i) = i;
294 if (ioctl(0, PIO_SCRNMAP, &scrnmap) == -1) {
296 errc(1, errno, "loading default screenmap");
302 * Print the current screenmap to stdout.
308 unsigned char map[256];
311 if (ioctl(0, GIO_SCRNMAP, &map) == -1) {
313 errc(1, errno, "getting screenmap");
316 for (i=0; i<sizeof(map); i++) {
317 if (i > 0 && i % 16 == 0)
318 fprintf(stdout, "\n");
321 fprintf(stdout, " %02x", map[i]);
323 fprintf(stdout, " %03d", map[i]);
326 fprintf(stdout, "\n");
331 * Determine a file's size.
339 if (fstat(fileno(file), &sb) == 0)
347 * Load a font from file and set it.
351 load_font(char *type, char *filename)
355 unsigned long io = 0; /* silence stupid gcc(1) in the Wall mode */
356 char *name, *fontmap, size_sufx[6];
357 char *a[] = {"", FONT_PATH, NULL};
358 char *b[] = {filename, NULL};
359 char *c[] = {"", size_sufx, NULL};
360 char *d[] = {"", ".fnt", NULL};
367 } sizes[] = {{8, 16, PIO_FONT8x16},
368 {8, 14, PIO_FONT8x14},
372 info.size = sizeof(info);
374 if (ioctl(0, CONS_GETINFO, &info) == -1) {
376 errc(1, errno, "obtaining current video mode parameters");
379 snprintf(size_sufx, sizeof(size_sufx), "-8x%d", info.font_size);
381 fd = openguess(a, b, c, d, &name);
385 errx(1, "%s: can't load font file", filename);
390 if (sscanf(type, "%dx%d", &w, &h) == 2)
391 for (i = 0; sizes[i].w != 0; i++) {
392 if (sizes[i].w == w && sizes[i].h == h) {
393 size = DATASIZE(sizes[i]);
395 font_height = sizes[i].h;
402 errx(1, "%s: bad font size specification", type);
405 /* Apply heuristics */
410 size = DATASIZE(sizes[0]);
411 fontmap = (char*) malloc(size);
412 dsize[0] = decode(fd, fontmap, size);
413 dsize[1] = fsize(fd);
417 for (j = 0; j < 2; j++) {
418 for (i = 0; sizes[i].w != 0; i++) {
419 if (DATASIZE(sizes[i]) == dsize[j]) {
422 font_height = sizes[i].h;
432 errx(1, "%s: can't guess font size", filename);
438 fontmap = (char*) malloc(size);
440 if (decode(fd, fontmap, size) != size) {
442 if (fsize(fd) != size || fread(fontmap, 1, size, fd) != size) {
446 errx(1, "%s: bad font file", filename);
450 if (ioctl(0, io, fontmap) == -1) {
452 errc(1, errno, "loading font");
461 * Set the timeout for the screensaver.
465 set_screensaver_timeout(char *arg)
469 if (!strcmp(arg, "off")) {
474 if ((*arg == '\0') || (nsec < 1)) {
476 errx(1, "argument must be a positive number");
480 if (ioctl(0, CONS_BLANKTIME, &nsec) == -1) {
482 errc(1, errno, "setting screensaver period");
489 * Set the cursor's shape/type.
493 set_cursor_type(char *appearance)
497 if (!strcmp(appearance, "normal"))
499 else if (!strcmp(appearance, "blink"))
501 else if (!strcmp(appearance, "destructive"))
505 errx(1, "argument to -c must be normal, blink or destructive");
508 if (ioctl(0, CONS_CURSORTYPE, &type) == -1) {
510 errc(1, errno, "setting cursor type");
516 * Set the video mode.
520 video_mode(int argc, char **argv, int *index)
525 unsigned long mode_num;
526 } modes[] = {{ "80x25", SW_TEXT_80x25, M_TEXT_80x25 },
527 { "80x30", SW_TEXT_80x30, M_TEXT_80x30 },
528 { "80x43", SW_TEXT_80x43, M_TEXT_80x43 },
529 { "80x50", SW_TEXT_80x50, M_TEXT_80x50 },
530 { "80x60", SW_TEXT_80x60, M_TEXT_80x60 },
531 { "132x25", SW_TEXT_132x25, M_TEXT_132x25 },
532 { "132x30", SW_TEXT_132x30, M_TEXT_132x30 },
533 { "132x43", SW_TEXT_132x43, M_TEXT_132x43 },
534 { "132x50", SW_TEXT_132x50, M_TEXT_132x50 },
535 { "132x60", SW_TEXT_132x60, M_TEXT_132x60 },
536 { "VGA_40x25", SW_VGA_C40x25, M_VGA_C40x25 },
537 { "VGA_80x25", SW_VGA_C80x25, M_VGA_C80x25 },
538 { "VGA_80x30", SW_VGA_C80x30, M_VGA_C80x30 },
539 { "VGA_80x50", SW_VGA_C80x50, M_VGA_C80x50 },
540 { "VGA_80x60", SW_VGA_C80x60, M_VGA_C80x60 },
542 { "VGA_90x25", SW_VGA_C90x25, M_VGA_C90x25 },
543 { "VGA_90x30", SW_VGA_C90x30, M_VGA_C90x30 },
544 { "VGA_90x43", SW_VGA_C90x43, M_VGA_C90x43 },
545 { "VGA_90x50", SW_VGA_C90x50, M_VGA_C90x50 },
546 { "VGA_90x60", SW_VGA_C90x60, M_VGA_C90x60 },
548 { "VGA_320x200", SW_VGA_CG320, M_CG320 },
549 { "EGA_80x25", SW_ENH_C80x25, M_ENH_C80x25 },
550 { "EGA_80x43", SW_ENH_C80x43, M_ENH_C80x43 },
551 { "VESA_132x25", SW_VESA_C132x25, M_VESA_C132x25 },
552 { "VESA_132x43", SW_VESA_C132x43, M_VESA_C132x43 },
553 { "VESA_132x50", SW_VESA_C132x50, M_VESA_C132x50 },
554 { "VESA_132x60", SW_VESA_C132x60, M_VESA_C132x60 },
555 { "VESA_800x600", SW_VESA_800x600, M_VESA_800x600 },
559 int new_mode_num = 0;
560 unsigned long mode = 0;
565 * Parse the video mode argument...
569 if (!strncmp(argv[*index], "MODE_", 5)) {
570 if (!isnumber(argv[*index][5]))
571 errx(1, "invalid video mode number");
573 new_mode_num = atoi(&argv[*index][5]);
575 for (i = 0; modes[i].name != NULL; ++i) {
576 if (!strcmp(argv[*index], modes[i].name)) {
577 mode = modes[i].mode;
578 new_mode_num = modes[i].mode_num;
583 if (modes[i].name == NULL)
584 errx(1, "invalid video mode name");
588 * Collect enough information about the new video mode...
591 new_mode_info.vi_mode = new_mode_num;
593 if (ioctl(0, CONS_MODEINFO, &new_mode_info) == -1) {
595 errc(1, errno, "obtaining new video mode parameters");
599 if (new_mode_num >= M_VESA_BASE)
600 mode = _IO('V', new_mode_num - M_VESA_BASE);
602 mode = _IO('S', new_mode_num);
606 * Try setting the new mode.
609 if (ioctl(0, mode, NULL) == -1) {
611 errc(1, errno, "setting video mode");
615 * For raster modes it's not enough to just set the mode. We also
616 * need to explicitly set the raster mode.
619 if (new_mode_info.vi_flags & V_INFO_GRAPHICS) {
622 if (font_height == 0)
623 font_height = cur_info.console_info.font_size;
625 size[2] = font_height;
629 if ((vesa_cols * 8 > new_mode_info.vi_width) ||
632 size[0] = new_mode_info.vi_width / 8;
639 if ((vesa_rows * font_height > new_mode_info.vi_height) ||
642 size[1] = new_mode_info.vi_height / font_height;
647 /* set raster mode */
649 if (ioctl(0, KDRASTER, size)) {
651 errc(1, errno, "activating raster display");
654 video_mode_changed = 1;
656 video_mode_changed = 1;
666 * Return the number for a specified color name.
670 get_color_number(char *color)
674 for (i=0; i<16; i++) {
675 if (!strcmp(color, legal_colors[i]))
683 * Get normal text and background colors.
687 get_normal_colors(int argc, char **argv, int *index)
691 if (*index < argc && (color = get_color_number(argv[*index])) != -1) {
693 normal_fore_color = color;
696 if (*index < argc && (color = get_color_number(argv[*index])) != -1) {
698 normal_back_color = color;
705 * Get reverse text and background colors.
709 get_reverse_colors(int argc, char **argv, int *index)
713 if ((color = get_color_number(argv[*(index)-1])) != -1) {
714 revers_fore_color = color;
717 if (*index < argc && (color = get_color_number(argv[*index])) != -1) {
719 revers_back_color = color;
726 * Set normal and reverse foreground and background colors.
731 fprintf(stderr, "
\e[=%dF", normal_fore_color);
732 fprintf(stderr, "
\e[=%dG", normal_back_color);
733 fprintf(stderr, "
\e[=%dH", revers_fore_color);
734 fprintf(stderr, "
\e[=%dI", revers_back_color);
739 * Switch to virtual terminal #arg.
743 set_console(char *arg)
747 if(!arg || strspn(arg,"0123456789") != strlen(arg)) {
749 errx(1, "bad console number");
754 if (n < 1 || n > 16) {
756 errx(1, "console number out of range");
757 } else if (ioctl(0, VT_ACTIVATE, (caddr_t) (long) n) == -1) {
759 errc(1, errno, "switching vty");
765 * Sets the border color.
769 set_border_color(char *arg)
773 if ((color = get_color_number(arg)) != -1)
774 fprintf(stderr, "
\e[=%dA", color);
781 set_mouse_char(char *arg)
783 struct mouse_info mouse;
786 l = strtol(arg, NULL, 0);
788 if ((l < 0) || (l > UCHAR_MAX)) {
790 errx(1, "argument to -M must be 0 through %d", UCHAR_MAX);
793 mouse.operation = MOUSE_MOUSECHAR;
794 mouse.u.mouse_char = (int)l;
796 if (ioctl(0, CONS_MOUSECTL, &mouse) == -1) {
798 errc(1, errno, "setting mouse character");
804 * Show/hide the mouse.
810 struct mouse_info mouse;
812 if (!strcmp(arg, "on")) {
813 mouse.operation = MOUSE_SHOW;
814 } else if (!strcmp(arg, "off")) {
815 mouse.operation = MOUSE_HIDE;
818 errx(1, "argument to -m must be either on or off");
821 if (ioctl(0, CONS_MOUSECTL, &mouse) == -1) {
823 errc(1, errno, "%sing the mouse",
824 mouse.operation == MOUSE_SHOW ? "show" : "hid");
830 set_lockswitch(char *arg)
834 if (!strcmp(arg, "off")) {
836 } else if (!strcmp(arg, "on")) {
840 errx(1, "argument to -S must be either on or off");
843 if (ioctl(0, VT_LOCKSWITCH, &data) == -1) {
845 errc(1, errno, "turning %s vty switching",
846 data == 0x01 ? "off" : "on");
852 * Return the adapter name for a specified type.
856 *adapter_name(int type)
861 } names[] = {{ KD_MONO, "MDA" },
862 { KD_HERCULES, "Hercules" },
866 { KD_PC98, "PC-98xx" },
873 for (i = 0; names[i].type != -1; ++i) {
874 if (names[i].type == type)
878 return names[i].name;
883 * Show graphics adapter information.
887 show_adapter_info(void)
889 struct video_adapter_info ad;
893 if (ioctl(0, CONS_ADPINFO, &ad) == -1) {
895 errc(1, errno, "obtaining adapter information");
898 printf("fb%d:\n", ad.va_index);
899 printf(" %.*s%d, type:%s%s (%d), flags:0x%x\n",
900 (int)sizeof(ad.va_name), ad.va_name, ad.va_unit,
901 (ad.va_flags & V_ADP_VESA) ? "VESA " : "",
902 adapter_name(ad.va_type), ad.va_type, ad.va_flags);
903 printf(" initial mode:%d, current mode:%d, BIOS mode:%d\n",
904 ad.va_initial_mode, ad.va_mode, ad.va_initial_bios_mode);
905 printf(" frame buffer window:0x%x, buffer size:0x%x\n",
906 ad.va_window, ad.va_buffer_size);
907 printf(" window size:0x%x, origin:0x%x\n",
908 ad.va_window_size, ad.va_window_orig);
909 printf(" display start address (%d, %d), scan line width:%d\n",
910 ad.va_disp_start.x, ad.va_disp_start.y, ad.va_line_width);
911 printf(" reserved:0x%x\n", ad.va_unused0);
916 * Show video mode information.
922 struct video_info info;
927 printf(" mode# flags type size "
928 "font window linear buffer\n");
929 printf("---------------------------------------"
930 "---------------------------------------\n");
932 for (mode = 0; mode < M_VESA_MODE_MAX; ++mode) {
935 if (ioctl(0, CONS_MODEINFO, &info))
937 if (info.vi_mode != mode)
940 printf("%3d (0x%03x)", mode, mode);
941 printf(" 0x%08x", info.vi_flags);
943 if (info.vi_flags & V_INFO_GRAPHICS) {
946 snprintf(buf, sizeof(buf), "%dx%dx%d %d",
947 info.vi_width, info.vi_height,
948 info.vi_depth, info.vi_planes);
952 snprintf(buf, sizeof(buf), "%dx%d",
953 info.vi_width, info.vi_height);
956 printf(" %c %-15s", c, buf);
957 snprintf(buf, sizeof(buf), "%dx%d",
958 info.vi_cwidth, info.vi_cheight);
959 printf(" %-5s", buf);
960 printf(" 0x%05x %2dk %2dk",
961 info.vi_window, (int)info.vi_window_size / 1024,
962 (int)info.vi_window_gran/1024);
963 printf(" 0x%08x %dk\n",
964 info.vi_buffer, (int)info.vi_buffer_size / 1024);
972 if (!strcmp(arg, "adapter")) {
974 } else if (!strcmp(arg, "mode")) {
978 errx(1, "argument to -i must be either adapter or mode");
988 fprintf(stdout, "
\e[=0G\n\n");
990 for (i = 0; i < 8; i++) {
991 fprintf(stdout, "
\e[=15F
\e[=0G %2d
\e[=%dF%-16s"
992 "
\e[=15F
\e[=0G %2d
\e[=%dF%-16s "
993 "
\e[=15F %2d
\e[=%dGBACKGROUND
\e[=0G\n",
994 i, i, legal_colors[i], i+8, i+8,
995 legal_colors[i+8], i, i);
998 fprintf(stdout, "
\e[=%dF
\e[=%dG
\e[=%dH
\e[=%dI\n",
999 info.mv_norm.fore, info.mv_norm.back,
1000 info.mv_rev.fore, info.mv_rev.back);
1005 * Snapshot the video memory of that terminal, using the CONS_SCRSHOT
1006 * ioctl, and writes the results to stdout either in the special
1007 * binary format (see manual page for details), or in the plain
1012 dump_screen(int mode)
1017 info.size = sizeof(info);
1019 if (ioctl(0, CONS_GETINFO, &info) == -1) {
1021 errc(1, errno, "obtaining current video mode parameters");
1024 shot.buf = alloca(info.mv_csz * info.mv_rsz * sizeof(u_int16_t));
1026 if (shot.buf == NULL) {
1028 errx(1, "failed to allocate memory for dump");
1031 shot.xsize = info.mv_csz;
1032 shot.ysize = info.mv_rsz;
1034 if (ioctl(0, CONS_SCRSHOT, &shot) == -1) {
1036 errc(1, errno, "dumping screen");
1039 if (mode == DUMP_RAW) {
1040 printf("SCRSHOT_%c%c%c%c", DUMP_FMT_REV, 2,
1041 shot.xsize, shot.ysize);
1045 (void)write(STDOUT_FILENO, shot.buf,
1046 shot.xsize * shot.ysize * sizeof(u_int16_t));
1052 line = alloca(shot.xsize + 1);
1056 errx(1, "failed to allocate memory for line buffer");
1059 for (y = 0; y < shot.ysize; y++) {
1060 for (x = 0; x < shot.xsize; x++) {
1061 ch = shot.buf[x + (y * shot.xsize)];
1064 if (isprint(ch) == 0)
1070 /* Trim trailing spaces */
1074 } while (line[x] == ' ' && x != 0);
1087 * Set the console history buffer size.
1091 set_history(char *opt)
1097 if ((*opt == '\0') || size < 0) {
1099 errx(1, "argument must be a positive number");
1102 if (ioctl(0, CONS_HISTORY, &size) == -1) {
1104 errc(1, errno, "setting history buffer size");
1110 * Clear the console history buffer.
1116 if (ioctl(0, CONS_CLRHIST) == -1) {
1118 errc(1, errno, "clearing history buffer");
1124 main(int argc, char **argv)
1131 info.size = sizeof(info);
1136 if (ioctl(0, CONS_GETINFO, &info) == -1)
1137 err(1, "must be on a virtual console");
1139 while((opt = getopt(argc, argv, "b:Cc:df:g:h:i:l:LM:m:pPr:S:s:t:x")) != -1) {
1142 set_border_color(optarg);
1148 set_cursor_type(optarg);
1155 font = nextarg(argc, argv, &optind, 'f', 0);
1162 load_font(type, font);
1165 if (sscanf(optarg, "%dx%d", &vesa_cols, &vesa_rows) != 2) {
1167 warnx("incorrect geometry: %s", optarg);
1172 set_history(optarg);
1178 load_scrnmap(optarg);
1181 load_default_scrnmap();
1184 set_mouse_char(optarg);
1190 dump_screen(DUMP_RAW);
1193 dump_screen(DUMP_TXT);
1196 get_reverse_colors(argc, argv, &optind);
1199 set_lockswitch(optarg);
1202 set_console(optarg);
1205 set_screensaver_timeout(optarg);
1215 video_mode(argc, argv, &optind);
1217 get_normal_colors(argc, argv, &optind);
1219 if (colors_changed || video_mode_changed) {
1220 if (!(new_mode_info.vi_flags & V_INFO_GRAPHICS)) {
1221 if ((normal_back_color < 8) && (revers_back_color < 8)) {
1225 errx(1, "background colors for text video modes must be < 8");
1232 if (optind < argc && !strcmp(argv[optind], "show")) {
1237 if ((optind != argc) || (argc == 1))