On Thu, Mar 20, 2008 at 9:50 AM, markus schnalke <[EMAIL PROTECTED]> wrote:

>  sounds interesting!
>  Would you make the modified source (or a patch)  available, please.

Here's a patch against aterm-1.0.0 obtainable from

ftp://ftp.afterstep.org/apps/aterm/

(looks like 1.0.1 got released after I did the patch but I never
noticed). I'd also forgotten how it works: it sets the colour based on
the window title of the aterm, and I have shell codes in my PS1 prompt
that set the window title to the current directory (I have

PS1=\[\e]2;\W\007\]$

FWIW). Also note this is a real hack that I've never bothered to clean
up properly.

diff -r -u aterm-1.0.0/src/main.c aterm-1.0.0.mod/src/main.c
--- aterm-1.0.0/src/main.c      2005-06-20 17:10:19.000000000 +0100
+++ aterm-1.0.0.mod/src/main.c  2002-01-01 00:05:03.000000000 +0000
@@ -1265,6 +1265,45 @@
 # define set_window_color(idx,color)   ((void)0)
 #endif                         /* XTERM_COLOR_CHANGE */

+/*DST*/
+#define NO_VARS 16
+char* col[NO_VARS][2]
+  ={{"#000000","#ffffff"},
+    {"#202020","#ffffff"},
+    {"#404040","#ffffff"},
+    {"#300030","#ffffff"},
+    {"#303000","#ffffff"},
+    {"#003030","#ffffff"},
+    {"#300000","#ffffff"},
+    {"#000030","#ffffff"},
+    {"#000000","#ffffff"},
+    {"#300030","#ffffff"},
+    {"#004040","#ffffff"},
+    {"#404000","#ffff00"},
+    {"#400040","#00ff00"},
+    {"#000040","#00c090"},
+    {"#004000","#00c090"},
+    {"#400000","#c09000"}};
+
+int oldAcc=0;
+
+void
+setRepColor(const char* const str)
+{
+    char *p=(char*)str;
+    int acc=0;
+    while(*p!='\0'){
+        acc+=*p;
+        ++p;
+    }
+    acc=acc & (NO_VARS-1);
+    if(acc!=oldAcc){ /*prevent unnecessary blinking*/
+        set_window_color(Color_bg,col[acc][0]);
+        set_window_color(Color_fg,col[acc][1]);
+        oldAcc=acc;
+    }
+}
+
 /*
  * XTerm escape sequences: ESC ] Ps;Pt BEL
  *       0 = change iconName/title
@@ -1299,7 +1338,8 @@
        set_iconName(str);
        break;
     case XTerm_title:
-       set_title(str);
+        set_title(str); /*DST*/
+        setRepColor(str);
        break;
     case XTerm_Color:
        for (buf = (char *)str; buf && *buf;) {


-- 
cheers, dave tweed__________________________
[EMAIL PROTECTED]
Rm 124, School of Systems Engineering, University of Reading.
"while having code so boring anyone can maintain it, use Python." --
attempted insult seen on slashdot

Reply via email to