Since I sent several mails to upstream author and I didn't receive an
answer, then I did the patch by myself.

The patch is attached. Now I need time to review the package, change
it to the new standards (quilt 3.0, policy and dh versions), and
upload it. Intend to do this in the following 2 weeks.
Index: tdl-1.5.2/Makefile.in
===================================================================
--- tdl-1.5.2.orig/Makefile.in	2004-01-06 22:09:05.000000000 -0200
+++ tdl-1.5.2/Makefile.in	2012-03-25 21:30:20.000000000 -0300
@@ -47,7 +47,7 @@
 
 OBJ = main.o io.o add.o done.o remove.o move.o list.o \
       report.o purge.o util.o dates.o impexp.o narrow.o \
-			inter.o
+			inter.o color.o
 
 all : tdl
 
Index: tdl-1.5.2/color.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ tdl-1.5.2/color.c	2012-03-25 21:28:03.000000000 -0300
@@ -0,0 +1,100 @@
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "color.h"
+
+#define dNORMAL  ""
+#define dRED     ""
+#define dGREEN   ""
+#define dYELLOW  ""
+#define dBLUE    ""
+#define dMAGENTA ""
+#define dCYAN    ""
+
+char NORMAL[COLORMAXSIZE];
+char RED[COLORMAXSIZE];
+char GREEN[COLORMAXSIZE];
+char YELLOW[COLORMAXSIZE];
+char BLUE[COLORMAXSIZE];
+char MAGENTA[COLORMAXSIZE];
+char CYAN[COLORMAXSIZE];
+
+void color_apply(char * varname, char * config) {
+  int i = 0;
+  while (config[i]) {
+    /* terminate string at first special char (like CR, LF and others) */
+    if (config[i] < 0x20) {
+      config[i] = 0;
+    } else {
+      /* replace tilde -> ESC */
+      if (config[i] == '~') config[i] = 0x1b;
+      i++;
+    }
+  }
+  strncpy(varname,config,COLORMAXSIZE);
+  varname[COLORMAXSIZE-1] = 0;
+}
+
+void color_map_from_file (char * filename) {
+  FILE * fh;
+  char s[1024];
+  fh = fopen(filename,"r");
+  if (fh != NULL) {
+    while (! feof(fh)) {
+      if (fgets(s, 1023, fh)) {
+        if (strncasecmp("NORMAL=",s,7)==0) {
+          color_apply(NORMAL,s+7);
+        }
+        if (strncasecmp("RED=",s,4)==0) {
+          color_apply(RED,s+4);
+        }
+        if (strncasecmp("GREEN=",s,6)==0) {
+          color_apply(GREEN,s+6);
+        }
+        if (strncasecmp("YELLOW=",s,7)==0) {
+          color_apply(YELLOW,s+7);
+        }
+        if (strncasecmp("BLUE=",s,5)==0) {
+          color_apply(BLUE,s+5);
+        }
+        if (strncasecmp("MAGENTA=",s,8)==0) {
+          color_apply(MAGENTA,s+8);
+        }
+        if (strncasecmp("CYAN=",s,5)==0) {
+          color_apply(CYAN,s+5);
+        }
+      }
+    }
+    fclose(fh);
+  }
+}
+
+void color_init(void) {
+  char * s;
+
+  /* default colors */
+  strcpy(RED,dRED);
+  strcpy(GREEN,dGREEN);
+  strcpy(YELLOW,dYELLOW);
+  strcpy(BLUE,dBLUE);
+  strcpy(MAGENTA,dMAGENTA);
+  strcpy(CYAN,dCYAN);
+  strcpy(NORMAL,dNORMAL);
+
+  /* try to get colors from /etc/tdl.conf */
+  color_map_from_file ("/etc/tdl.conf");
+
+  /* try to get colors from $HOME/.tdl.color */
+  s = getenv("HOME");
+  if (s != NULL) {
+    char * t;
+    t = malloc(strlen(s)+16);
+    sprintf(t,"%s/.tdl.color",s);
+    color_map_from_file (t);
+    free(t);
+  }
+
+  /* try to get colors from CURRENT_DIR/.tdl.color */
+  color_map_from_file ("./.tdl.color");
+
+}
Index: tdl-1.5.2/color.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ tdl-1.5.2/color.h	2012-03-25 21:28:29.000000000 -0300
@@ -0,0 +1,16 @@
+#ifndef _COLOR_H
+#define _COLOR_H
+
+#define COLORMAXSIZE 32
+
+extern char RED[COLORMAXSIZE];
+extern char GREEN[COLORMAXSIZE];
+extern char YELLOW[COLORMAXSIZE];
+extern char BLUE[COLORMAXSIZE];
+extern char MAGENTA[COLORMAXSIZE];
+extern char CYAN[COLORMAXSIZE];
+extern char NORMAL[COLORMAXSIZE];
+
+void color_init(void);
+
+#endif
Index: tdl-1.5.2/list.c
===================================================================
--- tdl-1.5.2.orig/list.c	2012-03-25 21:25:28.000000000 -0300
+++ tdl-1.5.2/list.c	2012-03-25 21:29:16.000000000 -0300
@@ -25,6 +25,7 @@
 #include <ctype.h>
 #include <unistd.h>
 #include "tdl.h"
+#include "color.h"
 
 struct list_options {
   unsigned monochrome:1;
@@ -37,17 +38,6 @@
 
 #define INDENT_TAB 3
 
-/*{{{ Colour definitions */
-#define RED     ""
-#define GREEN   ""
-#define YELLOW  ""
-#define BLUE    ""
-#define MAGENTA ""
-#define CYAN    ""
-#define NORMAL  ""
-#define DIM     ""
-#define DIMCYAN ""
-
 /* Table to map priority levels to colours */
 static char *colour_table[] = {
   NORMAL, BLUE, CYAN, NORMAL, YELLOW, RED
Index: tdl-1.5.2/main.c
===================================================================
--- tdl-1.5.2.orig/main.c	2012-03-25 21:25:28.000000000 -0300
+++ tdl-1.5.2/main.c	2012-03-25 21:29:53.000000000 -0300
@@ -20,6 +20,7 @@
    */
 
 #include "tdl.h"
+#include "color.h"
 #include <assert.h>
 #include <string.h>
 #include <errno.h>
@@ -933,6 +934,7 @@
 /*{{{  int main (int argc, char **argv)*/
 int main (int argc, char **argv)
 {
+  color_init();
   n_cmds = N(cmds);
   is_interactive = 0;
   
Index: tdl-1.5.2/tdl.1
===================================================================
--- tdl-1.5.2.orig/tdl.1	2012-03-25 21:25:28.000000000 -0300
+++ tdl-1.5.2/tdl.1	2012-03-25 21:32:07.000000000 -0300
@@ -945,5 +945,12 @@
 .br
 ln \-s ../project2/.tdldb .
 
+.br
+.TP
+ /etc/tdl.conf
+colour mapping config. Use this file to change colors for all users.
+You can also use $HOME/.tdl.color or ./.tdl.color as a personal preference way to configure colors. These files uses ANSI color codes,
+for more details, read /etc/tdl.conf comments.
+
 .SH BUGS
 Please report them to the author.
Index: tdl-1.5.2/tdl.color
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ tdl-1.5.2/tdl.color	2012-03-25 21:30:54.000000000 -0300
@@ -0,0 +1,9 @@
+# ANSI color mapping for tdl
+# Important: ~ means ESC
+NORMAL=~[0m
+RED=~[31m~[1m
+GREEN=~[32m
+YELLOW=~[33m~[1m
+BLUE=~[34m
+MAGENTA=~[35m
+CYAN=~[36m

Reply via email to