svn commit: r344458 - in head: share/man/man4 sys/conf usr.sbin/vidcontrol

Bruce Evans bde at FreeBSD.org
Fri Feb 22 06:41:50 UTC 2019


Author: bde
Date: Fri Feb 22 06:41:47 2019
New Revision: 344458
URL: https://svnweb.freebsd.org/changeset/base/344458

Log:
  Connect the restored dumb and sc terminal emulators to the kernel build.
  Add or fix options to control static and dynamic configuration.  Keep
  the default of scteken, but default to statically configuring all available
  emulators (now 3 instead of 1).
  
  The dumb emulator is almost usable.  libedit and libreadline handle
  dumb terminals perfectly for at least shell history.  less(1) works
  as well as possible except on exit.  But curses programs make messes.
  The dumb emulator has strange color support, with 2 dumb colors for
  normal output but fancy colorization for the cursor, mouse pointer and
  (with a non-dumb initial emulator) for low-level console output.
  
  Using the sc emulator instead of the default of scteken fixes at least
  the following bugs:
  - NUL is a printing character in cons25 but not in teken
  - teken doesn't support fixed colors for "reverse" video.
  - The best versions of sc are about 10 times faster than scteken (for
    printing to the frame buffer).  This version is only about 5 times
    faster.
  
  Fix configuration features:
  - make SC_DFLT_TERM (for setting the initial emulator) a normal option.
  
  Add configuration features:
  - negative options SC_NO_TERM_* for omitting emulators in the static config.
    Modules for emulators might work, but I don't know of any
  - vidcontrol -e shows the available emulators
  - vidcontrol -E <emulator> sets the active emulator.

Modified:
  head/share/man/man4/syscons.4
  head/sys/conf/NOTES
  head/sys/conf/files
  head/sys/conf/options
  head/usr.sbin/vidcontrol/vidcontrol.1
  head/usr.sbin/vidcontrol/vidcontrol.c

Modified: head/share/man/man4/syscons.4
==============================================================================
--- head/share/man/man4/syscons.4	Fri Feb 22 04:52:12 2019	(r344457)
+++ head/share/man/man4/syscons.4	Fri Feb 22 06:41:47 2019	(r344458)
@@ -38,6 +38,7 @@
 .Cd "options SC_ALT_MOUSE_IMAGE"
 .Cd "options SC_CUT_SEPCHARS=_characters_"
 .Cd "options SC_CUT_SPACES2TABS"
+.Cd "options SC_DFLT_TERM"
 .Cd "options SC_DISABLE_KDBKEY"
 .Cd "options SC_DISABLE_REBOOT"
 .Cd "options SC_HISTORY_SIZE=N"
@@ -48,6 +49,9 @@
 .Cd "options SC_NO_PALETTE_LOADING"
 .Cd "options SC_NO_SUSPEND_VTYSWITCH"
 .Cd "options SC_NO_SYSMOUSE"
+.Cd "options SC_NO_TERM_DUMB"
+.Cd "options SC_NO_TERM_SC"
+.Cd "options SC_NO_TERM_SCTEKEN"
 .Cd "options SC_PIXEL_MODE"
 .Cd "options SC_TWOBUTTON_MOUSE"
 .Cd "options SC_NORM_ATTR=_attribute_"
@@ -285,6 +289,8 @@ This options instructs the driver to convert leading s
 when copying data into cut buffer.
 This might be useful to preserve
 indentation when copying tab-indented text.
+.It Dv SC_DFLT_TERM=_name_
+This option specifies the name of the preferred terminal emulator.
 .It Dv SC_DISABLE_KDBKEY
 This option disables the ``debug'' key combination (by default, it is
 .Dv Alt-Esc ,
@@ -409,6 +415,15 @@ will fail if this option is defined.
 This option implies the
 .Dv SC_NO_CUTPASTE
 option too.
+.It Dv SC_NO_TERM_DUMB
+.It Dv SC_NO_TERM_SC
+.It Dv SC_NO_TERM_SCTEKEN
+These options remove the
+.Qq dumb ,
+.Qq sc ,
+and
+.Qq scteken 
+terminal emulators, respectively.
 .El
 .Ss Driver Flags
 The following driver flags can be used to control the

Modified: head/sys/conf/NOTES
==============================================================================
--- head/sys/conf/NOTES	Fri Feb 22 04:52:12 2019	(r344457)
+++ head/sys/conf/NOTES	Fri Feb 22 06:41:47 2019	(r344458)
@@ -1488,6 +1488,7 @@ options 	MAXCONS=16		# number of virtual consoles
 options 	SC_ALT_MOUSE_IMAGE	# simplified mouse cursor in text mode
 options 	SC_DFLT_FONT		# compile font in
 makeoptions	SC_DFLT_FONT=cp850
+options 	SC_DFLT_TERM=\"sc\"	# default terminal emulator
 options 	SC_DISABLE_KDBKEY	# disable `debug' key
 options 	SC_DISABLE_REBOOT	# disable reboot key sequence
 options 	SC_HISTORY_SIZE=200	# number of history buffer lines
@@ -1518,6 +1519,9 @@ options 	SC_NO_HISTORY
 options 	SC_NO_MODE_CHANGE
 options 	SC_NO_SYSMOUSE
 options 	SC_NO_SUSPEND_VTYSWITCH
+#!options 	SC_NO_TERM_DUMB
+#!options 	SC_NO_TERM_SC
+#!options 	SC_NO_TERM_SCTEKEN
 
 # `flags' for sc
 #	0x80	Put the video card in the VESA 800x600 dots, 16 color mode

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Fri Feb 22 04:52:12 2019	(r344457)
+++ head/sys/conf/files	Fri Feb 22 06:41:47 2019	(r344458)
@@ -3133,7 +3133,9 @@ dev/syscons/rain/rain_saver.c	optional rain_saver
 dev/syscons/schistory.c		optional sc
 dev/syscons/scmouse.c		optional sc
 dev/syscons/scterm.c		optional sc
-dev/syscons/scterm-teken.c	optional sc
+dev/syscons/scterm-dumb.c	optional sc !SC_NO_TERM_DUMB
+dev/syscons/scterm-sc.c		optional sc !SC_NO_TERM_SC
+dev/syscons/scterm-teken.c	optional sc !SC_NO_TERM_TEKEN
 dev/syscons/scvidctl.c		optional sc
 dev/syscons/scvtb.c		optional sc
 dev/syscons/snake/snake_saver.c	optional snake_saver
@@ -4883,7 +4885,7 @@ security/mac_veriexec/mac_veriexec_sha1.c	optional mac
 security/mac_veriexec/mac_veriexec_sha256.c	optional mac_veriexec_sha256
 security/mac_veriexec/mac_veriexec_sha384.c	optional mac_veriexec_sha384
 security/mac_veriexec/mac_veriexec_sha512.c	optional mac_veriexec_sha512
-teken/teken.c			optional sc | vt
+teken/teken.c			optional sc !SC_NO_TERM_TEKEN | vt
 ufs/ffs/ffs_alloc.c		optional ffs
 ufs/ffs/ffs_balloc.c		optional ffs
 ufs/ffs/ffs_inode.c		optional ffs

Modified: head/sys/conf/options
==============================================================================
--- head/sys/conf/options	Fri Feb 22 04:52:12 2019	(r344457)
+++ head/sys/conf/options	Fri Feb 22 06:41:47 2019	(r344458)
@@ -767,6 +767,7 @@ SC_CUT_SPACES2TABS	opt_syscons.h
 SC_CUT_SEPCHARS		opt_syscons.h
 SC_DEBUG_LEVEL		opt_syscons.h
 SC_DFLT_FONT		opt_syscons.h
+SC_DFLT_TERM		opt_syscons.h
 SC_DISABLE_KDBKEY	opt_syscons.h
 SC_DISABLE_REBOOT	opt_syscons.h
 SC_HISTORY_SIZE		opt_syscons.h
@@ -780,6 +781,9 @@ SC_NO_HISTORY		opt_syscons.h
 SC_NO_MODE_CHANGE	opt_syscons.h
 SC_NO_SUSPEND_VTYSWITCH	opt_syscons.h
 SC_NO_SYSMOUSE		opt_syscons.h
+SC_NO_TERM_DUMB		opt_syscons.h
+SC_NO_TERM_SC		opt_syscons.h
+SC_NO_TERM_TEKEN	opt_syscons.h
 SC_NORM_ATTR		opt_syscons.h
 SC_NORM_REV_ATTR	opt_syscons.h
 SC_PIXEL_MODE		opt_syscons.h

Modified: head/usr.sbin/vidcontrol/vidcontrol.1
==============================================================================
--- head/usr.sbin/vidcontrol/vidcontrol.1	Fri Feb 22 04:52:12 2019	(r344457)
+++ head/usr.sbin/vidcontrol/vidcontrol.1	Fri Feb 22 06:41:47 2019	(r344458)
@@ -21,9 +21,10 @@
 .Nd system console control and configuration utility
 .Sh SYNOPSIS
 .Nm
-.Op Fl CdLHPpx
+.Op Fl CdHLPpx
 .Op Fl b Ar color
 .Op Fl c Ar appearance
+.Op Fl E Ar emulator
 .Oo
 .Fl f
 .Oo
@@ -282,6 +283,11 @@ Show the current changes.
 .El
 .It Fl d
 Print out current output screen map.
+.It Fl E Ar emulator
+Set the terminal emulator to
+.Ar emulator .
+.It Fl e
+Show the active and available terminal emulators.
 .It Xo
 .Fl f
 .Oo

Modified: head/usr.sbin/vidcontrol/vidcontrol.c
==============================================================================
--- head/usr.sbin/vidcontrol/vidcontrol.c	Fri Feb 22 04:52:12 2019	(r344457)
+++ head/usr.sbin/vidcontrol/vidcontrol.c	Fri Feb 22 06:41:47 2019	(r344458)
@@ -204,11 +204,11 @@ usage(void)
 "                  [foreground [background]] [show]");
 	else
 		fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n",
-"usage: vidcontrol [-CdHLPpx] [-b color] [-c appearance] [-f [size] file]",
-"                  [-g geometry] [-h size] [-i active | adapter | mode]",
-"                  [-l screen_map] [-M char] [-m on | off]",
-"                  [-r foreground background] [-S on | off] [-s number]",
-"                  [-T xterm | cons25] [-t N | off] [mode]",
+"usage: vidcontrol [-CdHLPpx] [-b color] [-c appearance] [-E emulator]",
+"                  [-f [[size] file]] [-g geometry] [-h size]",
+"                  [-i active | adapter | mode] [-l screen_map] [-M char]",
+"                  [-m on | off] [-r foreground background] [-S on | off]",
+"                  [-s number] [-T xterm | cons25] [-t N | off] [mode]",
 "                  [foreground [background]] [show]");
 	exit(1);
 }
@@ -1384,7 +1384,46 @@ clear_history(void)
 	}
 }
 
+static int
+get_terminal_emulator(int i, struct term_info *tip)
+{
+	tip->ti_index = i;
+	if (ioctl(0, CONS_GETTERM, tip) == 0)
+		return (1);
+	strlcpy(tip->ti_name, "unknown", sizeof(tip->ti_name));
+	strlcpy(tip->ti_desc, "unknown", sizeof(tip->ti_desc));
+	return (0);
+}
+
 static void
+get_terminal_emulators(void)
+{
+	struct term_info ti;
+	int i;
+
+	for (i = 0; i < 10; i++) {
+		if (get_terminal_emulator(i, &ti) == 0)
+			break;
+		printf("%d: %s (%s)%s\n", i, ti.ti_name, ti.ti_desc,
+		    i == 0 ? " (active)" : "");
+	}
+}
+
+static void
+set_terminal_emulator(const char *name)
+{
+	struct term_info old_ti, ti;
+
+	get_terminal_emulator(0, &old_ti);
+	strlcpy(ti.ti_name, name, sizeof(ti.ti_name));
+	if (ioctl(0, CONS_SETTERM, &ti) != 0)
+		warn("SETTERM '%s'", name);
+	get_terminal_emulator(0, &ti);
+	printf("%s (%s) -> %s (%s)\n", old_ti.ti_name, old_ti.ti_desc,
+	    ti.ti_name, ti.ti_desc);
+}
+
+static void
 set_terminal_mode(char *arg)
 {
 
@@ -1412,7 +1451,7 @@ main(int argc, char **argv)
 	if (vt4_mode)
 		opts = "b:Cc:fg:h:Hi:M:m:pPr:S:s:T:t:x";
 	else
-		opts = "b:Cc:dfg:h:Hi:l:LM:m:pPr:S:s:T:t:x";
+		opts = "b:Cc:deE:fg:h:Hi:l:LM:m:pPr:S:s:T:t:x";
 
 	while ((opt = getopt(argc, argv, opts)) != -1)
 		switch(opt) {
@@ -1429,6 +1468,16 @@ main(int argc, char **argv)
 			if (vt4_mode)
 				break;
 			print_scrnmap();
+			break;
+		case 'E':
+			if (vt4_mode)
+				break;
+			set_terminal_emulator(optarg);
+			break;
+		case 'e':
+			if (vt4_mode)
+				break;
+			get_terminal_emulators();
 			break;
 		case 'f':
 			optarg = nextarg(argc, argv, &optind, 'f', 0);


More information about the svn-src-all mailing list