shithub: riscv

Download patch

ref: b9796e0774636821b0a0c50c600920805642960a
parent: 6fa3e08412c49a188e2abe7d9ee54cd1f37a85f5
author: cinap_lenrek <[email protected]>
date: Thu Sep 20 17:07:10 EDT 2018

vt: implement line selection by double click

--- a/sys/src/cmd/vt/main.c
+++ b/sys/src/cmd/vt/main.c
@@ -1013,10 +1013,10 @@
 }
 
 void
-select(Point p, Point q)
+select(Point p, Point q, int line)
 {
 	if(onscreenr(p.x, p.y) > onscreenr(q.x, q.y)){
-		select(q, p);
+		select(q, p, line);
 		return;
 	}
 	unselect();
@@ -1030,9 +1030,9 @@
 		q.y = ymax;
 		if(!blocksel) q.x = xmax+1;
 	}
-	if(p.x < 0)
+	if(p.x < 0 || line)
 		p.x = 0;
-	if(q.x > xmax+1)
+	if(q.x > xmax+1 || line)
 		q.x = xmax+1;
 	selrect = Rpt(p, q);
 	for(; p.y <= q.y; p.y++)
@@ -1042,18 +1042,22 @@
 void
 selecting(void)
 {
-	Point p;
+	Point p, q;
+	static ulong t;
 
 	p = pos(mc->xy);
+	t += mc->msec;
 	do{
+		q = pos(mc->xy);
+		select(p, q, t < 200);
 		drawscreen();
 		readmouse(mc);
-		select(p, pos(mc->xy));
 	} while(button1());
 	switch(mc->buttons & 0x7){
 	case 3:	snarfsel();	break;
 	case 5:	paste();	break;
 	}
+	t = -mc->msec;
 }
 
 int
@@ -1259,7 +1263,7 @@
 	/* move selection */
 	selrect.min.y -= d;
 	selrect.max.y -= d;
-	select(selrect.min, selrect.max);
+	select(selrect.min, selrect.max, 0);
 	
 	clear(0, cy, xmax+1, cy+1);
 }