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 (:

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 15:50:29 -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;
@@ -1209,9 +1209,14 @@ 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;
+               if (attr & WSATTR_REVERSE) {
+                       a.in.fg_colour = STI_COLOUR_BLACK;
+                       a.in.bg_colour = STI_COLOUR_WHITE;
+               } else {
+                       a.in.fg_colour = STI_COLOUR_WHITE;
+                       a.in.bg_colour = STI_COLOUR_BLACK;
+               }
+
                a.in.x = col * fp->width;
                a.in.y = row * fp->height;
                a.in.font_addr = scr->scr_romfont;
@@ -1231,9 +1236,13 @@ 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;
+               if (attr & WSATTR_REVERSE) {
+                       a.in.fg_colour = STI_COLOUR_BLACK;
+                       a.in.bg_colour = STI_COLOUR_WHITE;
+               } else {
+                       a.in.fg_colour = STI_COLOUR_WHITE;
+                       a.in.bg_colour = STI_COLOUR_BLACK;
+               }
 
                a.in.srcx = ((uc - fp->first) / scr->scr_fontmaxcol) *
                    fp->width + scr->scr_fontbase;
@@ -1309,7 +1318,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 +1329,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 = WSCOL_BLACK;
+               *bg = WSCOL_WHITE;
+       } else {
+               *fg = WSCOL_WHITE;
+               *bg = WSCOL_BLACK;
+       }
        if (ul != NULL)
                *ul = 0;
 }

Reply via email to