On Tue, Jun 3, 2014 at 4:34 AM, Colona <col...@ycc.fr> wrote:
> Currently, selection is expanded to the end of the line over line breaks only 
> in
> regular selection mode, when the line in not empty and when going down and/or
> right. This covers all the cases including word selection mode, with the
> exception of rectangular selection because it would make this mode too rigid.
> This adjustment is made in selsort so I renamed it to selnormalize to better
> reflect what it does now.
>

I like it. The logic in getsel() can also use the tlinelen function. I
attached a patch which does this and removes a couple of lines. It
depends on both patches you sent.

Kind regards,
Hiltjo
From 9a935ef5ba8eeefe1c6cc9e0e9bfc116aeefc1bf Mon Sep 17 00:00:00 2001
From: Hiltjo Posthuma <hil...@codemadness.org>
Date: Tue, 3 Jun 2014 17:46:34 +0200
Subject: [PATCH] tiny cleanup

Signed-off-by: Hiltjo Posthuma <hil...@codemadness.org>
---
 st.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/st.c b/st.c
index a246ffa..8b65450 100644
--- a/st.c
+++ b/st.c
@@ -920,7 +920,7 @@ bpress(XEvent *e) {
 char *
 getsel(void) {
 	char *str, *ptr;
-	int x, y, bufsize, size, i, ex;
+	int x, y, bufsize, size, ex;
 	Glyph *gp, *last;
 
 	if(sel.ob.x == -1)
@@ -965,13 +965,10 @@ getsel(void) {
 		 * after the visible text '\n' is appended.
 		 */
 		if(y == sel.ne.y) {
-			i = term.col;
-			while(--i > 0 && term.line[y][i].c[0] == ' ')
-				/* nothing */;
 			ex = sel.ne.x;
 			if(sel.nb.y == sel.ne.y && sel.ne.x < sel.nb.x)
 				ex = sel.nb.x;
-			if(i < ex)
+			if(tlinelen(y) < ex)
 				*ptr++ = '\n';
 		}
 	}
-- 
1.9.2

Reply via email to