Thread View: news.software.readers
4 messages
4 total messages
Started by Thomas Schultz
Wed, 21 Jul 1999 00:00
[slrn] Patch: colors for different quote-levels
Author: Thomas Schultz
Date: Wed, 21 Jul 1999 00:00
Date: Wed, 21 Jul 1999 00:00
29 lines
1970 bytes
1970 bytes
Hi,
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. It
introduces the new color objects quotes1 (for quote levels 1, 5, 9
etc.) to quotes4 (for quote levels 4, 8...). The color object "quotes"
remains valid and is now an alias for "quotes1".
The highlighting takes into account all regular expressions that are
defined using "ignore_quotes". To achieve this, I needed to change
S-Lang; any hints on how to implement the same functionality without
patching S-Lang are appreciated. Otherwise, I would be glad if it was
possible to add the needed feature to the official S-Lang release.
The two patches (one for S-Lang 1.3.8, the other one for slrn 0.9.5.7)
can be obtained from the following URLs:
http://home.knuut.de/svengo/patch_slang_regexp.diff
http://home.knuut.de/svengo/patch_slrn_quotes.diff
Please note that http://home.knuut.de/svengo/ is *not* my homepage,
but that its owner was so kind to upload my patches there. Please do
not bother him in case you should encounter problems with the patches.
--
Kind regards,
Thomas Schultz
Re: [slrn] Patch: colors for different quote-levels
Author: Thomas Schultz
Date: Thu, 22 Jul 1999 00:00
Date: Thu, 22 Jul 1999 00:00
137 lines
5422 bytes
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
Re: [slrn] Patch: colors for different quote-levels
Author: Sven Guckes
Date: Thu, 22 Jul 1999 00:00
Date: Thu, 22 Jul 1999 00:00
25 lines
1729 bytes
1729 bytes
* 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! > The two patches (one for S-Lang 1.3.8, the other one for > slrn 0.9.5.7) can be obtained from the following URLs: > http://home.knuut.de/svengo/patch_slang_regexp.diff > http://home.knuut.de/svengo/patch_slrn_quotes.diff I made a note on the SLRN WishList. Hopefully JED will add this feature when he's back from his holidays. Sven -- Sven Guckes guckes@math.fu-berlin.de using SLRN 0.9.4.4 [981105] SLRN Pages: http://www.guckes.net/slrn/ latest version: 0.9.5.7 [9907..] SLRN Wishlist: http://www.guckes.net/slrn/wish.html wish.html SLRN Author: http://space.mit.edu/~davis/slrn.html John E. Davis aka JED
Re: [slrn] Patch: colors for different quote-levels
Author: Thomas Schultz
Date: Thu, 29 Jul 1999 00:00
Date: Thu, 29 Jul 1999 00:00
15 lines
1433 bytes
1433 bytes
On 22 July 1999 at 21:23 GMT, Thomas Schultz <tststs@gmx.de> wrote:
> 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 discovered a bug in my code which made it impossible to ROT13-decode
quoted lines and caused incorrect treatment of quoted text below
spoiler chars (^L). A version without this bug can be obtained at
http://home.knuut.de/svengo/patch_slrn_quotes.diff
--
Kind regards,
Thomas Schultz
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads