Re: [dev] [st] Tip adds non-existing trailing whitespace upon mouse selection + fix

2012-10-11 Thread Roberto E. Vargas Caballero
 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



Re: [dev] [st] Tip adds non-existing trailing whitespace upon mouse selection + fix

2012-10-10 Thread Roberto E. Vargas Caballero
 The GLYPH_SET flag can be used to compute the end of the line or we
 could add another flag like GLYPH_TAB when appropriate and test it in
 the copy function when it loops over the selection.

Instead of adding GLYPH_TAB we could use directly \t in c and then we don't
have to test anything in selcopy, but of couse we should check it in
drawregion.

But this solution doesn't fix this problem when you use a sequence to locate
the cursor in some place of the screen.



[dev] [st] Tip adds non-existing trailing whitespace upon mouse selection + fix

2012-10-09 Thread Rafa Garcia Gallego
Hi,

Upon selecting text with the mouse, st tip fills the selection
straight from its term matrix and replaces unset glyphs with a
whitespace. This results in some really annoying trailing whitespace
at the end of each line when you paste/pipe the selection. Is there
any reason for this?

The attached patch fixes this behavior.

Cheers,
Rafa.


st-tip-do-not-select-trailing-whitespaces.diff
Description: Binary data


Re: [dev] [st] Tip adds non-existing trailing whitespace upon mouse selection + fix

2012-10-09 Thread pancake
i feel this annoying too, but someone told me this was an intentional 
behaviour.


i'm used to xterm and iTerm2, and copypasting text with text selection 
is something
I do many times (as well as scrolling), and this is behaviour of st is 
somewhat

annoying. i vote for your patch to be upstream :)

On 10/09/12 15:47, Rafa Garcia Gallego wrote:

Hi,

Upon selecting text with the mouse, st tip fills the selection
straight from its term matrix and replaces unset glyphs with a
whitespace. This results in some really annoying trailing whitespace
at the end of each line when you paste/pipe the selection. Is there
any reason for this?

The attached patch fixes this behavior.

Cheers,
Rafa.





Re: [dev] [st] Tip adds non-existing trailing whitespace upon mouse selection + fix

2012-10-09 Thread Roberto E. Vargas Caballero
On Tue, Oct 09, 2012 at 04:07:54PM +0200, pancake wrote:
 i feel this annoying too, but someone told me this was an
 intentional behaviour.

The problem is that tab characters means a movement of the cursor. so if you
apply your patch and run something like:

$ printf a\tb

you will see in the screen:

a   b

but if you try copy/paste it you will copy only the character a and b,
getting:

ab


Solution of copying all the characters needs some work, because I agree it sucks
when you copy this non existing leading paces. I think the solution should be a
variable by line saying maximum column written in it. I think other terminal
emulators do something like this.

Of course actual solution converts all tabs into spaces, but fix this is
reallt complex and I think all the emulator take this aproach.


Sincerely,

Roberto E. Vargas Caballero.



Re: [dev] [st] Tip adds non-existing trailing whitespace upon mouse selection + fix

2012-10-09 Thread Aurélien Aptel
On Tue, Oct 9, 2012 at 7:03 PM, Roberto E. Vargas Caballero
k...@shike2.com wrote:
 Solution of copying all the characters needs some work, because I agree it 
 sucks
 when you copy this non existing leading paces. I think the solution should be 
 a
 variable by line saying maximum column written in it. I think other terminal
 emulators do something like this.

 Of course actual solution converts all tabs into spaces, but fix this is
 reallt complex and I think all the emulator take this aproach.

The GLYPH_SET flag can be used to compute the end of the line or we
could add another flag like GLYPH_TAB when appropriate and test it in
the copy function when it loops over the selection.



Re: [dev] [st] Tip adds non-existing trailing whitespace upon mouse selection + fix

2012-10-09 Thread hiro
pancake: even in my urxvt copying text never works reliably, so I
always end up repeating what I did in 9term and copy-pasting from
there. dumb, ugly, useless, annoying shit.

vts suck.