New feature in feature.h: DONT_SELECT_TRAILING_SPACES
Strips all trailing spaces in selected text.
Marius Gedminas
--
1 4m 5o 3l337! just got r00t on this <a href="127.0.0.1">k3wl site</a> j00
sux0r5!
Index: src/feature.h
===================================================================
RCS file: /cvsroot/rxvt/rxvt/src/feature.h,v
retrieving revision 1.52
diff -u -r1.52 feature.h
--- src/feature.h 2001/03/02 05:33:15 1.52
+++ src/feature.h 2001/03/06 12:54:18
@@ -255,6 +281,11 @@
*/
/* #define SCROLLBAR_INITIAL_DELAY 40 */
/* #define SCROLLBAR_CONTINUOUS_DELAY 2 */
+
+/*
+ * Strip trailing spaces from selection -- mg
+ */
+#define DONT_SELECT_TRAILING_SPACES
/*--------------------------------MISC----------------------------------*/
/*
Index: src/screen.c
===================================================================
RCS file: /cvsroot/rxvt/rxvt/src/screen.c,v
retrieving revision 1.197
diff -u -r1.197 screen.c
--- src/screen.c 2001/03/06 05:04:28 1.197
+++ src/screen.c 2001/03/06 12:54:27
@@ -118,6 +118,11 @@
r->TermWin.int_bwidth, Row2Pixel(row), \
r->TermWin.width, Height2Pixel(num))
+
+#define STRIP_TRAILING_SPACES(str, fence) \
+ while (str > fence && str[-1] == ' ') \
+ str--
+
/* ------------------------------------------------------------------------- *
* SCREEN `COMMON' ROUTINES *
* ------------------------------------------------------------------------- */
@@ -2896,7 +2901,7 @@
{
int i, col, end_col, row, end_row;
unsigned char *new_selection_text;
- char *str;
+ unsigned char *str;
text_t *t;
D_SELECT((stderr, "rxvt_selection_make(): r->selection.op=%d,
r->selection.clicks=%d", r->selection.op, r->selection.clicks));
@@ -2936,8 +2941,12 @@
end_col = r->TermWin.ncol;
for (; col < end_col; col++)
*str++ = *t++;
- if (r->screen.tlen[row] != -1)
+ if (r->screen.tlen[row] != -1) {
+#ifdef DONT_SELECT_TRAILING_SPACES
+ STRIP_TRAILING_SPACES(str, new_selection_text);
+#endif
*str++ = '\n';
+ }
}
/*
* B: end row
@@ -2949,15 +2958,20 @@
MIN_IT(end_col, r->TermWin.ncol); /* CHANGE */
for (; col < end_col; col++)
*str++ = *t++;
+#ifdef DONT_SELECT_TRAILING_SPACES
+ STRIP_TRAILING_SPACES(str, new_selection_text);
+#endif
#ifndef NO_OLD_SELECTION
if (r->selection_style == OLD_SELECT)
- if (end_col == r->TermWin.ncol)
+ if (end_col == r->TermWin.ncol) {
*str++ = '\n';
+ }
#endif
#ifndef NO_NEW_SELECTION
if (r->selection_style != OLD_SELECT)
- if (end_col != r->selection.end.col)
+ if (end_col != r->selection.end.col) {
*str++ = '\n';
+ }
#endif
*str = '\0';
if ((i = STRLEN((char *)new_selection_text)) == 0) {