[PATCH 2/6] Factor out color settings to cg-Xlib

From: Dan Holmsand <holmsand@gmail.com>
Date: 2005-06-09 21:17:00
[PATCH 2/6] Factor out color settings to cg-Xlib

setup_colors sets color variables from COGITO_COLORS, and
adds a sed script for diff colorization to color_rules.

Note that this changes the default colors a little from the
ones in cg-diff: in particular there's no bold any more. Bold
isn't really necessary if the "less search" thing in the new
cg-diff/cg-log is used (and bold is really ugly in
gnome-terminal :-) ).

Signed-off-by: Dan Holmsand <holmsand@gmail.com>
---


 cg-Xlib |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -136,6 +136,29 @@ print_help () {
 	exit
 }
 
+setup_colors() {
+	local C="header=32:author=36:signoff=33:committer=35:files=34"
+	C="$C:commit=34:date=32:trim=35"
+	C="$C:diffhdr=34:diffhdradd=32:diffadd=32:diffhdrmod=35"
+	C="$C:diffmod=35:diffhdrrem=31:diffrem=31:diffhunk=36"
+	C="$C:diffctx=34:diffcctx=33:default=0"
+	[ -n "$COGITO_COLORS" ] && C="$C:$COGITO_COLORS"
+
+	C=${C//=/=\'$'\e'[}
+	C=col${C//:/m\'; col}m\'
+	#coldefault=$(tput op)
+	eval $C
+
+	color_rules="
+s,^+++.*,$coldiffhdradd&$coldefault,
+s,^---.*,$coldiffhdrrem&$coldefault,
+s,^[+].*,$coldiffadd&$coldefault,
+s,^[-].*,$coldiffrem&$coldefault,
+s,^\\(@@.*@@\\)\\(.*\\),$coldiffhunk\\1$coldiffctx\\2$coldefault,
+s,^=*$',$coldiffhdr&$coldefault,
+s,^\\(Index:\\|===\\|diff\\) .*,$coldiffhdr&$coldefault,"
+}
+
 for option in "$@"; do
 	if [ "$option" = "-h" -o "$option" = "--help" ]; then
 		print_help ${_cg_cmd##cg-}


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Thu Jun 09 22:15:14 2005

This archive was generated by hypermail 2.1.8 : 2005-06-09 22:15:15 EST