]> git.lizzy.rs Git - plan9front.git/commitdiff
sam: chording
authorcinap_lenrek <cinap_lenrek@rei2.9hal>
Fri, 10 Feb 2012 00:40:13 +0000 (01:40 +0100)
committercinap_lenrek <cinap_lenrek@rei2.9hal>
Fri, 10 Feb 2012 00:40:13 +0000 (01:40 +0100)
sys/src/cmd/samterm/flayer.c
sys/src/cmd/samterm/main.c

index 4e5797c3a34238b912898ec5f8ac59000c9c79ff..c61a531f7b5630e516753f0eae42731b7bcf4c0c 100644 (file)
@@ -252,21 +252,18 @@ fldelete(Flayer *l, long p0, long p1)
 int
 flselect(Flayer *l)
 {
-       int ret;
        if(l->visible!=All)
                flupfront(l);
-       frselect(&l->f, mousectl);
-       ret = 0;
-       if(l->f.p0==l->f.p1){
-               if(mousep->msec-l->click<Clicktime && l->f.p0+l->origin==l->p0){
-                       ret = 1;
+       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;
-               }else
-                       l->click = mousep->msec;
-       }else
-               l->click = 0;
+                       return 1;
+               }
+       l->click = mousep->msec;
+       frselect(&l->f, mousectl);
        l->p0 = l->f.p0+l->origin, l->p1 = l->f.p1+l->origin;
-       return ret;
+       return 0;
 }
 
 void
index 1548a7d4a2a6d8dfe31da5d6356f7d8e56df7773..315b69d804280cc40e1153b9f17bb54b280d6cc6 100644 (file)
@@ -28,7 +28,7 @@ int   autoindent;
 void
 threadmain(int argc, char *argv[])
 {
-       int i, got, scr;
+       int i, got, scr, chord;
        Text *t;
        Rectangle r;
        Flayer *nwhich;
@@ -51,6 +51,7 @@ threadmain(int argc, char *argv[])
        startnewfile(Tstartcmdfile, &cmd);
 
        got = 0;
+       chord = 0;
        for(;;got = waitforio()){
                if(hasunlocked && RESIZED())
                        resize();
@@ -77,7 +78,23 @@ threadmain(int argc, char *argv[])
                        scr = which && ptinrect(mousep->xy, which->scroll);
                        if(mousep->buttons)
                                flushtyping(1);
-                       if(mousep->buttons&1){
+                       if((mousep->buttons&1) == 0)
+                               chord = 0;
+                       if(chord && which && which==nwhich){
+                               chord |= mousep->buttons;
+                               t = (Text *)which->user1;
+                               if(!t->lock){
+                                       int w = which-t->l;
+                                       if(chord&2){
+                                               cut(t, w, 1, 1);
+                                               chord &= ~2;
+                                       }
+                                       if(chord&4){
+                                               paste(t, w);
+                                               chord &= ~4;
+                                       }
+                               }
+                       } else if(mousep->buttons&1){
                                if(nwhich){
                                        if(nwhich!=which)
                                                current(nwhich);
@@ -90,6 +107,8 @@ threadmain(int argc, char *argv[])
                                                        t->lock++;
                                                }else if(t!=&cmd)
                                                        outcmd();
+                                               if(mousep->buttons&1)
+                                                       chord = mousep->buttons;
                                        }
                                }
                        }else if((mousep->buttons&2) && which){