[PATCH] configurable wrap_marker character
Alex Chiang <[email protected]>
| Newsgroups | gmane.network.slrn.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I was dissatisfied with the way the slrn always inserted a
leading space character for lines that were word-wrapped. In
particular, this behavior made easy copy/paste of URLs somewhat
troublesome, as you not only have a newline character to
remove[1], but a space character as well.
This patch allows the user to configure a 'marker' character
(similar to mutt's 'markers' variable) that is inserted when slrn
wraps a line.
A new variable is created:
set wrap_marker ' '
The default value is ' ', so for most users, it will be a
transparent option. Things get interesting, however, with the
following combination:
set wrap_method 1
set wrap_marker ''
This tells slrn to do a hard break at the width of the screen
(without looking for a space or tab character). However, since
we've set wrap_marker to '', the text on the next line will *not*
have a leading space prepended.
Of course, you can specify any legal character value for
wrap_marker. I did test with the '+' character as well (similar
to mutt's default).
You will notice that this combination:
set wrap_method 0 % or 2
set wrap_marker ' '
will produce a surprising result -- it will seem as if nothing
has changed. The next line will begin with a leading space.
However, in the routine that does the line wrapping, we see that
this is actually the programmed behavior. As we search backwards
for a spot to break the line, we stop when we find a space. That
spot is where we start printing the next line, and it contains
the space that we found on the previous line.
Maybe this is a subtle bug, but I wasn't skilled/motivated enough
to try and fix it.
Finally, it would be neat if one could specify a color for the
wrap_marker, but frankly, I don't know beans about s-lang, and
couldn't quite figure out how to make a single character in a
buffer have a different color from the rest of the line. It would
be cool if someone else added support for that. :)
I tested various combinations of wrap_method and wrap_marker,
along with "text-ish" long lines (aka, lines that were >80
columns, but had spaces between the words) and "url-ish" long
lines (aka, lines that were >80 columsn but had *no* spaces at
all), and based upon my visual inspection, and a few minutes
examining the buffers in gdb, it seemed to behave correctly.
Comments, etc. welcomed.
/ac
Index: slrn-0.9.8.1pl1/src/art.h
===================================================================
--- slrn-0.9.8.1pl1.orig/src/art.h 2007-07-23 23:03:07.000000000 -0600
+++ slrn-0.9.8.1pl1/src/art.h 2007-07-24 00:24:44.000000000 -0600
@@ -48,6 +48,7 @@
extern int Slrn_Use_Tmpdir;
extern int Slrn_Wrap_Mode;
extern int Slrn_Wrap_Method;
+extern int Slrn_Wrap_Marker;
extern int Slrn_Use_Header_Numbers;
extern int Slrn_Reads_Per_Update;
extern int Slrn_High_Score_Min;
Index: slrn-0.9.8.1pl1/src/startup.c
===================================================================
--- slrn-0.9.8.1pl1.orig/src/startup.c 2007-07-23 23:02:35.000000000 -0600
+++ slrn-0.9.8.1pl1/src/startup.c 2007-07-24 00:33:12.000000000 -0600
@@ -560,6 +560,7 @@
{"warn_followup_to", &Slrn_Warn_Followup_To},
{"wrap_flags", &Slrn_Wrap_Mode},
{"wrap_method", &Slrn_Wrap_Method},
+ {"wrap_marker", &Slrn_Wrap_Marker},
{"write_newsrc_flags", &Slrn_Write_Newsrc_Flags},
{"query_read_group_cutoff", &Slrn_Query_Group_Cutoff},
{"max_queued_groups", &Slrn_Max_Queued_Groups},
Index: slrn-0.9.8.1pl1/src/art_misc.c
===================================================================
--- slrn-0.9.8.1pl1.orig/src/art_misc.c 2007-07-23 23:03:40.000000000 -0600
+++ slrn-0.9.8.1pl1/src/art_misc.c 2007-07-24 00:48:09.000000000 -0600
@@ -60,6 +60,7 @@
/*}}}*/
static int Art_Hide_Quote_Level = 1;
+int Slrn_Wrap_Marker = ' ';
int Slrn_Wrap_Mode = 3;
int Slrn_Wrap_Method = 2;
@@ -564,7 +565,8 @@
buf0 = buf;
lbuf = (unsigned char *) l->buf;
- lbuf += 1; /* avoid space at beg of line */
+ if (Slrn_Wrap_Marker)
+ lbuf += 1; /* avoid space at beg of line */
if (Slrn_Wrap_Method == 0 || Slrn_Wrap_Method == 2)
{
@@ -574,6 +576,7 @@
|| (header_char_delimiter
&& (*buf0 == header_char_delimiter)))
{
+ ch = ' ';
buf = buf0;
break;
}
@@ -597,18 +600,25 @@
}
else {
lbuf = (unsigned char *) l->buf;
- lbuf += 1; /* avoid space at beg of line */
+ if (Slrn_Wrap_Marker)
+ lbuf += 1; /* avoid space at beg of line */
}
}
}
- /* Start wrapped lines with a space. To do this, I will
- * _temporally_ modify the previous character for the purpose
- * of creating the new space.
+ /* Insert the wrap_marker at the beginning of the line. To do
+ * this, _temporarily_ modify the previous character for the
+ * purpose of creating the new space.
+ *
+ * NULL is a valid value for wrap_marker (the user doesn't
+ * want any leading spaces when the line has been wrapped),
+ * so only do this if wrap_marker is non-NULL.
*/
- buf--;
- ch = *buf;
- *buf = ' ';
+ if (Slrn_Wrap_Marker) {
+ buf--;
+ ch = *buf;
+ *buf = Slrn_Wrap_Marker;
+ }
new_l = (Slrn_Article_Line_Type *) slrn_malloc (sizeof (Slrn_Article_Line_Type), 1, 1);
if (new_l == NULL)
Index: slrn-0.9.8.1pl1/doc/manual.txt
===================================================================
--- slrn-0.9.8.1pl1.orig/doc/manual.txt 2007-07-24 00:39:30.000000000 -0600
+++ slrn-0.9.8.1pl1/doc/manual.txt 2007-07-24 00:42:51.000000000 -0600
@@ -200,8 +200,9 @@
6.141 warn_followup_to
6.142 wrap_flags
6.143 wrap_method
- 6.144 write_newsrc_flags
- 6.145 Xbrowser
+ 6.144 wrap_method
+ 6.145 write_newsrc_flags
+ 6.146 Xbrowser
7. Interactive functions
7.1 group functions
@@ -4039,7 +4040,19 @@
See also: ``wrap_flags''
- 6.144. write_newsrc_flags
+ 6.144. wrap_marker
+
+ Type: character
+ Default: ' '
+
+ With this variable, you can control how slrn indicates that a long
+ line has been wrapped. The specified character will be inserted at
+ the beginning of the wrapped line.
+
+ See also: ``wrap_method''
+
+
+ 6.145. write_newsrc_flags
Type: integer
Default: 0
@@ -4050,7 +4063,7 @@
in them.
- 6.145. Xbrowser
+ 6.146. Xbrowser
Type: string
Default: (unset)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/