sam-fans - fans of the sam editor
 help / color / mirror / Atom feed
From: Scott Schwartz <schwartz@groucho.cse.psu.edu>
To: Sam Fans <sam-fans@hawkwind.utcs.toronto.edu>
Subject: scrollForwardR is buggy (+patch)
Date: Sun, 18 Jul 1993 18:21:05 -0400	[thread overview]
Message-ID: <93Jul18.182024edt.2579@groucho.cse.psu.edu> (raw)

Greetings all,

In the Bell Labs distribution, if the X resource database contains
	Sam*scrollForwardR:false
then scrolling will malfunction.   As distributed, scrollForwardR works
by having samterm/main.c lie to scroll() about which button was
pressed, if it was 1 or 3.  Unfortunately, scroll() detects the lie at
line 122 when it calls button(but); it will always exit the loop at
that point since the real mouse won't match but.  My fix was to have
the scrolling logic in samterm check to see which is the
forward-scrolling button in the three places it needs to know that.

*** 1.1	1993/07/18 21:23:20
--- main.c	1993/07/18 22:00:31
***************
*** 21,26 ****
--- 21,28 ----
  char	lock = 1;
  char	hasunlocked = 0;
  
+ int	fwdbut = 3;		/* an X resource may set this to 1 */
+ 
  void
  main(int argc, char *argv[])
  {
***************
*** 29,36 ****
  	Rectangle r;
  	Flayer *nwhich;
  
- 	int fwdbut;
- 
  	getscreen(argc, argv);
  	fwdbut = scrollfwdbut();
  	iconinit();
--- 31,36 ----
***************
*** 81,87 ****
  					if(nwhich!=which)
  						current(nwhich);
  					else if(scr)
! 						scroll(which, fwdbut == 3 ? 1 : 3);
  					else{
  						t=(Text *)which->user1;
  						if(flselect(which)){
--- 81,87 ----
  					if(nwhich!=which)
  						current(nwhich);
  					else if(scr)
! 						scroll(which, 1);
  					else{
  						t=(Text *)which->user1;
  						if(flselect(which)){
***************
*** 98,104 ****
  					menu2hit();
  			}else if((mouse.buttons&4)){
  				if(scr)
! 					scroll(which, fwdbut == 3 ? 3 : 1);
  				else
  					menu3hit();
  			}
--- 98,104 ----
  					menu2hit();
  			}else if((mouse.buttons&4)){
  				if(scr)
! 					scroll(which, 3);
  				else
  					menu3hit();
  			}
***************
*** 287,302 ****
  {
  	Text *t=(Text *)l->user1;
  
! 	switch(but){
! 	case 1:
  		outTsll(Torigin, t->tag, l->origin, p0);
! 		break;
! 	case 2:
  		outTsll(Torigin, t->tag, p0, 1L);
! 		break;
! 	case 3:
  		horigin(t->tag,p0);
- 	}
  }
  
  int
--- 287,298 ----
  {
  	Text *t=(Text *)l->user1;
  
! 	if (but == BCKBUT)
  		outTsll(Torigin, t->tag, l->origin, p0);
! 	else if (but == SETBUT)
  		outTsll(Torigin, t->tag, p0, 1L);
! 	else if (but == FWDBUT)
  		horigin(t->tag,p0);
  }
  
  int
*** 1.1	1993/07/18 21:30:30
--- samterm.h	1993/07/18 22:00:33
***************
*** 5,10 ****
--- 5,14 ----
  #define	MAXFILES	256
  #define	NL	5
  
+ #define BCKBUT (4-fwdbut)
+ #define SETBUT (2)
+ #define FWDBUT (fwdbut)
+ 
  enum{
  	Up,
  	Down
***************
*** 67,72 ****
--- 71,77 ----
  extern long	snarflen;
  extern Mouse	mouse;
  extern long	modified;
+ extern int	fwdbut;
  
  Rune	*gettext(Flayer*, long, ulong*);
  void	*alloc(ulong n);
*** 1.1	1993/07/16 20:06:17
--- scroll.c	1993/07/18 22:05:39
***************
*** 100,114 ****
  				my = s.max.y;
  			if(!eqpt(mouse.xy, Pt(x, my)))
  				cursorset(Pt(x, my));
! 			if(but == 1){
  				p0 = l->origin-frcharofpt(&l->f, Pt(s.max.x, my));
  				rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot);
  				y = rt.min.y;
! 			}else if(but == 2){
  				y = my;
  				if(y > s.max.y-2)
  					y = s.max.y-2;
! 			}else if(but == 3){
  				p0 = l->origin+frcharofpt(&l->f, Pt(s.max.x, my));
  				rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot);
  				y = rt.min.y;
--- 100,114 ----
  				my = s.max.y;
  			if(!eqpt(mouse.xy, Pt(x, my)))
  				cursorset(Pt(x, my));
! 			if(but == BCKBUT){
  				p0 = l->origin-frcharofpt(&l->f, Pt(s.max.x, my));
  				rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot);
  				y = rt.min.y;
! 			}else if(but == SETBUT){
  				y = my;
  				if(y > s.max.y-2)
  					y = s.max.y-2;
! 			}else if(but == FWDBUT){
  				p0 = l->origin+frcharofpt(&l->f, Pt(s.max.x, my));
  				rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot);
  				y = rt.min.y;
***************
*** 118,137 ****
  				r = raddp(scr, Pt(0, y-scr.min.y));
  				scrflip(l, r);
  			}
! 		}
  	}while(button(but));
  	if(in){
  		h = s.max.y-s.min.y;
  		scrflip(l, r);
  		p0 = 0;
! 		if(but == 1)
  			p0 = (long)(my-s.min.y)/l->f.font->height+1;
! 		else if(but == 2){
  			if(tot > 1024L*1024L)
  				p0 = ((tot>>10)*(y-s.min.y)/h)<<10;
  			else
  				p0 = tot*(y-s.min.y)/h;
! 		}else if(but == 3){
  			p0 = l->origin+frcharofpt(&l->f, Pt(s.max.x, my));
  			if(p0 > tot)
  				p0 = tot;
--- 118,137 ----
  				r = raddp(scr, Pt(0, y-scr.min.y));
  				scrflip(l, r);
  			}
! 		}		
  	}while(button(but));
  	if(in){
  		h = s.max.y-s.min.y;
  		scrflip(l, r);
  		p0 = 0;
! 		if(but == BCKBUT)
  			p0 = (long)(my-s.min.y)/l->f.font->height+1;
! 		else if(but == SETBUT){
  			if(tot > 1024L*1024L)
  				p0 = ((tot>>10)*(y-s.min.y)/h)<<10;
  			else
  				p0 = tot*(y-s.min.y)/h;
! 		}else if(but == FWDBUT){
  			p0 = l->origin+frcharofpt(&l->f, Pt(s.max.x, my));
  			if(p0 > tot)
  				p0 = tot;


                 reply	other threads:[~1993-07-18 22:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=93Jul18.182024edt.2579@groucho.cse.psu.edu \
    --to=schwartz@groucho.cse.psu.edu \
    --cc=sam-fans@hawkwind.utcs.toronto.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).