> The GLYPH_SET flag can be used to compute the end of the line or we This patch uses this approach for locating the end of line and works fine for me.
>From 2192d284a3d002044d57592c6e36246a6d8882dc Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" <k...@shike2.com> Date: Thu, 11 Oct 2012 19:03:57 +0200 Subject: Avoid copying characters beyond last
Positions without GLYPH_SET are copied as spaces. This is correct for tabs and others locate sequences, but is wrong in the end of lines, where you get a lot of spaces where there isn't any text. This patch avoid these ghost trailing whitespaces, but still transform tabs into spaces. --- st.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/st.c b/st.c index 8641a7a..532d706 100644 --- a/st.c +++ b/st.c @@ -691,7 +691,6 @@ void selcopy(void) { char *str, *ptr, *p; int x, y, bufsize, is_selected = 0, size; - Glyph *gp; if(sel.bx == -1) { str = NULL; @@ -701,9 +700,11 @@ selcopy(void) { /* append every set & selected glyph to the selection */ for(y = 0; y < term.row; y++) { - for(x = 0; x < term.col; x++) { - gp = &term.line[y][x]; + Glyph *gp = &term.line[y][0], *last = gp + term.col; + while(--last >= gp && !(last->state & GLYPH_SET)) + /* nothing */; + for(x = 0; gp <= last; x++, ++gp) { if(!(is_selected = selected(x, y))) continue; p = (gp->state & GLYPH_SET) ? gp->c : " "; -- 1.7.10.4