Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Dec 2004 17:21:53 +0300 (MSK)
From:      Alex Kapranoff <kappa@rambler-co.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/75310: textproc/cdiff is useless on monochrome terminal
Message-ID:  <20041220142153.4F47B410C@capella.park.rambler.ru>
Resent-Message-ID: <200412201430.iBKEUZ7v081434@freefall.freebsd.org>

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

>Number:         75310
>Category:       ports
>Synopsis:       textproc/cdiff is useless on monochrome terminal
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 20 14:30:35 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Alex Kapranoff
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
Inner Mongolia
>Environment:
FreeBSD capella.park.rambler.ru 5.2-CURRENT FreeBSD 5.2-CURRENT #0: Tue Jun 15 17:17:42 MSD 2004     root@capella.rambler.stack.net:/usr/obj/usr/src/sys/CAPELLA  i386

	
>Description:
Make cdiff(1) even more cooler by adding support for monochrome and
greyscale terminals. The problem has annoyed me much for about half a year.
>How-To-Repeat:
	
>Fix:

The manpage diff looks ok, I derived it from mans in the base system,
but it is the first time I use mdoc macros.

Also, change code to return to normal attributes from "\e[m" to "\e[0m"
to be a little more standard.

diff -ruN /usr/ports/textproc/cdiff/src/cdiff.1 cdiff/src/cdiff.1
--- /usr/ports/textproc/cdiff/src/cdiff.1	Mon Mar 11 01:01:55 2002
+++ cdiff/src/cdiff.1	Mon Dec 20 17:10:25 2004
@@ -34,6 +34,7 @@
 .Nd show diffs with colors
 .Sh SYNOPSIS
 .Nm cdiff
+.Op Fl m
 .Op Ar diff ...
 .Sh DESCRIPTION
 .Nm
@@ -43,6 +44,11 @@
 .Xr less 1 .
 If used on a color terminal, it makes diffs much easier to read.
 There is also handling of "cvs annotate" in it.
+.Pp
+.Bl -tag -width Ds
+.It Fl m
+Use bold, reverse and underline codes (for monochrome terminals).
+.El
 .Sh AUTHORS
 .Nm
 was written by
diff -ruN /usr/ports/textproc/cdiff/src/cdiff.sh cdiff/src/cdiff.sh
--- /usr/ports/textproc/cdiff/src/cdiff.sh	Mon Mar 11 01:01:55 2002
+++ cdiff/src/cdiff.sh	Mon Dec 20 17:00:07 2004
@@ -1,4 +1,10 @@
 #!/bin/sh
+if [ "$1" = "-m" ]; then
+	shift;
+	CODES="4:7:1:1"
+else
+	CODES="1:34:31:35"
+fi
 (if [ "$1" != "" ]; then
     while [ "$1" != "" ]; do
     	case $1 in
@@ -13,20 +19,21 @@
     done
 else
 	cat
-fi) | perl -pe '
+fi) | perl -p -mconstant=CODES,${CODES} -e '
+($at, $m, $p, $c) = split /:/, CODES;
 while (s/\t/" " x (8 - ((length($`)-1) % 8))/e) {}
-s/^(\+.*)$/\033[31m$1\033[m/o;
-s/^(-.*)$/\033[34m$1\033[m/o
-	if !s/^(--- \d+,\d+ ----.*)$/\033[1m$1\033[m/o;
-s/^(\*\*\* \d+,\d+ *\*\*\*.*)$/\033[1m$1\033[m/o;
-s/^(\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*)$/\033[1m$1\033[m/o;
-s/^(!.*)$/\033[35m$1\033[m/o;
-s/^(@@.*$)/\033[1m$1\033[m/o;
+s/^(\+.*)$/\033[${p}m$1\033[0m/o;
+s/^(-.*)$/\033[${m}m$1\033[0m/o
+	if !s/^(--- \d+,\d+ ----.*)$/\033[1m$1\033[0m/o;
+s/^(\*\*\* \d+,\d+ *\*\*\*.*)$/\033[1m$1\033[0m/o;
+s/^(\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*)$/\033[1m$1\033[0m/o;
+s/^(!.*)$/\033[${c}m$1\033[0m/o;
+s/^(@@.*$)/\033[${at}m$1\033[0m/o;
 if (/^1.(\d+)(\s+\(\w+\s+\d{2}-\w{3}-\d{2}\):\s)(.*)/) {
 	$lastcol = $lastcol || 0;
 	$lastcol++ if defined($lastrev) && $lastrev != $1;
 	$lastrev = $1;
 	$lastcol %= 6;
-	$_ = "\033[3" . ($lastcol + 1) . "m1.$1$2\033[m$3\n";
+	$_ = "\033[3" . ($lastcol + 1) . "m1.$1$2\033[0m$3\n";
 }
 ' | less -R
>Release-Note:
>Audit-Trail:
>Unformatted:



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