From owner-svn-src-all@FreeBSD.ORG Thu Sep 3 16:31:12 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4232E106566C; Thu, 3 Sep 2009 16:31:12 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 30FCF8FC0A; Thu, 3 Sep 2009 16:31:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n83GVCYl038338; Thu, 3 Sep 2009 16:31:12 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n83GVCp9038333; Thu, 3 Sep 2009 16:31:12 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200909031631.n83GVCp9038333@svn.freebsd.org> From: Ed Schouten Date: Thu, 3 Sep 2009 16:31:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196786 - in head/sys: dev/syscons teken X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2009 16:31:12 -0000 Author: ed Date: Thu Sep 3 16:31:11 2009 New Revision: 196786 URL: http://svn.freebsd.org/changeset/base/196786 Log: Expose the TF_REVERSE flag to the console driver. Right now libteken processes TF_REVERSE internally and returns the toggled colors to the console driver. This isn't entirely correct. This means that the bold flag is always processed by the foreground color, while reversing should be done after the foreground color has been set to a brighter version by the bold flag. This is no problem with the syscons driver, because with VGA it only supports 16 foreground and 8 background colors. My WIP console driver reconfigures the graphics hardware to disable the blink functionality and uses 16 foreground and 16 background colors. This means that this driver will handle the TF_REVERSE flag a little different from what syscons does right now. Modified: head/sys/dev/syscons/scterm-teken.c head/sys/teken/teken.c head/sys/teken/teken.h head/sys/teken/teken_demo.c Modified: head/sys/dev/syscons/scterm-teken.c ============================================================================== --- head/sys/dev/syscons/scterm-teken.c Thu Sep 3 16:29:02 2009 (r196785) +++ head/sys/dev/syscons/scterm-teken.c Thu Sep 3 16:31:11 2009 (r196786) @@ -300,12 +300,20 @@ static unsigned int scteken_attr(const teken_attr_t *a) { unsigned int attr = 0; + teken_color_t fg, bg; + if (a->ta_format & TF_REVERSE) { + fg = a->ta_bgcolor; + bg = a->ta_fgcolor; + } else { + fg = a->ta_fgcolor; + bg = a->ta_bgcolor; + } if (a->ta_format & TF_BOLD) - attr |= fgcolors_bold[a->ta_fgcolor]; + attr |= fgcolors_bold[fg]; else - attr |= fgcolors_normal[a->ta_fgcolor]; - attr |= bgcolors[a->ta_bgcolor]; + attr |= fgcolors_normal[fg]; + attr |= bgcolors[bg]; #ifdef FG_UNDERLINE if (a->ta_format & TF_UNDERLINE) Modified: head/sys/teken/teken.c ============================================================================== --- head/sys/teken/teken.c Thu Sep 3 16:29:02 2009 (r196785) +++ head/sys/teken/teken.c Thu Sep 3 16:31:11 2009 (r196786) @@ -70,9 +70,6 @@ static FILE *df; #define teken_scs_switch(t, g) #endif /* TEKEN_XTERM && TEKEN_UTF8 */ -/* Private flags for teken_format_t. */ -#define TF_REVERSE 0x08 - /* Private flags for t_stateflags. */ #define TS_FIRSTDIGIT 0x01 /* First numeric digit in escape sequence. */ #define TS_INSERT 0x02 /* Insert mode. */ @@ -114,19 +111,10 @@ static inline void teken_funcs_putchar(teken_t *t, const teken_pos_t *p, teken_char_t c, const teken_attr_t *a) { - teken_attr_t ta; teken_assert(p->tp_row < t->t_winsize.tp_row); teken_assert(p->tp_col < t->t_winsize.tp_col); - /* Apply inversion. */ - if (a->ta_format & TF_REVERSE) { - ta.ta_format = a->ta_format; - ta.ta_fgcolor = a->ta_bgcolor; - ta.ta_bgcolor = a->ta_fgcolor; - a = &ta; - } - t->t_funcs->tf_putchar(t->t_softc, p, c, a); } @@ -134,21 +122,12 @@ static inline void teken_funcs_fill(teken_t *t, const teken_rect_t *r, const teken_char_t c, const teken_attr_t *a) { - teken_attr_t ta; teken_assert(r->tr_end.tp_row > r->tr_begin.tp_row); teken_assert(r->tr_end.tp_row <= t->t_winsize.tp_row); teken_assert(r->tr_end.tp_col > r->tr_begin.tp_col); teken_assert(r->tr_end.tp_col <= t->t_winsize.tp_col); - /* Apply inversion. */ - if (a->ta_format & TF_REVERSE) { - ta.ta_format = a->ta_format; - ta.ta_fgcolor = a->ta_bgcolor; - ta.ta_bgcolor = a->ta_fgcolor; - a = &ta; - } - t->t_funcs->tf_fill(t->t_softc, r, c, a); } Modified: head/sys/teken/teken.h ============================================================================== --- head/sys/teken/teken.h Thu Sep 3 16:29:02 2009 (r196785) +++ head/sys/teken/teken.h Thu Sep 3 16:31:11 2009 (r196786) @@ -54,6 +54,7 @@ typedef unsigned char teken_format_t; #define TF_BOLD 0x01 #define TF_UNDERLINE 0x02 #define TF_BLINK 0x04 +#define TF_REVERSE 0x08 typedef unsigned char teken_color_t; #define TC_BLACK 0 #define TC_RED 1 Modified: head/sys/teken/teken_demo.c ============================================================================== --- head/sys/teken/teken_demo.c Thu Sep 3 16:29:02 2009 (r196785) +++ head/sys/teken/teken_demo.c Thu Sep 3 16:31:11 2009 (r196786) @@ -121,6 +121,8 @@ printchar(const teken_pos_t *p) attr |= A_UNDERLINE; if (px->a.ta_format & TF_BLINK) attr |= A_BLINK; + if (px->a.ta_format & TF_REVERSE) + attr |= A_REVERSE; bkgdset(attr | COLOR_PAIR(px->a.ta_fgcolor + 8 * px->a.ta_bgcolor)); mvaddstr(p->tp_row, p->tp_col, str);