On Sat, May 05, 2012 at 16:07 +0000, Miod Vallat wrote:
> > add support for the WSATTR_REVERSE attribute to sti(4) to make mg,
> > less and others a bit prettier. tested on visualize fx 10 pro where
> > this email was written.
> > 
> > tests on other sti's are welcome as well as oks (:
> 
> This is a good start, but sti_putchar() really ought to invoke
> sti_unpack_attr() to get the appropriate color codes. This would also
> result in less duplicated code.
> 
> Miod

with a bunch of advices from miod, here's a new diff:

Index: dev/ic/sti.c
===================================================================
RCS file: /home/cvs/src/sys/dev/ic/sti.c,v
retrieving revision 1.64
diff -u -p -r1.64 sti.c
--- dev/ic/sti.c        19 Sep 2011 11:15:18 -0000      1.64
+++ dev/ic/sti.c        5 May 2012 22:04:43 -0000
@@ -618,7 +618,7 @@ sti_screen_setup(struct sti_screen *scr,
        scr->scr_wsd.textops = &sti_emulops;
        scr->scr_wsd.fontwidth = scr->scr_curfont.width;
        scr->scr_wsd.fontheight = scr->scr_curfont.height;
-       scr->scr_wsd.capabilities = 0;
+       scr->scr_wsd.capabilities = WSSCREEN_REVERSE;
 
        scr->scr_scrlist[0] = &scr->scr_wsd;
        scr->scr_screenlist.nscreens = 1;
@@ -1195,6 +1195,7 @@ sti_putchar(void *v, int row, int col, u
        struct sti_screen *scr = (struct sti_screen *)v;
        struct sti_rom *rom = scr->scr_rom;
        struct sti_font *fp = &scr->scr_curfont;
+       int bg, fg;
 
        if (scr->scr_romfont != NULL) {
                /*
@@ -1209,9 +1210,10 @@ sti_putchar(void *v, int row, int col, u
                bzero(&a, sizeof(a));
 
                a.flags.flags = STI_UNPMVF_WAIT;
-               /* XXX does not handle text attributes */
-               a.in.fg_colour = STI_COLOUR_WHITE;
-               a.in.bg_colour = STI_COLOUR_BLACK;
+               sti_unpack_attr(scr, attr, &fg, &bg, NULL);
+               a.in.fg_colour = fg;
+               a.in.bg_colour = bg;
+
                a.in.x = col * fp->width;
                a.in.y = row * fp->height;
                a.in.font_addr = scr->scr_romfont;
@@ -1231,9 +1233,9 @@ sti_putchar(void *v, int row, int col, u
                bzero(&a, sizeof(a));
 
                a.flags.flags = STI_BLKMVF_WAIT;
-               /* XXX does not handle text attributes */
-               a.in.fg_colour = STI_COLOUR_WHITE;
-               a.in.bg_colour = STI_COLOUR_BLACK;
+               sti_unpack_attr(scr, attr, &fg, &bg, NULL);
+               a.in.fg_colour = fg;
+               a.in.bg_colour = bg;
 
                a.in.srcx = ((uc - fp->first) / scr->scr_fontmaxcol) *
                    fp->width + scr->scr_fontbase;
@@ -1309,7 +1311,7 @@ sti_alloc_attr(void *v, int fg, int bg, 
        struct sti_screen *scr = (struct sti_screen *)v;
 #endif
 
-       *pattr = 0;
+       *pattr = flags & WSATTR_REVERSE;
        return 0;
 }
 
@@ -1320,8 +1322,13 @@ sti_unpack_attr(void *v, long attr, int 
        struct sti_screen *scr = (struct sti_screen *)v;
 #endif
 
-       *fg = WSCOL_WHITE;
-       *bg = WSCOL_BLACK;
+       if (attr & WSATTR_REVERSE) {
+               *fg = STI_COLOUR_BLACK;
+               *bg = STI_COLOUR_WHITE;
+       } else {
+               *fg = STI_COLOUR_WHITE;
+               *bg = STI_COLOUR_BLACK;
+       }
        if (ul != NULL)
                *ul = 0;
 }

Reply via email to