git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Dan Holmsand <holmsand@gmail.com>
Date
Jun 9, 2005, 11:17 UTC
Message-ID
<42A8252C.8040805@gmail.com>
[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-}
Message 1 of 1 in “Factor out color settings to cg-Xlib”
  1. 2/6 Factor out color settings to cg-XlibDan Holmsand, Jun 9, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.