summaryrefslogtreecommitdiff
path: root/sys/src/cmd/vt
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-09-20 21:07:10 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2018-09-20 21:07:10 +0200
commitb9796e0774636821b0a0c50c600920805642960a (patch)
tree076e4f3d69cdabec6d9f2c2ca6c762d5e71fe851 /sys/src/cmd/vt
parent6fa3e08412c49a188e2abe7d9ee54cd1f37a85f5 (diff)
vt: implement line selection by double click
Diffstat (limited to 'sys/src/cmd/vt')
-rw-r--r--sys/src/cmd/vt/main.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/src/cmd/vt/main.c b/sys/src/cmd/vt/main.c
index ec970d2b0..c660179da 100644
--- a/sys/src/cmd/vt/main.c
+++ b/sys/src/cmd/vt/main.c
@@ -1013,10 +1013,10 @@ unselect(void)
}
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 @@ select(Point p, Point q)
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 @@ select(Point p, Point q)
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 @@ scroll(int sy, int ly, int dy, int cy) /* source, limit, dest, which line to cle
/* 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);
}