From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu From: steve.simon@snellwilcox.com Message-Id: <1389707828@snellwilcox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Id: <1389707828-1@snellwilcox.com> Content-Transfer-Encoding: 7bit Subject: [9fans] Chording & sam - from the archives Date: Mon, 23 Apr 2001 11:44:06 +0100 Topicbox-Message-UUID: 8b6961f0-eac9-11e9-9e20-41e7f4b1d025 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: Subject: Help-style cut and paste. To: sam-fans@hawkwind.utcs.toronto.edu Sender: "Mark H. Wilkinson" 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->clickf.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->clickf, &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; + } + } } }