🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #50034

Re: [slrn] Patch: colors for different quote-levels

#50034
From: Thomas Schultz
Date: Thu, 22 Jul 1999 00:00
137 lines
5422 bytes
On 22 July 1999 at 09:55 GMT, Sven Guckes <guckes@math.fu-berlin.de> wrote:
> * Thomas Schultz <tststs@gmx.de>:
>> I implemented one of the features that are most frequently requested
>> in de.comm.software.newsreader -- I wrote a patch that adds the
>> possibility to assign different colors to different quote-levels.
> Thanks!

I just found out how to implement this feature without having to patch
S-Lang. The new patch makes the old one look rather stupid, so please
use the new version ;-) I think it is now short enough to post it to
the newsgroup (about 100 lines):

diff -ur slrn-0.9.5.7.orig/src/art.c slrn-0.9.5.7/src/art.c
--- slrn-0.9.5.7.orig/src/art.c	Thu Jul 15 23:19:28 1999
+++ slrn-0.9.5.7/src/art.c	Thu Jul 22 22:49:02 1999
@@ -7827,6 +7827,52 @@
 /*}}}*/
 #endif
 
+/* write out the line, using a different color for each quote level */
+static void write_quote (unsigned char *buf) /*{{{*/
+{
+   unsigned char *last_buf;
+   int color = QUOTE1_COLOR;
+   
+   do	/* Cycle through all quote regexps until none of them match */
+     {
+	SLRegexp_Type **r;
+	r = Slrn_Ignore_Quote_Regexp;
+	
+	last_buf = buf;
+	
+	while (*r != NULL)
+	  {
+	     SLRegexp_Type *re = *r;
+	     
+	     while (NULL != SLang_regexp_match (buf, strlen (buf), re))
+	       {
+		  unsigned char *epos = buf + re->beg_matches[0] +
+		                        re->end_matches[0];
+		  
+		  slrn_set_color(color);
+		  
+		  switch (color)
+		    {
+		     case QUOTE1_COLOR : color = QUOTE2_COLOR; break;
+		     case QUOTE2_COLOR : color = QUOTE3_COLOR; break;
+		     case QUOTE3_COLOR : color = QUOTE4_COLOR; break;
+		     case QUOTE4_COLOR : color = QUOTE1_COLOR; break;
+		    }
+		  
+		  while (buf != epos)
+		    {
+		       smg_write_char(*buf);
+		       buf++;
+		    }
+	       }
+	     r++;
+	  }
+     } while (last_buf != buf);
+   
+   smg_write_string(buf);
+}
+/*}}}*/
+
 static void draw_tree (Slrn_Header_Type *h) /*{{{*/
 {
    unsigned char buf[2];
@@ -8283,11 +8329,12 @@
      }
    else
      {
-	if (l->flags & QUOTE_LINE)
-	  slrn_set_color (QUOTE_COLOR);
-	else if (l->flags & SIGNATURE_LINE)
+	if (l->flags & SIGNATURE_LINE)
 	  slrn_set_color (SIGNATURE_COLOR);
 	else slrn_set_color (ARTICLE_COLOR);
+	if (l->flags & QUOTE_LINE)
+	  write_quote ((unsigned char *) lbuf);
+	else
 #if SLRN_HAS_SPOILERS
 	if (l->flags & SPOILER_LINE)
 	  write_spoiler ((unsigned char *) lbuf);
diff -ur slrn-0.9.5.7.orig/src/post.c slrn-0.9.5.7/src/post.c
--- slrn-0.9.5.7.orig/src/post.c	Thu Jul 15 23:19:28 1999
+++ slrn-0.9.5.7/src/post.c	Thu Jul 22 22:00:34 1999
@@ -504,7 +504,7 @@
 	slrn_set_color (SUBJECT_COLOR);
 	SLsmg_printf ("This message was generated while looking at line %d:", num);
 	SLsmg_gotorc (8,0);
-	slrn_set_color (QUOTE_COLOR);
+	slrn_set_color (QUOTE1_COLOR);
 	SLsmg_write_string (the_line);
 	SLsmg_gotorc (12, 0);
 	slrn_set_color (ARTICLE_COLOR);
diff -ur slrn-0.9.5.7.orig/src/slrn.h slrn-0.9.5.7/src/slrn.h
--- slrn-0.9.5.7.orig/src/slrn.h	Thu Jul 15 23:19:28 1999
+++ slrn-0.9.5.7/src/slrn.h	Thu Jul 22 22:49:55 1999
@@ -92,7 +92,7 @@
 #define CURSOR_COLOR	6
 #define ARTICLE_COLOR	7
 #define TREE_COLOR	8
-#define QUOTE_COLOR	9
+#define QUOTE1_COLOR	9
 #define SIGNATURE_COLOR 10
 #define THREAD_NUM_COLOR 11
 #define HIGH_SCORE_COLOR 12
@@ -108,4 +108,7 @@
 #define RESPONSE_CHAR_COLOR	22
 #define FRAME_COLOR		23
 #define SELECT_COLOR		24
+#define QUOTE2_COLOR	25
+#define QUOTE3_COLOR	26
+#define QUOTE4_COLOR	27
 #endif				       /* _SLRN_SLRN_H_ */
diff -ur slrn-0.9.5.7.orig/src/startup.c slrn-0.9.5.7/src/startup.c
--- slrn-0.9.5.7.orig/src/startup.c	Thu Jul 15 23:19:28 1999
+++ slrn-0.9.5.7/src/startup.c	Thu Jul 22 22:00:34 1999
@@ -708,7 +708,11 @@
      {"cursor",		CURSOR_COLOR,	"brightgreen",	"white", SLTT_REV_MASK},
      {"article",	ARTICLE_COLOR,	"blue",		"white", 0},
      {"tree",		TREE_COLOR,	"red",		"white", 0},
-     {"quotes",		QUOTE_COLOR,	"red",		"white", 0},
+     {"quotes",		QUOTE1_COLOR,	"red",		"white", 0},
+     {"quotes1",	QUOTE1_COLOR,	"red",		"white", 0},
+     {"quotes2",	QUOTE2_COLOR,	"green",	"white", 0},
+     {"quotes3",	QUOTE3_COLOR,	"brightred",	"white", 0},
+     {"quotes4",	QUOTE4_COLOR,	"brightgreen",	"white", 0},
      {"signature",	SIGNATURE_COLOR,"red",		"white", 0},
      {"thread_number",	THREAD_NUM_COLOR,"blue",	"white", SLTT_BOLD_MASK},
      {"header_number",	HEADER_NUMBER_COLOR,"green",	"white", 0},
-- 
Kind regards,
    Thomas Schultz

Technical Details
Message-ID: <slrn7pf2vf.3r1.tststs@starflower.tststs.ddns.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
References: <slrn7pclmu.ia.tststs@starflower.tststs.ddns.org> <7n6pq5$c0p$4@fu-berlin.de>

Show Full Headers
Complete Article Headers
Message-ID: <slrn7pf2vf.3r1.tststs@starflower.tststs.ddns.org>
Subject: Re: [slrn] Patch: colors for different quote-levels
Date: Thu, 22 Jul 1999 00:00:00 +0000
From: tststs@gmx.de (Thomas Schultz)
References: <slrn7pclmu.ia.tststs@starflower.tststs.ddns.org> <7n6pq5$c0p$4@fu-berlin.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
X-Deja-AN: 504180517
X-Server-Date: 22 Jul 1999 22:24:40 GMT
X-Trace: news1.cityweb.de 932682592 62.52.148.59 (Fri, 23 Jul 1999 00:29:52 MET DST)
Organization: Pinguin online
User-Agent: slrn/0.9.5.7 (UNIX)
NNTP-Posting-Date: Fri, 23 Jul 1999 00:29:52 MET DST
Newsgroups: news.software.readers