[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LYNX-DEV bold, underline, reverse, colors in Lynx

From: Klaus Weide
Subject: LYNX-DEV bold, underline, reverse, colors in Lynx
Date: Wed, 26 Mar 1997 13:39:15 -0600 (CST)

There have been several questions about character attributes in the last
days.  Below is a text I started writing to clarify my omn understanding
of this stuff.  I'll also put a copy under
<URL:>.  If somebody wants to massage
this into a more accessible help text, please do.


Here's an attempt to summarize the behavior of Lynx as far as display
character attributes (including color attributes) are concerned.

This doesn't take into account at all Rob Partington's character style
patches.  When they are used this table probably is obsolete.

This may also not properly take account of latest changes in the
development code.  The basis for the described behavior is 
Lynx 2.6 and 2.7.  The description is based more on looking at the
code than on extensive testing.  But I am trying to capture current
behavior, not possibilities and hooks in the code which are not used
in the code as distributed (e.g. HTStyle mechanisms).  I also leave
out discussion of -blink, not to complicate matters further.
The color-ncurses case is not covered (still too much in flux).
Some exceptions for specific systems ore not covered (HP_TERMINAL).

Oh, and I am making no judgement whether the behavior I find makes

There will be inaccuracies.  Please submit corrections.  But note that
just stating "I don't see what you describe on system xxx" isn't a
valid correction unless you have properly taken account of all factors
outside of Lynx (see (B) below), which is difficult.


On a first level, the Lynx code uses various character styles which I
call {N}, {U}, {B}, etc. below; see table "Lynx usage".
({N}, {U}, {B}, {R} _approximately_ stand for
normal,underline,bold,reverse, but see below for the hairy details.)

Now, it would be nice if it were that simple.  But whether _you_ see
{U}, {B}, etc. as underline, bold, etc., or maybe something else (or not
at all) depends on several additional factors, among them
(A) how Lynx is compiled and configured, and
(B) things outside of Lynx's control: your display library, terminal
    type (TERM environment variable), terminfo or termcap entry etc.
Both of these areas can (and most likely do) add additional mappings.

Lynx usage (a)      Abbr. function call or Macro used to set
========            ----   ------------ ----------------------------------
normal text         Norm   {N}          standend()
markup emphasis(b)  Emph   {U}          start_underline()
link (c)            Link   {B}          start_bold()
link in emphasis(d) EmLk   {U+B}        start_underline(),start_bold()
selected link       Sel    {R'}         start_reverse()[,start_underline()]
status line         Stat   {R}          start_reverse()
standout (e)        Stdo   {S}          standout()

(a) a representative use, not comprehensive
(b) used for EM, STRONG, B, I, U elements etc.
(c) everything that can be "selected" and (normally) followed as a
    link; also for A elements without HREF attribute (used as link targets)
    if BOLD_NAME_ANCHORS set TRUE in lynx.cfg; also possibly for headings 
    H1, H2 etc. depending on BOLD_HEADERS and BOLD_H1 in lynx.cfg.
(d) Will "forget" the emphasis after selecting then deselecting
    ("moving over the link")
(e) used on Options screen prompt and messages

(A)  How Lynx maps character styles

            simple-mono curses-mono curses-mono-UL slang-mono  slang-color
 Norm {N}    N           N           N              N           COLOR:0
 Emph {U}    S           U           B              U           U+COLOR:4
 Link {B}    S           B           U              B           COLOR:1
 EmLk {U+B}  S           U+B         U+B            U+B         U+COLOR:5
 Sel  {R'}   S           R           R              U+R         COLOR:6
 Stat {R}    S           R           R              R           COLOR:2
 Stdo {S}    S           S           S              R           COLOR:2
 not used                                                       COLOR:3
 not used                                                       COLOR:7

 simple-mono:     compiled with neither of -DFANCY_CURSES or -DUSE_SLANG
 curses-mono:     -DFANCY_CURSES (or VMS) and not -DUSE_SLANG
 curses-mono-UL:  as curses-mono, but -DUNDERLINE_LINKS in addition
 slang-mono:      -DUSE_SLANG, and TERM or -term indicates monochrome display
 slang-color:     -DUSE_SLANG, and TERM or -term or COLORTERM
                      environment variable indicates color display
 N, S, U, B, R:   Set character attributes on display for normal, standout,
                      underline, bold, reverse, as defined in terminfo
                      (or termcap) description for current terminal. 
 COLOR:n:         Set color fg/bg pair as defined by lynx.cfg setting
                      for COLOR:n *and* terminfo (or termcap) description.
 Note that a COLOR:n may imply a B attribute (if the color pair has a
 bright fg color), and that "bright"-ness of bg color is ignored.
 Also note that for slang-color, an U attribute is set for Emph and EmLk
 *in adddition to* whatever the definitions for COLOR:4 and COLOR:5 are.

(B)  What happens to character attributes outside of Lynx

The U[NDERLINE], B[OLD], R[EVERSE] etc. attributes and combinations
which appear in the table above are translated into escape sequences
(supposedly) understood by the terminal type. (This may be different
for non-Unix ports.)  So one could create a special terminfo/termcap
terminal definition that displays e.g. "B" as blinking (if the real
terminal or emulator in use supports an escape sequence to turn
blinking on).  Or one could get some color effects without using SLang
or color-curses, by just mappping the mono attributes B, U, R to
appropriate escape sequences (again depending on hardware of course).

On the other hand, the terminal type in use (and its terminfo/termcap
definition) may be responsible if, contrary to your expectations, your
display doesn't show B as bold and U as underlined and R as inverse.
(Of course it may also be that support for these attributes by the
hardware or emulator is insufficient.)

The same goes for SLang COLORs.  When lynx wants to change the fg/bg
combination for writing to the screen this is translated to an escape
sequence, according to what SLang knows about your terminal.  (It
makes some "ANSI"-ish default assumptions about this if forced to do
color with -color and COLORTERM when the terminfo entry doesn't
support color setting.)  In addition the implied intensity bit (if the
fg color is a bright one) is translated to the appropriate sequence
for B.

As a concrete example, here is how this works out on a linux console
(reference is 2.0.6, i386 and standard (color) VGA kernel support;
"linux" terminfo definition as in recent terminfo source distribution).

The U, B, and R attributes are sent to the screen as vt100-like escapes
("\e[4m", "\e[1m", and "\e[7m", respectively to turn them on).  But
the hardware (or the kernel console driver) doesn't really support an
underline attribute independent of colors; so when the VGA hardware is
in color mode, "underlining" is just represented as a specific
foreground color (incl. intensity bit).  (This is done by the linux
kernel's driver, neither Lynx nor the terminfo description have
knowledge or control of it.)  By default the color used for
underlining is bright white, so that "underlined" text cannot be
visually distinguished from "bold" white-on-dark text.  (The default
color for underlining can be changed with the setterm utility
program.)  Furthermore, this simulated "underlining" effectively
overrides whatever foreground color has been set (except for the
intensity bit).  Which means that with color-slang Lynx the
foreground settings of COLOR:4 and COLOR:5 are useless, since they are
only used in combination with an explicit "U" setting...
I leave out details of the intensity-bit ("bold" or "bright")
handling, except for noting that with default settings for ulcolor and
lynx.cfg COLOR:, emphasised text under slang-color Lynx becomes
completely unvisible if the console is in 512-character-font mode
(which makes intensity distinction unavailable)...


In summary, here's what you can do if running Lynx doesn't give you
the attributes (color or otherwise) you want:  [in my subjective rough
order of preference]

* Check whether the TERM variable (or -term command line option) is
  the right one for the terminal or terminal emulator and
  communication software you are using, and whether there is an
  alternative one you can use.
* Check whether the terminfo/termcap description is correct, and maybe
  get a better (or newer) one.
* If your terminal emulation software can't do what you want, try a
  different program.
* If using Lynx color support, play around with different settings for
  COLOR:n in lynx.cfg.  
  And/or if using TERM="linux", experiment with `setterm -ulcolor'.
* Try to compile with latest (beta?) ncurses.
* Get the latest development Lynx sources and try the experimental
  color-curses support.
* Read this text and try to understand it...
* Create your own terminfo/termcap description, according to your needs.
* Modify your copy of the Lynx sources according to your needs.
  A relatively simple way might be to change the definitions for 
  {start,stop}_{underline,bold,reverse} in src/LYCurses.h, instead of
  messing around with all the different places where these are used.
* Tell Tom Dickey <address@hidden> (or, in the case of the
  MS-Win32/DOS ports, Wayne Buttles <address@hidden>) what
  you want, in case the Lynx code's attribute handling prevents you
  from getting what you want.  They may or may not listen to you,
  or have a solution.
* Come up with a great way to make Lynx's handling of attributes and
  colors simpler while at the same time making it more configurable,
  covering all special cases, not breaking currently installed
  configurations, and leaving the door open for future integration of
  stylesheet-based handling.  Submit patches and become a hero.

; To UNSUBSCRIBE:  Send a mail message to address@hidden
;                  with "unsubscribe lynx-dev" (without the
;                  quotation marks) on a line by itself.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]