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@shike2.com>
This commit is contained in:
parent
51466e019a
commit
98a1085d0e
5
st.c
5
st.c
|
@ -662,6 +662,9 @@ y2row(int y) {
|
||||||
static int tlinelen(int y) {
|
static int tlinelen(int y) {
|
||||||
int i = term.col;
|
int i = term.col;
|
||||||
|
|
||||||
|
if(term.line[y][i - 1].mode & ATTR_WRAP)
|
||||||
|
return i;
|
||||||
|
|
||||||
while(i > 0 && term.line[y][i - 1].c[0] == ' ')
|
while(i > 0 && term.line[y][i - 1].c[0] == ' ')
|
||||||
--i;
|
--i;
|
||||||
|
|
||||||
|
@ -959,7 +962,7 @@ getsel(void) {
|
||||||
* st.
|
* st.
|
||||||
* FIXME: Fix the computer world.
|
* FIXME: Fix the computer world.
|
||||||
*/
|
*/
|
||||||
if(sel.ne.y > y || lastx >= linelen)
|
if((y < sel.ne.y || lastx >= linelen) && !(last->mode & ATTR_WRAP))
|
||||||
*ptr++ = '\n';
|
*ptr++ = '\n';
|
||||||
}
|
}
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
|
|
Loading…
Reference in a new issue