Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Oct 2002 18:22:25 +0300
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        "Andrey A. Chernov" <ache@nagual.pp.ru>
Cc:        Alexey Dokuchaev <danfe@nsu.ru>, Giorgos Keramidas <keramida@ceid.upatras.gr>, "Greg 'groggy' Lehey" <grog@FreeBSD.org>, Tony Finch <dot@dotat.at>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: Coloured manpages (was: Re: cvs commit: src/gnu/usr.bin/man Makefile.inc src/share/mk bsd.man.mk src/usr.bin/catman catman.c)
Message-ID:  <20021016152225.GA98692@sunbay.com>
In-Reply-To: <20021016095351.GB8009@nagual.pp.ru>
References:  <200210110916.g9B9GP8f064951@freefall.freebsd.org> <20021012040759.A23338@chiark.greenend.org.uk> <20021012155812.GA36832@sunbay.com> <20021013003257.GA64063@wantadilla.lemis.com> <20021013081038.GA14919@sunbay.com> <20021015094930.GB2083@hades.hell.gr> <20021015143304.GB12329@sunbay.com> <20021016023059.GD72251@regency.nsu.ru> <20021016095351.GB8009@nagual.pp.ru>

next in thread | previous in thread | raw e-mail | index | archive | help

--iFRdW5/EC4oqxDHL
Content-Type: multipart/mixed; boundary="KFztAG8eRSV9hGtP"
Content-Disposition: inline


--KFztAG8eRSV9hGtP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Oct 16, 2002 at 01:53:51PM +0400, Andrey A. Chernov wrote:
> On Wed, Oct 16, 2002 at 09:30:59 +0700, Alexey Dokuchaev wrote:
> >=20
> > Could we patch /usr/share/misc/termcap maybe (cons25w entry)?  This will
> > leave xterm along (since it does play nicely already) and console output
> > will get prettier.
>=20
> Any syscons or cons25 entry patch in this way will break color support,
> occuping some valid colors to emulate missing underline. Occuping some
> valid attribute (like now) is lesser evil for color-enabled application.
>=20
> Better way is to NOT emulate it in any way. Termcap database is for
> describing existen capabilities, not for emulating non-existen in
> destructive way. Application must do emulation by itself.=20
>=20
> I.e. underline should be written to the file as
>=20
> 	<character>^H_
>=20
> (in device-independent form) and browser (less) should emulate missing=20
> underline using some existent attribute or color.
>=20
I tend to agree, but still, what do we do with the color support in
grotty(1)?

Does anyone here also think that having a mode that prints bold and
italic characters the old way (see above) but with the color output
enabled would be useful?  (The attached patch implements this.)  If
so, should we use this mode by default when generating catpages, or
not?  If not, should we provide a knob for man(1) that would allow
one to?  What should it be?  I initially thought to use the CLICOLOR
environment variable that is already recognized by ls(1), but now I
am not so sure this is a good idea.

(Compare ``nroff -c -man grotty.1 |less -R'' with and without this
patch applied.)


Cheers,
--=20
Ruslan Ermilov		Sysadmin and DBA,
ru@sunbay.com		Sunbay Software AG,
ru@FreeBSD.org		FreeBSD committer,
+380.652.512.251	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age

--KFztAG8eRSV9hGtP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=p
Content-Transfer-Encoding: quoted-printable

Index: grotty.man
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/contrib/groff/src/devices/grotty/grotty.man,v
retrieving revision 1.7
diff -u -p -r1.7 grotty.man
--- grotty.man	14 Oct 2002 09:15:17 -0000	1.7
+++ grotty.man	16 Oct 2002 12:08:16 -0000
@@ -87,7 +87,7 @@ and white for the background).
 .LP
 Use the
 .B \-c
-switch to revert to the old behaviour, printing a bold character
+option to revert to the old behaviour, printing a bold character
 .I c
 with the sequence
 .RI ` c
@@ -99,7 +99,9 @@ by the sequence
 .RB ` _
 .SM BACKSPACE
 .IR c '.
-At the same time, color output is disabled.
+If
+.B \-c
+is specified more than once, color output is also disabled.
 The same effect can be achieved by setting either the
 .B GROFF_NO_SGR
 environment variable or using the `sgr' X command (see below).
@@ -203,7 +205,7 @@ isn't used.
 Use
 .BR grotty 's
 old output format (see above).
-This also disables color output.
+If specified more than once, also disables color output.
 .
 .TP
 .B \-d
Index: tty.cc
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/contrib/groff/src/devices/grotty/tty.cc,v
retrieving revision 1.1.1.4
diff -u -p -r1.1.1.4 tty.cc
--- tty.cc	14 Oct 2002 09:12:27 -0000	1.1.1.4
+++ tty.cc	16 Oct 2002 12:08:16 -0000
@@ -44,6 +44,7 @@ static int draw_flag =3D 1;
 static int italic_flag =3D 0;
 static int reverse_flag =3D 0;
 static int old_drawing_scheme =3D 0;
+static int color_output =3D 1;
=20
 enum {
   UNDERLINE_MODE =3D 0x01,
@@ -391,8 +392,10 @@ void tty_printer::special(char *arg, con
     for (; *p =3D=3D ' ' || *p =3D=3D '\n'; p++)
       ;
     int n;
-    if (*p !=3D '\0' && sscanf(p, "%d", &n) =3D=3D 1 && n =3D=3D 0)
+    if (*p !=3D '\0' && sscanf(p, "%d", &n) =3D=3D 1 && n =3D=3D 0) {
       old_drawing_scheme =3D 1;
+      color_output =3D 0;
+    }
     else
       old_drawing_scheme =3D 0;
   }
@@ -602,7 +605,7 @@ void tty_printer::end_page(int page_leng
       }
       assert(hpos =3D=3D p->hpos);
       if (p->mode & COLOR_CHANGE) {
-	if (!old_drawing_scheme) {
+	if (color_output) {
 	  if (p->fore_color_idx !=3D curr_fore_idx) {
 	    put_color(p->fore_color_idx, 0);
 	    curr_fore_idx =3D p->fore_color_idx;
@@ -631,7 +634,7 @@ void tty_printer::end_page(int page_leng
 	putstring(SGR_NO_BOLD);
 	is_bold =3D 0;
       }
-      if (!old_drawing_scheme) {
+      if (color_output) {
 	if (p->fore_color_idx !=3D curr_fore_idx) {
 	  put_color(p->fore_color_idx, 0);
 	  curr_fore_idx =3D p->fore_color_idx;
@@ -644,10 +647,10 @@ void tty_printer::end_page(int page_leng
       put_char(p->code);
       hpos++;
     }
-    if (!old_drawing_scheme
-	&& (is_bold || is_underline
-	    || curr_fore_idx !=3D DEFAULT_COLOR_IDX
-	    || curr_back_idx !=3D DEFAULT_COLOR_IDX))
+    if ((!old_drawing_scheme && (is_bold || is_underline))
+	 || (color_output
+	     && (curr_fore_idx !=3D DEFAULT_COLOR_IDX
+		 || curr_back_idx !=3D DEFAULT_COLOR_IDX)))
       putstring(SGR_DEFAULT);
     putchar('\n');
   }
@@ -677,8 +680,10 @@ int main(int argc, char **argv)
 {
   program_name =3D argv[0];
   static char stderr_buf[BUFSIZ];
-  if (getenv("GROFF_NO_SGR"))
+  if (getenv("GROFF_NO_SGR")) {
     old_drawing_scheme =3D 1;
+    color_output =3D 0;
+  }
   setbuf(stderr, stderr_buf);
   int c;
   static const struct option long_options[] =3D {
@@ -702,8 +707,14 @@ int main(int argc, char **argv)
       bold_flag =3D 0;
       break;
     case 'c':
-      // Use old scheme for emboldening and underline.
-      old_drawing_scheme =3D 1;
+      if (!old_drawing_scheme) {
+	// Use old scheme for emboldening and underline.
+	old_drawing_scheme =3D 1;
+      }
+      else {
+	// Disable color output.
+	color_output =3D 0;
+      }
       break;
     case 'u':
       // Do not underline.

--KFztAG8eRSV9hGtP--

--iFRdW5/EC4oqxDHL
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE9rYQxUkv4P6juNwoRAr6tAKCApWQFQrBC/OWHVRfpxEl6s2rQsQCdHdi+
GSt/nvJ4HlZeQ9WLQdQDgiw=
=a+lU
-----END PGP SIGNATURE-----

--iFRdW5/EC4oqxDHL--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021016152225.GA98692>