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.
This commit is contained in:
Bruce Evans 2017-08-19 23:13:33 +00:00
parent 4ea1f4f5ea
commit 36e19a0f8c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=322709
3 changed files with 23 additions and 4 deletions

View File

@ -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)

View File

@ -943,13 +943,19 @@ sctty_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
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, int height)
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 base, int height)
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) {

View File

@ -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)