diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-09-27 15:24:41 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-09-27 15:24:41 +0200 |
commit | b74ce50a1c8670e46ee55c4aa09912da6567bd9b (patch) | |
tree | 046cb7ed033054f14cebb547bb99e973441e9f21 /sys/src/cmd/vt | |
parent | e7f777ae03a4e739471c8916b436fd261da242fa (diff) |
vt: implement word select
Diffstat (limited to 'sys/src/cmd/vt')
-rw-r--r-- | sys/src/cmd/vt/main.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sys/src/cmd/vt/main.c b/sys/src/cmd/vt/main.c index acdd574e8..dc28688ac 100644 --- a/sys/src/cmd/vt/main.c +++ b/sys/src/cmd/vt/main.c @@ -1002,6 +1002,23 @@ paste(void) 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) { @@ -1030,6 +1047,14 @@ select(Point p, Point q, int line) 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; if(q.x > xmax+1 || line) |