Rename scteken_revattr() to scteken_sc_to_te_attr(). scteken_revattr()

looked like it might handle reverse attributes, but it actually handles
conversion of attributes in the direction indicated by the new name.
Reverse attributes are just broken.

Rename scteken_attr() to scteken_te_to_sc_attr().  scteken_attr() looked
like it might give teken attributes, but it actually gives sc attributes.

Change scteken_te_to_sc_attr() to return int instead of unsigned int.
u_char would be enough, and it promotes to int, and syscons uses int
or u_short for its attributes everywhere else (u_short holds a shifted
form and it promotes to int too).
This commit is contained in:
Bruce Evans 2017-03-10 14:25:38 +00:00
parent 501b16854f
commit eeb7d30e06

View File

@ -51,8 +51,8 @@ __FBSDID("$FreeBSD$");
#include <teken/teken.h> #include <teken/teken.h>
static void scteken_revattr(unsigned char, teken_attr_t *); static void scteken_sc_to_te_attr(unsigned char, teken_attr_t *);
static unsigned int scteken_attr(const teken_attr_t *); static int scteken_te_to_sc_attr(const teken_attr_t *);
static sc_term_init_t scteken_init; static sc_term_init_t scteken_init;
static sc_term_term_t scteken_term; static sc_term_term_t scteken_term;
@ -176,7 +176,7 @@ scteken_puts(scr_stat *scp, u_char *buf, int len, int kernel)
if (kernel) { if (kernel) {
/* Use special colors for kernel messages. */ /* Use special colors for kernel messages. */
backup = *teken_get_curattr(&ts->ts_teken); backup = *teken_get_curattr(&ts->ts_teken);
scteken_revattr(sc_kattr(), &kattr); scteken_sc_to_te_attr(sc_kattr(), &kattr);
teken_set_curattr(&ts->ts_teken, &kattr); teken_set_curattr(&ts->ts_teken, &kattr);
teken_input(&ts->ts_teken, buf, len); teken_input(&ts->ts_teken, buf, len);
teken_set_curattr(&ts->ts_teken, &backup); teken_set_curattr(&ts->ts_teken, &backup);
@ -193,19 +193,19 @@ scteken_ioctl(scr_stat *scp, struct tty *tp, u_long cmd, caddr_t data,
{ {
teken_stat *ts = scp->ts; teken_stat *ts = scp->ts;
vid_info_t *vi; vid_info_t *vi;
unsigned int attr; int attr;
switch (cmd) { switch (cmd) {
case GIO_ATTR: /* get current attributes */ case GIO_ATTR: /* get current attributes */
*(int*)data = *(int*)data =
scteken_attr(teken_get_curattr(&ts->ts_teken)); scteken_te_to_sc_attr(teken_get_curattr(&ts->ts_teken));
return (0); return (0);
case CONS_GETINFO: /* get current (virtual) console info */ case CONS_GETINFO: /* get current (virtual) console info */
vi = (vid_info_t *)data; vi = (vid_info_t *)data;
if (vi->size != sizeof(struct vid_info)) if (vi->size != sizeof(struct vid_info))
return EINVAL; return EINVAL;
attr = scteken_attr(teken_get_defattr(&ts->ts_teken)); attr = scteken_te_to_sc_attr(teken_get_defattr(&ts->ts_teken));
vi->mv_norm.fore = attr & 0x0f; vi->mv_norm.fore = attr & 0x0f;
vi->mv_norm.back = (attr >> 4) & 0x0f; vi->mv_norm.back = (attr >> 4) & 0x0f;
vi->mv_rev.fore = vi->mv_norm.back; vi->mv_rev.fore = vi->mv_norm.back;
@ -225,7 +225,7 @@ scteken_default_attr(scr_stat *scp, int color, int rev_color)
teken_stat *ts = scp->ts; teken_stat *ts = scp->ts;
teken_attr_t ta; teken_attr_t ta;
scteken_revattr(color, &ta); scteken_sc_to_te_attr(color, &ta);
teken_set_defattr(&ts->ts_teken, &ta); teken_set_defattr(&ts->ts_teken, &ta);
} }
@ -321,7 +321,7 @@ static const unsigned char bgcolors[TC_NCOLORS] = {
}; };
static void static void
scteken_revattr(unsigned char color, teken_attr_t *a) scteken_sc_to_te_attr(unsigned char color, teken_attr_t *a)
{ {
teken_color_t fg, bg; teken_color_t fg, bg;
@ -360,10 +360,10 @@ scteken_revattr(unsigned char color, teken_attr_t *a)
} }
} }
static unsigned int static int
scteken_attr(const teken_attr_t *a) scteken_te_to_sc_attr(const teken_attr_t *a)
{ {
unsigned int attr = 0; int attr = 0;
teken_color_t fg, bg; teken_color_t fg, bg;
if (a->ta_format & TF_REVERSE) { if (a->ta_format & TF_REVERSE) {
@ -558,7 +558,7 @@ scteken_putchar(void *arg, const teken_pos_t *tp, teken_char_t c,
* characters. Simply print a space and assume that the left * characters. Simply print a space and assume that the left
* hand side describes the entire character. * hand side describes the entire character.
*/ */
attr = scteken_attr(a) << 8; attr = scteken_te_to_sc_attr(a) << 8;
if (a->ta_format & TF_CJK_RIGHT) if (a->ta_format & TF_CJK_RIGHT)
c = ' '; c = ' ';
#ifdef TEKEN_UTF8 #ifdef TEKEN_UTF8
@ -590,7 +590,7 @@ scteken_fill(void *arg, const teken_rect_t *r, teken_char_t c,
unsigned int width; unsigned int width;
int attr, row; int attr, row;
attr = scteken_attr(a) << 8; attr = scteken_te_to_sc_attr(a) << 8;
#ifdef TEKEN_UTF8 #ifdef TEKEN_UTF8
scteken_get_cp437(&c, &attr); scteken_get_cp437(&c, &attr);
#endif /* TEKEN_UTF8 */ #endif /* TEKEN_UTF8 */