Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/1027/19

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Add pop-up menu in lens.
 [rsc] --rw-rw-r-- M 320859 glenda sys 1272 Oct 27 11:11 sys/man/1/lens
	/n/sourcesdump/2005/1027/plan9/sys/man/1/lens:37,42 - 
	/n/sourcesdump/2005/1028/plan9/sys/man/1/lens:37,44
	  To make counting pixels easier, typing a
	  .B g
	  toggles whether a checkerboard grid is imposed on the magnified area.
	+ .PP
	+ Button 3 brings up a menu of actions.
	  .SH SOURCE
	  .B /sys/src/cmd/lens.c
	  .SH BUGS
 [rsc] --rw-rw-r-- M 320859 glenda sys 5109 Oct 27 11:10 sys/src/cmd/lens.c
	/n/sourcesdump/2005/1027/plan9/sys/src/cmd/lens.c:8,13 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/cmd/lens.c:8,36
	  	Maxmag = 16
	  };
	  
	+ enum {
	+ 	Mzoom,
	+ 	Munzoom,
	+ 	Mgrid,
	+ 	Mredraw,
	+ 	Mexit
	+ };
	+ 
	+ char *menustr[] = {
	+ 	"zoom",
	+ 	"unzoom",
	+ 	"grid",
	+ 	"redraw",
	+ 	"exit",
	+ 	nil
	+ };
	+ 
	+ Menu menu = {
	+ 	menustr,
	+ 	nil,
	+ 	-1
	+ };
	+ 
	  Point lastp;
	  Image *red;
	  Image *tmp;
	/n/sourcesdump/2005/1027/plan9/sys/src/cmd/lens.c:86,95 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/cmd/lens.c:109,121
	  		case Ekeyboard:
	  			switch(e.kbdc){
	  			case 'q':
	+ 			case 0x7f:
	  			case '\04':
	+ 			caseexit:
	  				exits(nil);
	  			case '=':
	  			case '+':
	+ 			casezoom:
	  				if(mag < Maxmag){
	  					mag++;
	  					makegrid();
	/n/sourcesdump/2005/1027/plan9/sys/src/cmd/lens.c:97,102 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/cmd/lens.c:123,129
	  				}
	  				break;
	  			case 'g':
	+ 			casegrid:
	  				showgrid = !showgrid;
	  				makegrid();
	  				drawit();
	/n/sourcesdump/2005/1027/plan9/sys/src/cmd/lens.c:103,108 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/cmd/lens.c:130,136
	  				break;
	  			case '-':
	  			case '_':
	+ 			caseunzoom:
	  				if(mag > 1){
	  					mag--;
	  					makegrid();
	/n/sourcesdump/2005/1027/plan9/sys/src/cmd/lens.c:111,116 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/cmd/lens.c:139,145
	  				break;
	  			case '.':
	  			case ' ':
	+ 			caseredraw:
	  				drawit();
	  				break;
	  			case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case'0':
	/n/sourcesdump/2005/1027/plan9/sys/src/cmd/lens.c:121,134 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/cmd/lens.c:150,174
	  				drawit();
	  				break;
	  			}
	- 			if(e.kbdc == 'q' || e.kbdc == '\04')
	- 				exits(nil);
	  			break;
	  		case Emouse:
	- 			if(e.mouse.buttons){
	+ 			if(e.mouse.buttons & 1){
	  				lastp = e.mouse.xy;
	  				drawit();
	  			}
	+ 			if(e.mouse.buttons & 4)
	+ 				switch(emenuhit(3, &e.mouse, &menu)){
	+ 				case Mzoom:
	+ 					goto casezoom;
	+ 				case Munzoom:
	+ 					goto caseunzoom;
	+ 				case Mgrid:
	+ 					goto casegrid;
	+ 				case Mredraw:
	+ 					goto caseredraw;
	+ 				case Mexit:
	+ 					goto caseexit;
	+ 				}
	  			break;
	  		}
	  }


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].