From 0679e23fcb1a0e77dbc8ab76438f6071d6895acc Mon Sep 17 00:00:00 2001
From: Alexander Sedov <elec.lomy.ru@gmail.com>
Date: Tue, 19 Feb 2013 19:12:29 +0400
Subject: [PATCH 7/9] Fixed some problems with rectsel patch.
To: dev@suckless.org

---
 st.c |   16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/st.c b/st.c
index 9090a2a..56b2790 100644
--- a/st.c
+++ b/st.c
@@ -652,7 +652,7 @@ selected(int x, int y) {
 		ex = MAX(sel.bx, sel.ex);
 		return BETWEEN(x, bx, ex);
 	}
-	switch (sel.type) {
+	switch(sel.type) {
 	case SEL_REGULAR:
 		return ((sel.b.y < y && y < sel.e.y)
 				|| (y == sel.e.y && x <= sel.e.x))
@@ -679,8 +679,8 @@ getbuttoninfo(XEvent *e) {
 	sel.e.x = sel.by < sel.ey ? sel.ex : sel.bx;
 	sel.e.y = MAX(sel.by, sel.ey);
 	sel.type = SEL_REGULAR;
-	for (type = 1; type < LEN(selmasks); ++type) {
-		if (match(selmasks[type], state)) {
+	for(type = 1; type < LEN(selmasks); ++type) {
+		if(match(selmasks[type], state)) {
 			sel.type = type;
 			break;
 		}
@@ -768,7 +768,7 @@ selcopy(void) {
 		ptr = str = xmalloc(bufsize);
 
 		/* append every set & selected glyph to the selection */
-		for(y = 0; y < term.row; y++) {
+		for(y = sel.b.y; y < sel.e.y + 1; y++) {
 			is_selected = 0;
 			gp = &term.line[y][0];
 			last = gp + term.col;
@@ -932,7 +932,7 @@ brelease(XEvent *e) {
 
 void
 bmotion(XEvent *e) {
-	int /*starty, endy,*/ oldey, oldex;
+	int oldey, oldex;
 
 	if(IS_SET(MODE_MOUSE)) {
 		mousereport(e);
@@ -947,10 +947,6 @@ bmotion(XEvent *e) {
 	getbuttoninfo(e);
 
 	if(oldey != sel.ey || oldex != sel.ex) {
-		/*
-		starty = MIN(oldey, sel.ey);
-		endy = MAX(oldey, sel.ey);
-		*/
 		tsetdirt(sel.b.y, sel.e.y);
 	}
 }
@@ -1243,7 +1239,7 @@ selscroll(int orig, int n) {
 			sel.bx = -1;
 			return;
 		}
-		switch (sel.type) {
+		switch(sel.type) {
 		case SEL_REGULAR:
 			if(sel.by < term.top) {
 				sel.by = term.top;
-- 
1.7.10.4

