9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Chording & sam - from the archives
@ 2001-04-23 10:44 steve.simon
  0 siblings, 0 replies; only message in thread
From: steve.simon @ 2001-04-23 10:44 UTC (permalink / raw)
  To: 9fans


For those interested here is a diff from the sam-fans archive to implement mouse
chording,
it is very old and the sam source has probably changed enough to make applying
it a bit of a pain,
but... its free.

I rembember using this and being very impressed, but these days I'am tied to NT
and the
binary only Win sam release.

-Steve

 From sam-fans-owner Fri Aug 13 12:22:39 1993
Received: from minster.york.ac.uk ([144.32.128.41]) by hawkwind.utcs.toronto.edu
with SMTP id <2685>; Fri, 13 Aug 1993 12:21:52 -0400
From:   mhw@minster.york.ac.uk
Date:   Fri, 13 Aug 1993 13:14:57 -0400
Message-ID: <swordfish.745258897@minster.york.ac.uk>
Subject: Help-style cut and paste.
To: sam-fans@hawkwind.utcs.toronto.edu
Sender: "Mark H. Wilkinson" <mhw@minster.york.ac.uk>
X-Mailer: Sendmail/ream v4.12bv

I've been using Rob's help system under Plan 9 a bit recently and have
become so used to using mouse button chords to cut and paste that
returning to a system where these operations are selected from a menu
or with key presses feels awkward. Hence this patch, which puts this
feature of help into samterm.

For those who haven't seen help, mouse chords work like this: you select
some text by dragging with the left button down, or by double clicking,
as normal. While holding the left button down at the end of the selection
operation you can immediately cut it by clicking the middle button or
paste over it by clicking the right button. Running these two actions
together (i.e. while holding the left button click the middle button
and then the right button) is equivalent to snarf.

Share and enjoy...

-Mark.



diff -C 2 -r sam-dist/libframe/frselect.c sam-hack/libframe/frselect.c
*** sam-dist/libframe/frselect.c    Thu Aug  5 14:29:19 1993
--- sam-hack/libframe/frselect.c    Thu Aug  5 18:22:09 1993
***************
*** 42,46 ****
            f->p0 = p1, f->p1 = p0;
        frgetmouse();
!   }while(m->buttons & 1);
  }
  /* it is assumed p0<=p1 and both were generated by frptofchar() */
--- 42,46 ----
            f->p0 = p1, f->p1 = p0;
        frgetmouse();
!   }while((m->buttons & 7) == 1);
  }
  /* it is assumed p0<=p1 and both were generated by frptofchar() */
diff -C 2 -r sam-dist/samterm/flayer.c sam-hack/samterm/flayer.c
*** sam-dist/samterm/flayer.c   Thu Aug  5 14:17:06 1993
--- sam-hack/samterm/flayer.c   Thu Aug  5 18:22:11 1993
***************
*** 236,248 ****
    if(l->visible!=All)
        flupfront(l);
    frselect(&l->f, &mouse);
    if(l->f.p0==l->f.p1){
!       if(mouse.msec-l->click<Clicktime && l->f.p0+l->origin==l->p0){
            ret = 1;
            l->click = 0;
!       }else
            l->click = mouse.msec;
!   }else
        l->click = 0;
    l->p0 = l->f.p0+l->origin, l->p1 = l->f.p1+l->origin;
    return ret;
--- 236,254 ----
    if(l->visible!=All)
        flupfront(l);
+   if(mouse.msec-l->click<Clicktime)
+       ret = 1;
    frselect(&l->f, &mouse);
    if(l->f.p0==l->f.p1){
!       if(ret == 1 && l->f.p0+l->origin==l->p0){
            ret = 1;
            l->click = 0;
!       }else{
!           ret = 0;
            l->click = mouse.msec;
!       }
!   }else{
!       ret = 0;
        l->click = 0;
+   }
    l->p0 = l->f.p0+l->origin, l->p1 = l->f.p1+l->origin;
    return ret;
diff -C 2 -r sam-dist/samterm/main.c sam-hack/samterm/main.c
*** sam-dist/samterm/main.c Thu Aug  5 12:16:09 1993
--- sam-hack/samterm/main.c Thu Aug  5 18:31:03 1993
***************
*** 21,24 ****
--- 21,25 ----
  char  lock = 1;
  char  hasunlocked = 0;
+ int   chord = 0;

  void
***************
*** 77,81 ****
            if(mouse.buttons)
                flushtyping(1);
!           if(mouse.buttons&1){
                if(nwhich){
                    if(nwhich!=which)
--- 78,86 ----
            if(mouse.buttons)
                flushtyping(1);
!           if(chord == 1 && !mouse.buttons)
!               chord = 0;
!           if(chord)
!               chord |= mouse.buttons;
!           else if(mouse.buttons&1){
                if(nwhich){
                    if(nwhich!=which)
***************
*** 90,93 ****
--- 95,100 ----
                        }else if(t!=&cmd)
                            outcmd();
+                       if(mouse.buttons&1)
+                           chord = mouse.buttons;
                    }
                }
***************
*** 104,107 ****
--- 111,128 ----
            }
            mouseunblock();
+       }
+       if(chord){
+           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;
+               }
+           }
        }
    }





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-04-23 10:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-23 10:44 [9fans] Chording & sam - from the archives steve.simon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).