sam-fans - fans of the sam editor
 help / color / mirror / Atom feed
* Help-style cut and paste.
@ 1993-08-13 17:14 mhw
  0 siblings, 0 replies; only message in thread
From: mhw @ 1993-08-13 17:14 UTC (permalink / raw)
  To: sam-fans

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:[~1993-08-13 16:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-08-13 17:14 Help-style cut and paste mhw

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