svn commit: r322709 - in head/sys: dev/syscons sys
Bruce Evans
bde at FreeBSD.org
Sat Aug 19 23:13:35 UTC 2017
Author: bde
Date: Sat Aug 19 23:13:33 2017
New Revision: 322709
URL: https://svnweb.freebsd.org/changeset/base/322709
Log:
Fix setting of defaults for the text cursor.
There was already a per-vty defaults field, but it was useless since it was
only initialized when propagating the global settings and thus no different
from the current global settings and not per-vty. The global defaults field
was also invariant after boot time, but not quite so useless.
Fix this by adding a second selection bit the the control flags of the
relevant ioctl(). vidcontrol doesn't support this yet. Setting either
default propagates the change to the current setting for the same level
and then to all lower levels.
Improve the 3-way escape sequence used by termcap to control the cursor.
The "normal" (ve) case has always used reset, so the user could set
it to anything, but since the reset is to a global value this is not
very useful, especially since the "very visible" (vs) case doesn't
reset but inconsistently forces to a blinking block. Change vs to
first reset and then XOR the blinking bit so that it is predictably
different from ve.
Modified:
head/sys/dev/syscons/scterm-teken.c
head/sys/dev/syscons/syscons.c
head/sys/sys/consio.h
Modified: head/sys/dev/syscons/scterm-teken.c
==============================================================================
--- head/sys/dev/syscons/scterm-teken.c Sat Aug 19 21:40:42 2017 (r322708)
+++ head/sys/dev/syscons/scterm-teken.c Sat Aug 19 23:13:33 2017 (r322709)
@@ -684,7 +684,6 @@ scteken_param(void *arg, int cmd, unsigned int value)
static int tcattrs[] = {
CONS_RESET_CURSOR | CONS_LOCAL_CURSOR, /* normal */
CONS_HIDDEN_CURSOR | CONS_LOCAL_CURSOR, /* invisible */
- CONS_BLINK_CURSOR | CONS_LOCAL_CURSOR, /* very visible */
};
scr_stat *scp = arg;
int flags, n, v0, v1, v2;
@@ -727,6 +726,13 @@ scteken_param(void *arg, int cmd, unsigned int value)
case TP_SETLOCALCURSOR:
if (value < sizeof(tcattrs) / sizeof(tcattrs[0]))
sc_change_cursor_shape(scp, tcattrs[value], -1, -1);
+ else if (value == 2) {
+ sc_change_cursor_shape(scp,
+ CONS_RESET_CURSOR | CONS_LOCAL_CURSOR, -1, -1);
+ flags = scp->base_curs_attr.flags ^ CONS_BLINK_CURSOR;
+ sc_change_cursor_shape(scp,
+ flags | CONS_LOCAL_CURSOR, -1, -1);
+ }
break;
case TP_SHOWCURSOR:
if (value != 0)
Modified: head/sys/dev/syscons/syscons.c
==============================================================================
--- head/sys/dev/syscons/syscons.c Sat Aug 19 21:40:42 2017 (r322708)
+++ head/sys/dev/syscons/syscons.c Sat Aug 19 23:13:33 2017 (r322709)
@@ -943,13 +943,19 @@ sctty_ioctl(struct tty *tp, u_long cmd, caddr_t data,
return 0;
case CONS_GETCURSORSHAPE: /* get cursor shape (new interface) */
- switch (((int *)data)[0] & CONS_LOCAL_CURSOR) {
+ switch (((int *)data)[0] & (CONS_DEFAULT_CURSOR | CONS_LOCAL_CURSOR)) {
case 0:
cap = &sc->curs_attr;
break;
case CONS_LOCAL_CURSOR:
cap = &scp->base_curs_attr;
break;
+ case CONS_DEFAULT_CURSOR:
+ cap = &sc->dflt_curs_attr;
+ break;
+ case CONS_DEFAULT_CURSOR | CONS_LOCAL_CURSOR:
+ cap = &scp->dflt_curs_attr;
+ break;
}
((int *)data)[1] = cap->base;
((int *)data)[2] = cap->height;
@@ -3030,7 +3036,10 @@ change_cursor_shape(scr_stat *scp, int flags, int base
if (flags & CONS_RESET_CURSOR)
scp->base_curs_attr = scp->dflt_curs_attr;
- else
+ else if (flags & CONS_DEFAULT_CURSOR) {
+ sc_adjust_ca(&scp->dflt_curs_attr, flags, base, height);
+ scp->base_curs_attr = scp->dflt_curs_attr;
+ } else
sc_adjust_ca(&scp->base_curs_attr, flags, base, height);
if ((scp == scp->sc->cur_scp) && !ISGRAPHSC(scp)) {
@@ -3062,7 +3071,10 @@ sc_change_cursor_shape(scr_stat *scp, int flags, int b
sc = scp->sc;
if (flags & CONS_RESET_CURSOR)
sc->curs_attr = sc->dflt_curs_attr;
- else
+ else if (flags & CONS_DEFAULT_CURSOR) {
+ sc_adjust_ca(&sc->dflt_curs_attr, flags, base, height);
+ sc->curs_attr = sc->dflt_curs_attr;
+ } else
sc_adjust_ca(&sc->curs_attr, flags, base, height);
for (i = sc->first_vty; i < sc->first_vty + sc->vtys; ++i) {
Modified: head/sys/sys/consio.h
==============================================================================
--- head/sys/sys/consio.h Sat Aug 19 21:40:42 2017 (r322708)
+++ head/sys/sys/consio.h Sat Aug 19 23:13:33 2017 (r322709)
@@ -187,6 +187,7 @@ typedef struct mouse_info mouse_info_t;
#define CONS_HIDDEN_CURSOR (1 << 2)
#define CONS_CURSOR_ATTRS (CONS_BLINK_CURSOR | CONS_CHAR_CURSOR | \
CONS_HIDDEN_CURSOR)
+#define CONS_DEFAULT_CURSOR (1 << 28)
#define CONS_SHAPEONLY_CURSOR (1 << 29)
#define CONS_RESET_CURSOR (1 << 30)
#define CONS_LOCAL_CURSOR (1U << 31)
More information about the svn-src-head
mailing list