From owner-freebsd-bugs@FreeBSD.ORG Sat May 14 11:04:56 2011 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7675A106566C; Sat, 14 May 2011 11:04:56 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail09.syd.optusnet.com.au (mail09.syd.optusnet.com.au [211.29.132.190]) by mx1.freebsd.org (Postfix) with ESMTP id 1575F8FC08; Sat, 14 May 2011 11:04:55 +0000 (UTC) Received: from c122-106-158-76.carlnfd1.nsw.optusnet.com.au (c122-106-158-76.carlnfd1.nsw.optusnet.com.au [122.106.158.76]) by mail09.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p4EB4maf029800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 14 May 2011 21:04:53 +1000 Date: Sat, 14 May 2011 21:04:48 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Jens Schweikhardt In-Reply-To: <201105132045.p4DKj3Yd010018@red.freebsd.org> Message-ID: <20110514205451.M979@besplex.bde.org> References: <201105132045.p4DKj3Yd010018@red.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-bugs@freebsd.org, freebsd-gnats-submit@freebsd.org Subject: Re: bin/157017: "vidcontrol -r" no longer works X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 May 2011 11:04:56 -0000 On Fri, 13 May 2011, Jens Schweikhardt wrote: >> Description: > Apparently, "vidcontrol -r foreground background" no longer works. I don't know when exactly it stopped. > > I use it via /etc/rc.conf with > > allscreens_flags="-r cyan blue" > > The symptom is that running "man man" still uses black on white for reverse video instead of cyan and blue. My TERM is cons31l. syscons used to have independently programmable reverse video colors (tcp->rev_color for these and tcp->std_color for normal colors). This functionality has been lost, so all the escape sequences that depend on it are broken. Two of the broken escape sequences are "ESC [ = H" and "ESC [ = I", which are still used by vidcontrol -r. The main other ones are "ESC [ ; x", where is "5", "6" or "7". syscons should have had independendly programmable colors for all (non-color) "ANSI" attributes (i.e., for all of normal video, reverse video, blink and underline, not just for normal and reverse video). For consoles that don't support blink or underline, it fakes these attributes using colors (if these are available). Often it makes very poor choices for these colors and you can do better by choosing the colors yourself. This works best if the colors are never changed as pure colors. The "ESC [ ... x" sequences are old pc3 ones which were always supported by syscons until the breakage. In /etc/termcap, they seem to only be used for 'op' for pc3, and there only as "ESC [ x" which is short for "ESC [ 0 x" which means "reset colors to defaults". The independently programmable colors are not really used by this -- the independent programming is just undone. The one with "5" selector is equivalent to "ESC [ I" and the one with the "6" selector is equivalent to "ESC [ H". The only differences are that the "x" sequences are less verbose and use the "IBM PC" color mapping, while the "H/I" sequences use the "ANSI" color mapping. Other "x" selectors provided functionality that is either not available or more verbosely available near the "H/I" sequences. It is a feature that there is no "ANSI" sequence equivalent to "ESC [ 0 x". This makes settings of the reverse colors fairly sticky, so that they are not clobbered by other "ANSI" color sequences. Apart "ESC [ 0 x", only a terminal reset ("ESC c") clobbers the reverse color settings. I don't use vidcontrol -r, but have used the "x" escape sequences to set sticky reverse colors in syscons for almost 20 years, and similar sequences, some written by me, in other drivers/OS's for another 5 years. Now I use the following in ~/.profile. It partially works around the broken "x" sequences by using "ANSI" colors more. % case $TERM in % cons25) % printf '\033[x\033[2;6x\033[1;0x\033[6;7x\033[5;4x' The old version just uses this "x" sequence. It does: 0) reset normal and reverse colors to defaults 2) set normal foreground color 1) set normal background color 6) set reverse foreground color 5) set reverse background color This still works with old kernels. IIRC, the "x" sequences are silentl yignored by now kernels for all selectors, although the functionality for implementing them has only been lost for the reverse color selectors. % printf '\033[=3F\033[=0G' These "F" and "G" sequences do as much as possible with the unbroken sequences near the "H" and "I" ones -- just set the normal foreground and background colors. This just repeats the settings made by "2x" and "1x" on old kernels. Don't bother trying to use the "H" and "I" sequences corresponding to "6x" and "5x", since at best they are silently ignored on new kernels. % ;; % linux) % printf '\033[36;40m\033[1;4]\033[8]' Start by setting some "ANSI" colors. I forget what the "]" sequence does. It may even work. % ;; % esac % case $TERM in % cons25) % TERMCAP="$TERM:md=\E[1;37m:so=\E[37;44m:se=\E[39;49m:us=\E[1;33;44m:ue=\E[22;39;49m:tc=$TERM:" % ;; % esac Hack on termcap to set and restore "ANSI" colors the same as the "x" sequence would do if it weren't broken, plus handle underline like the "x" sequence should be able to do. Blink doesn't seem to be mappable to termcap, so don't do anything for it. Fixing this, and using termcap, actually improved the rendition of man pages, but it loses the stickiness feature. I had to be more careful with the color choices for normal and reverse, and used the same method to improve underline. Unlike unbroken "x" sequences, this only works if termcap is used. Then it works fairly well -- the attribute "end" sequences just need to reset to whatever the "x" sequences would give. The main problem with this is that the system termcap can't hard-code individual users' color choices like this. Bruce