diff options
author | Ori Bernstein <ori@eigenstate.org> | 2020-04-25 08:57:26 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2020-04-25 08:57:26 -0700 |
commit | f616a0c1bd161c8d3a4765a9d171403974011922 (patch) | |
tree | 7ca8c48d9e4c286f5519226e424661d6d613b1fe /sys/src/cmd/samterm | |
parent | 614b18484cb754c4ba936d143016b558845073b1 (diff) |
triple click selection in sam
three clicks selects a whitespace-delimited line.
Diffstat (limited to 'sys/src/cmd/samterm')
-rw-r--r-- | sys/src/cmd/samterm/flayer.c | 20 | ||||
-rw-r--r-- | sys/src/cmd/samterm/flayer.h | 2 | ||||
-rw-r--r-- | sys/src/cmd/samterm/main.c | 10 |
3 files changed, 22 insertions, 10 deletions
diff --git a/sys/src/cmd/samterm/flayer.c b/sys/src/cmd/samterm/flayer.c index c61a531f7..101effb6e 100644 --- a/sys/src/cmd/samterm/flayer.c +++ b/sys/src/cmd/samterm/flayer.c @@ -252,15 +252,23 @@ fldelete(Flayer *l, long p0, long p1) int flselect(Flayer *l) { + static int clickcount; + static Point clickpt = {-10, -10}; + int dt, dx, dy; + if(l->visible!=All) flupfront(l); - if(l->f.p0==l->f.p1) - if(mousep->msec-l->click<Clicktime && l->f.p0+l->origin==l->p0 && - l->f.p0==frcharofpt(&l->f, mousep->xy)){ - l->click = 0; - return 1; - } + dt = l->click = mousep->msec; + dx = abs(mousep->xy.x - clickpt.x); + dy = abs(mousep->xy.y - clickpt.y); + l->click = mousep->msec; + clickpt = mousep->xy; + + if(dx < 3 && dy < 3 && dt < Clicktime && clickcount < 3) + return ++clickcount; + clickcount = 0; + frselect(&l->f, mousectl); l->p0 = l->f.p0+l->origin, l->p1 = l->f.p1+l->origin; return 0; diff --git a/sys/src/cmd/samterm/flayer.h b/sys/src/cmd/samterm/flayer.h index 41306f79e..0967999e5 100644 --- a/sys/src/cmd/samterm/flayer.h +++ b/sys/src/cmd/samterm/flayer.h @@ -5,7 +5,7 @@ typedef enum Vis{ }Vis; enum{ - Clicktime=1000, /* one second */ + Clicktime=500, /* milliseconds */ }; typedef struct Flayer Flayer; diff --git a/sys/src/cmd/samterm/main.c b/sys/src/cmd/samterm/main.c index 14444e0ee..ec584f58e 100644 --- a/sys/src/cmd/samterm/main.c +++ b/sys/src/cmd/samterm/main.c @@ -31,7 +31,7 @@ int spacesindent; void threadmain(int argc, char *argv[]) { - int i, got, scr, chord; + int i, got, nclick, scr, chord; Text *t; Rectangle r; Flayer *nwhich; @@ -105,8 +105,12 @@ threadmain(int argc, char *argv[]) current(nwhich); else{ t=(Text *)which->user1; - if(flselect(which)){ - outTsl(Tdclick, t->tag, which->p0); + nclick = flselect(which); + if(nclick > 0){ + if(nclick > 1) + outTsl(Ttclick, t->tag, which->p0); + else + outTsl(Tdclick, t->tag, which->p0); t->lock++; }else if(t!=&cmd) outcmd(); |