ref: b74ce50a1c8670e46ee55c4aa09912da6567bd9b
parent: e7f777ae03a4e739471c8916b436fd261da242fa
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Sep 27 11:24:41 EDT 2018
vt: implement word select
--- a/sys/src/cmd/vt/main.c
+++ b/sys/src/cmd/vt/main.c
@@ -1002,6 +1002,23 @@
snarffp = Bopen("/dev/snarf",OREAD);
}
+int
+isalnum(Rune c)
+{
+ /*
+ * Hard to get absolutely right. Use what we know about ASCII
+ * and assume anything above the Latin control characters is
+ * potentially an alphanumeric.
+ */
+ if(c <= ' ')
+ return 0;
+ if(0x7F<=c && c<=0xA0)
+ return 0;
+ if(utfrune("!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~", c))
+ return 0;
+ return 1;
+}
+
void
unselect(void)
{
@@ -1029,6 +1046,14 @@
if(q.y > ymax){
q.y = ymax;
if(!blocksel) q.x = xmax+1;
+ }
+ if(line && eqpt(p, q)){
+ while(p.x > 0 && isalnum(*onscreenr(p.x-1, p.y)))
+ p.x--;
+ while(q.x <= xmax && isalnum(*onscreenr(q.x, q.y)))
+ q.x++;
+ if(p.x != q.x)
+ line = 0;
}
if(p.x < 0 || line)
p.x = 0;