vt: implement word select

This commit is contained in:
cinap_lenrek 2018-09-27 15:24:41 +02:00
parent e7f777ae03
commit b74ce50a1c

View file

@ -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)