[hackers] [st] Removing wrapping newlines from selection || Ben Hendrickson

From: <git_AT_suckless.org>
Date: Sun, 24 Aug 2014 11:01:39 +0200

commit 98a1085d0e7c3d84e19185ba666c4b0c725cd974
Author: Ben Hendrickson <ben_AT_1m7.com>
Date: Fri Aug 22 09:25:04 2014 -0700

    Removing wrapping newlines from selection
    
    When getting selected text, lines that were wrapped because of length
    ought not include the wrapping newline in the selection.
    
    This comes up, for example, when copying a bash command that is long
    enough to wrap from the console and pasting it back into the console.
    The extra newline breaks it.
    
    Similiarly, changes behavior when trimming whitespace from the end of a
    physical line to only do so if the line does not wrap. Otherwise we are
    trimming whitespace from the middle of a logical line, which may change
    its meaning.
    
    Signed-off-by: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>

diff --git a/st.c b/st.c
index 497885b..097775d 100644
--- a/st.c
+++ b/st.c
_AT_@ -662,7 +662,10 @@ y2row(int y) {
 static int tlinelen(int y) {
         int i = term.col;
 
- while (i > 0 && term.line[y][i - 1].c[0] == ' ')
+ if(term.line[y][i - 1].mode & ATTR_WRAP)
+ return i;
+
+ while(i > 0 && term.line[y][i - 1].c[0] == ' ')
                 --i;
 
         return i;
_AT_@ -959,7 +962,7 @@ getsel(void) {
                  * st.
                  * FIXME: Fix the computer world.
                  */
- if(sel.ne.y > y || lastx >= linelen)
+ if((y < sel.ne.y || lastx >= linelen) && !(last->mode & ATTR_WRAP))
                         *ptr++ = '
';
         }
         *ptr = 0;
Received on Sun Aug 24 2014 - 11:01:39 CEST

This archive was generated by hypermail 2.3.0 : Sun Aug 24 2014 - 11:12:08 CEST