Plan 9 from Bell Labs’s /usr/web/sources/extra/changes/2005/1205

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


Document recent changes.
 [rsc] --rw-rw-r-- M 786594 glenda sys 2472 Dec  5 12:34 sys/man/1/vt
	/n/sourcesdump/2005/1205/plan9/sys/man/1/vt:4,11 - 
	/n/sourcesdump/2005/1206/plan9/sys/man/1/vt:4,15
	  .SH SYNOPSIS
	  .B vt
	  [
	- .B -2sa
	+ .B -2aswx
	  ]
	+ [
	+ .B -f
	+ .I font
	+ ]
	  .SH DESCRIPTION
	  .I Vt
	  replaces a rio window with a fresh instance of the shell
	/n/sourcesdump/2005/1205/plan9/sys/man/1/vt:12,28 - 
	/n/sourcesdump/2005/1206/plan9/sys/man/1/vt:16,48
	  .IR rc (1)
	  running within an emulation of a DEC VT-100 terminal.
	  The
	- .B -2
	- and
	+ .BR -2 ,
	  .B -a
	- options configure
	+ and
	+ .B -x
	+ options change
	  .I vt
	- to emulate a VT-220 and Ansi terminal respectively.
	+ to emulate a VT-220, ANSI, or XTerm terminal respectively.
	+ .PP
	  The
	  .B -s
	- options forces a saner color scheme, i.e, black text on white
	- background.
	+ option changes the color scheme to black text on a white background.
	  .PP
	+ The
	+ .B -w
	+ option causes
	+ .I vt
	+ to provide a 
	+ .B /dev/wctl
	+ file that can be read to learn about window size changes.
	+ In particular,
	+ .IR ssh (1)
	+ will read this file and inform the remote system about size changes.
	+ .PP
	+ The
	+ .B -f
	+ option sets the font.
	+ .PP
	  The right button has a menu with the following entries to provide
	  the sort of character processing expected by non-Plan 9 systems:
	  .TF cooked
	/n/sourcesdump/2005/1205/plan9/sys/man/1/vt:51,57 - 
	/n/sourcesdump/2005/1206/plan9/sys/man/1/vt:71,77
	  Leave raw mode.
	  .TP
	  .B exit
	- Exits
	+ Exit
	  .IR vt .
	  .PD
	  .PP
	/n/sourcesdump/2005/1205/plan9/sys/man/1/vt:93,101 - 
	/n/sourcesdump/2005/1206/plan9/sys/man/1/vt:113,121
	  .PP
	  To exit
	  .IR vt ,
	- exit its
	+ exit the
	  .B rc
	- session by, for example, typing EOT (control-D).
	+ it starts.
	  .SH SOURCE
	  .B /sys/src/cmd/vt
	  .SH BUGS
	/n/sourcesdump/2005/1205/plan9/sys/man/1/vt:105,109 - 
	/n/sourcesdump/2005/1206/plan9/sys/man/1/vt:125,131
	  .PP
	  Use care in setting raw and newline modes when connecting to Unix systems
	  via
	- .IR con .
	+ .IR con (1)
	+ or
	+ .IR ssh (1).
	  It may also be necessary to set the emulator into raw mode.
 [rsc] --rw-rw-r-- M 786594 glenda sys 2472 Dec  5 12:34 sys/man/1/vt
 [rsc] --rw-rw-r-- M 786594 glenda sys 14466 Dec  5 15:35 sys/src/cmd/vt/main.c
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/main.c:48,79 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/main.c:48,88
	  char	*histp;
	  char	hist[HISTSIZ];
	  int	yscrmin, yscrmax;
	- int	bckcolor, frgcolor, bckdefault, frgdefault;
	- int	attribute, attdefault;
	+ int	attr, defattr;
	  int	wctlout;
	- int	wflag;
	  
	  Image	*bordercol;
	  Image	*cursback;
	- Image	*black;
	+ Image	*colors[8];
	+ Image	*hicolors[8];
	  Image	*red;
	- Image	*green;
	- Image	*blue;
	- Image	*cyan;
	- Image	*purple;
	- Image	*brown;
	- Image	*grey;
	- Image	*hiblack;
	- Image	*hired;
	- Image	*higreen;
	- Image	*hiblue;
	- Image	*hicyan;
	- Image	*hipurple;
	- Image	*hibrown;
	- Image	*higrey;
	- Image	*colortab[8];
	- Image	*hicolortab[8];
	+ Image	*fgcolor;
	+ Image	*bgcolor;
	+ Image	*fgdefault;
	+ Image	*bgdefault;
	  
	+ uint rgbacolors[8] = {
	+ 	0x000000FF,	/* black */
	+ 	0xAA0000FF,	/* red */
	+ 	0x00AA00FF,	/* green */
	+ 	0xFF5500FF,	/* brown */
	+ 	0x0000FFFF,	/* blue */
	+ 	0xAA00AAFF,	/* purple */
	+ 	0x00AAAAFF,	/* cyan */
	+ 	0x7F7F7FFF,	/* white */
	+ };
	+ 
	+ ulong rgbahicolors[8] = {
	+ 	0x555555FF,	/* light black aka grey */
	+ 	0xFF5555FF,	/* light red */
	+ 	0x55FF55FF,	/* light green */
	+ 	0xFFFF55FF,	/* light brown aka yellow */
	+ 	0x5555FFFF,	/* light blue */
	+ 	0xFF55FFFF,	/* light purple */
	+ 	0x55FFFFFF,	/* light cyan */
	+ 	0xFFFFFFFF,	/* light grey aka white */
	+ };
	+ 
	  /* terminal control */
	  struct ttystate ttystate[2] = { {0, 1}, {0, 1} };
	  
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/main.c:85,91 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/main.c:94,99
	  int	outfd = -1;
	  Biobuf	*snarffp = 0;
	  
	- Font	*fnt;
	  char	*host_buf;
	  char	*hostp;			/* input from host */
	  int	host_bsize = 2*BSIZE;
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/main.c:122,128 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/main.c:130,136
	  }
	  
	  void
	- useage(void)
	+ usage(void)
	  {
	  	fprint(2, "usage: %s [-2s] [-l logfile]\n", argv0);
	  	exits("usage");
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/main.c:131,147 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/main.c:139,155
	  void
	  initialize(int argc, char **argv)
	  {
	- 	int dayglo = 1;
	- 	char *p;
	- 	char *fname = 0;
	+ 	int i;
	+ 	char *fontname, *p;
	  
	- 	rfork(RFENVG|RFNAMEG|RFNOTEG);
	+ 	rfork(RFNAMEG|RFNOTEG);
	  
	+ 	fontname = nil;
	  	term = "vt100";
	  	fk = vt100fk;
	  	ARGBEGIN{
	  	case 'f':
	- 		fname = EARGF(useage());
	+ 		fontname = EARGF(usage());
	  		break;
	  	case 'a':
	  		term = "ansi";
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/main.c:155,174 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/main.c:163,174
	  		fk = xtermfk;
	  		term = "xterm";
	  		break;
	- 	case 's': /* for sape */
	- 		dayglo = 0;
	- 		break;
	  	case 'l':
	- 		p = ARGF();
	- 		if(p == 0)
	- 			useage();
	+ 		p = EARGF(usage());
	  		logfd = create(p, OWRITE, 0666);
	  		if(logfd < 0)
	  			sysfatal("could not create log file: %s: %r", p);
	  		break;
	- 	case 'w':
	- 		wflag = 1;
	- 		break;
	  	}ARGEND;
	  
	  	host_buf = malloc(host_bsize);
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/main.c:175,260 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/main.c:175,210
	  	hostp = host_buf;
	  	hostlength = 0;
	  
	- 	if(initdraw(0,0,term) < 0){
	+ 	if(initdraw(0, fontname, term) < 0){
	  		fprint(2, "%s: initdraw failed: %r\n", term);
	  		exits("initdraw");
	  	}
	  	ebegin(Ehost);
	  
	- 	if(fname)
	- 		fnt = openfont(display, fname);
	- 	if(fnt == nil)
	- 		fnt = font;
	- 
	  	histp = hist;
	  	menu2.item = menutext2;
	  	menu3.item = menutext3;
	  	pagemode = 0;
	  	blocked = 0;
	- 	NS = fnt->height;
	- 	CW = stringwidth(fnt, "m");
	+ 	NS = font->height;
	+ 	CW = stringwidth(font, "m");
	  
	+ 	red = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DRed);
	  	bordercol = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0xCCCCCCCC);
	  	cursback = allocimage(display, Rect(0, 0, CW+1, NS+1), screen->chan, 0, DNofill);
	  
	- 	black =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x000000FF);
	- 	red =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1,   0xAA0000FF);
	- 	green =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x00AA00FF);
	- 	blue =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1,  0x0000FFFF);
	- 	cyan =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1,  0x00AAAAFF);
	- 	purple = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xAA00AAFF);
	- 	brown = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1,  0xFF5500FF);
	- 	grey =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1,  0x7F7F7FFF);
	- 
	- 	hiblack =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x555555FF);
	- 	hired =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1,   0xff5555FF);
	- 	higreen =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0x55ff55FF);
	- 	hiblue =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1,  0x5555ffFF);
	- 	hicyan =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1,  0x55ffffFF);
	- 	hipurple = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xff55ffFF);
	- 	hibrown = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1,  0xffff55FF);
	- 	higrey =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1,  0xffffffFF);
	- 
	- 	bckdefault = bckcolor = 0;
	- 	frgdefault = frgcolor = 7;
	- 	if(dayglo){
	- 		colortab[0] = black;
	- 		colortab[1] = red;
	- 		colortab[2] = green;
	- 		colortab[3] = brown;
	- 		colortab[4] = blue;
	- 		colortab[5] = purple;
	- 		colortab[6] = cyan;
	- 		colortab[7] = grey;
	- 		hicolortab[0] = hiblack;
	- 		hicolortab[1] = hired;
	- 		hicolortab[2] = higreen;
	- 		hicolortab[3] = hibrown;
	- 		hicolortab[4] = hiblue;
	- 		hicolortab[5] = hipurple;
	- 		hicolortab[6] = hicyan;
	- 		hicolortab[7] = higrey;
	- 	} else {
	- 		hicolortab[0] = grey;
	- 		hicolortab[1] = red;
	- 		hicolortab[2] = green;
	- 		hicolortab[3] = brown;
	- 		hicolortab[4] = blue;
	- 		hicolortab[5] = purple;
	- 		hicolortab[6] = cyan;
	- 		hicolortab[7] = black;
	- 		colortab[0] = higrey;
	- 		colortab[1] = hired;
	- 		colortab[2] = higreen;
	- 		colortab[3] = hibrown;
	- 		colortab[4] = hiblue;
	- 		colortab[5] = hipurple;
	- 		colortab[6] = hicyan;
	- 		colortab[7] = hiblack;
	+ 	for(i=0; i<8; i++){
	+ 		colors[i] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, rgbacolors[i]);
	+ 		hicolors[i] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, rgbahicolors[i]);
	  	}
	  
	- 	eresized(0);
	+ 	bgdefault = display->white;
	+ 	fgdefault = display->black;
	+ 	bgcolor = bgdefault;
	+ 	fgcolor = fgdefault;
	  
	+ 	resize();
	+ 
	  	if(argc > 0) {
	  		sendnchars(strlen(argv[0]),argv[0]);
	  		sendnchars(1,"\n");
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/main.c:264,270 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/main.c:214,220
	  void
	  clear(Rectangle r)
	  {
	- 	draw(screen, r, colortab[bckcolor], nil, ZP);
	+ 	draw(screen, r, bgcolor, nil, ZP);
	  }
	  
	  void
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/main.c:286,292 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/main.c:236,243
	  void
	  cursoff(void)
	  {
	- 	draw(screen, Rpt(pt(x, y), addpt(pt(x, y), Pt(CW,NS))), cursback, nil, cursback->r.min);
	+ 	draw(screen, Rpt(pt(x, y), addpt(pt(x, y), Pt(CW,NS))), 
	+ 		cursback, nil, cursback->r.min);
	  }
	  
	  void
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/main.c:294,304 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/main.c:245,256
	  {
	  	Image *col;
	  
	- 	draw(cursback, cursback->r, screen, nil, pt(x, y));
	- 
	- 	if(!cursoron)
	+ 	if(!cursoron){
	+ 		cursoff();
	  		return;
	+ 	}
	  
	+ 	draw(cursback, cursback->r, screen, nil, pt(x, y));
	  	if(bl)
	  		col = red;
	  	else
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/main.c:577,608 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/main.c:529,555
	  }
	  
	  void
	- exportsize(void)
	+ putenvint(char *name, int x)
	  {
	- 	int	fd;
	- 	char	buf[10];
	+ 	char buf[20];
	  
	- 	if((fd = create("/env/LINES", OWRITE, 0644)) > 0) {
	- 		sprint(buf,"%d",ymax+1);
	- 		write(fd,buf,strlen(buf));
	- 		close(fd);
	- 	}
	- 	if((fd = create("/env/COLS", OWRITE, 0644)) > 0) {
	- 		sprint(buf,"%d",xmax+1);
	- 		write(fd,buf,strlen(buf));
	- 		close(fd);
	- 	}
	- 	if((fd = create("/env/TERM", OWRITE, 0644)) > 0) {
	- 		fprint(fd, "%s", term);
	- 		close(fd);
	- 	}
	+ 	snprint(buf, sizeof buf, "%d", x);
	+ 	putenv(name, buf);
	  }
	  
	  void
	+ exportsize(void)
	+ {
	+ 	putenvint("XPIXELS", Dx(screen->r)-2*XMARGIN);
	+ 	putenvint("YPIXELS", Dy(screen->r)-2*XMARGIN);
	+ 	putenvint("LINES", ymax+1);
	+ 	putenvint("COLS", xmax+1);
	+ 	putenv("TERM", term);
	+ }
	+ 
	+ void
	  resize(void)
	  {
	- 	static int oldwt;
	- 	static int oldht;
	  	if(resize_flag > 1 && getwindow(display, Refnone) < 0){
	  		fprint(2, "can't reattach to window: %r\n");
	  		exits("can't reattach to window");
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/main.c:618,628 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/main.c:565,570
	  	olines = 0;
	  	exportsize();
	  	clear(screen->r);
	- 	fprint(wctlout, " %11d %11d %11d %11d",
	- 		screen->r.min.x, screen->r.min.y,
	- 		screen->r.max.x, screen->r.max.y);
	- 	oldwt = Dx(screen->r);
	- 	oldht = Dy(screen->r);
	  	resize_flag = 0;
	  }
	  
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/main.c:758,764 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/main.c:700,706
	  {
	  	draw(screen, Rpt(pt(0, dy), pt(xmax+1, dy+ly-sy)), screen, nil, pt(0, sy));
	  	clear(Rpt(pt(0, cy), pt(xmax+1, cy+1)));
	- 	flushimage(display,1);
	+ 	flushimage(display, 1);
	  }
	  
	  void
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/main.c:894,931 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/main.c:836,859
	  
	  
	  void
	- drawstring(Point p, char *str, int attribute)
	+ drawstring(Point p, char *str, int attr)
	  {
	- 	Image *txt, *bg;
	- 	Rune *rstr;
	- 	int i, n;
	+ 	int i;
	+ 	Image *txt, *bg, *tmp;
	  	
	- 	if(!(attribute & TReverse)) {
	- 		if(attribute & THighIntensity || bckcolor){
	- 			txt = hicolortab[frgcolor];
	- 			bg = colortab[bckcolor];
	- 		}else{
	- 			txt = colortab[frgcolor];
	- 			bg = colortab[bckcolor];
	- 		}
	- 	} else {
	- 		if(attribute & THighIntensity || bckcolor){
	- 			txt = colortab[bckcolor];
	- 			bg = colortab[frgcolor];
	- 		}else{
	- 			txt = colortab[bckcolor];
	- 			bg = colortab[frgcolor];
	- 		}
	+ 	txt = fgcolor;
	+ 	bg = bgcolor;
	+ 	if(attr & TReverse){
	+ 		tmp = txt;
	+ 		txt = bg;
	+ 		bg = tmp;
	  	}
	+ 	if(attr & THighIntensity){
	+ 		for(i=0; i<8; i++)
	+ 			if(txt == colors[i])
	+ 				txt = hicolors[i];
	+ 	}
	  
	- 	n = strlen(str) + 1;
	- 	rstr = malloc(n * sizeof(rstr[0]));
	- 
	- 	for(i = 0; i < n; ++i)
	- 		rstr[i] = (uchar)str[i];
	- 
	- 	draw(screen, Rpt(p, addpt(p, runestringsize(fnt, rstr))), bg, nil, p);
	- 	runestring(screen, p, txt, ZP, fnt, rstr);
	- 
	- 	free(rstr);
	+ 	draw(screen, Rpt(p, addpt(p, stringsize(font, str))), bg, nil, p);
	+ 	string(screen, p, txt, ZP, font, str);
	  }
 [rsc] --rw-rw-r-- M 786594 glenda sys 1792 Dec  5 13:44 sys/src/cmd/vt/cons.h
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/cons.h:70,84 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/cons.h:70,86
	  
	  extern int	debug;
	  extern int	yscrmin, yscrmax;
	- extern int	attribute;
	- extern int	attdefault;
	- extern int	frgcolor;
	- extern int	bckcolor;
	- extern int	frgdefault;
	- extern int	bckdefault;
	+ extern int	attr;
	+ extern int	defattr;
	+ 
	+ extern Image *fgcolor;
	+ extern Image *bgcolor;
	+ extern Image *colors[];
	+ extern Image *hicolors[];
	+ extern Image *bgdefault;
	+ extern Image *fgdefault;
	+ 
	  extern int cursoron;
	- extern Font *fnt;
	- extern int	wflag;
	  
	  extern void curson(int);
	  extern void cursoff(void);
 [rsc] --rw-rw-r-- M 786594 glenda sys 1071 Dec  5 13:44 sys/src/cmd/vt/event.c
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/event.c:7,13 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/event.c:7,12
	  #define	BUFSIZ	4000
	  
	  extern int	outfd;
	- extern int	wctlout;
	  
	  int	hostpid;
	  
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/event.c:32,46 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/event.c:31,38
	  		exits("consctl");
	  	}
	  
	- 	if(wflag){
	- 		bind("#|", "/mnt/temp", MREPL);
	- 		wctlout = open("/mnt/temp/data", OWRITE);
	- 	}
	- 
	  	switch((hostpid = rfork(RFPROC|RFNAMEG|RFFDG|RFNOTEG))) {
	  	case 0:
	- 		if(wflag)
	- 			bind("/mnt/temp/data1", "/dev/wctl", MREPL);
	  		fd = open("/dev/cons", OREAD);
	  		dup(fd,0);
	  		if(fd != 0)
 [rsc] --rw-rw-r-- M 786594 glenda sys 3362 Dec  5 13:44 sys/src/cmd/vt/hp.c
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/hp.c:199,205 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/hp.c:199,205
	  					Rpt(pt(x, y), pt(xmax-n+1, y+1)), S);
	  			}
	  			xtipple(Rpt(pt(x,y), pt(x+n, y+1)));
	- 			string(&screen, pt(x, y), fnt, buf, DxorS);
	+ 			string(&screen, pt(x, y), font, buf, DxorS);
	  			if (standout)
	  				rectf(&screen,
	  				      Rpt(pt(x,y),pt(x+n,y+1)),
 [rsc] --rw-rw-r-- M 786594 glenda sys 14466 Dec  5 15:35 sys/src/cmd/vt/main.c
 [rsc] --rw-rw-r-- M 786594 glenda sys 19606 Dec  5 13:44 sys/src/cmd/vt/vt.c
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:139,145 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:139,145
	  	int c;
	  	int operand[10];
	  	int noperand;
	- 	int savex, savey, saveattribute, saveisgraphics;
	+ 	int savex, savey, saveattr, saveisgraphics;
	  	int isgraphics;
	  	int g0set, g1set;
	  	int dch;
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:150,156 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:150,156
	  	savex = savey = 0;
	  	yscrmin = 0;
	  	yscrmax = ymax;
	- 	saveattribute = 0;
	+ 	saveattr = 0;
	  	saveisgraphics = 0;
	  	/* set initial tab stops to DEC-standard 8-column spacing */
	  	for(c=0; (c+=8)<nelem(tabcol);)
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:196,202 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:196,201
	  		case '\013':
	  		case '\014':
	  			newline();
	- 			//attribute = attdefault;
	  			if (ttystate[cs->raw].nlcr)
	  				x = 0;
	  			break;
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:203,209 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:202,207
	  
	  		case '\015':		/* carriage return */
	  			x = 0;
	- 			//attribute = attdefault;
	  			if (ttystate[cs->raw].crnl)
	  				newline();
	  			break;
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:258,264 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:256,262
	  //print("save\n");
	  				savex = x;
	  				savey = y;
	- 				saveattribute = attribute;
	+ 				saveattr = attr;
	  				saveisgraphics = isgraphics;
	  				break;
	  
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:269,275 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:267,273
	  //print("restore\n");
	  				x = savex;
	  				y = savey;
	- 				attribute = saveattribute;
	+ 				attr = saveattr;
	  				isgraphics = saveisgraphics;
	  				break;
	  
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:431,437 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:429,434
	  						if(noperand == 1){
	  							switch(operand[0]){	
	  							case 20:	/* set line feed mode */
	- print("linefeedmode\n");
	  								ttystate[cs->raw].nlcr = 1;
	  								break;
	  							case 30:	/* screen invisible (? not supported through VT220) */
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:451,457 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:448,453
	  							case 5:	/* set normal video on screen */
	  								break;
	  							case 6:	/* set origin to absolute */
	- //print("OL\n");
	  								originrelative = 0;
	  								x = y = 0;
	  								break;
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:479,492 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:475,485
	  					 * h - set various options.
	  					 */
	  					case 'h':
	- //print("h%d:%d,%d\n", noperand, operand[0], operand[1]);
	  						if(noperand == 1){
	  							switch(operand[0]){
	  							default:
	- //print("escape2 'h' unknown operand %d (n:%d)\n", operand[0], noperand-1);
	  								break;
	  							case 20:	/* set newline mode */
	- print("newlinemode\n");
	  								ttystate[cs->raw].nlcr = 0;
	  								break;
	  							case 30:	/* screen visible (? not supported through VT220) */
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:495,501 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:488,493
	  						}else while(--noperand > 0){
	  							switch(operand[noperand]){
	  							default:
	- //print("escape2 'h' operand: %d (n:%d)\n", operand[noperand], noperand);
	  								break;
	  							case 1:	/* set cursor keys to send application function: ESC O A..D */
	  								break;
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:509,515 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:501,506
	  							case 5:	/* set screen to reverse video (not implemented) */
	  								break;
	  							case 6:	/* set origin to relative */
	- //print("origin relative\n");
	  								originrelative = 1;
	  								x = 0;
	  								y = yscrmin;
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:529,535 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:520,526
	  						break;
	  
	  					/*
	- 					 * m - change character attributes.
	+ 					 * m - change character attrs.
	  					 */
	  					case 'm':
	  						setattr(noperand, operand);
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:544,550 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:535,540
	  							sendnchars2(4, "\033[0n");	/* terminal ok */
	  							break;
	  						case 6:	/* cursor position */
	- //print("cursor pos\n");
	  							sendnchars2(sprint(buf, "\033[%d;%dR",
	  								originrelative ? y+1 - yscrmin : y+1, x+1), buf);
	  							break;
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:555,561 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:545,550
	  					 * q - turn on list of LEDs; turn off others.
	  					 */
	  					case 'q':
	- //print("LED\n");
	  						break;
	  
	  					/*
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:564,570 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:553,558
	  					 * scrolling region.
	  					 */
	  					case 'r':
	- //print("scrolling region: n:%d %d %d\n", noperand, operand[1], operand[0]);
	  						yscrmin = 0;
	  						yscrmax = ymax;
	  						switch(noperand){
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:874,880 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:862,868
	  			}
	  			buf[n] = 0;
	  //			clear(Rpt(pt(x,y), pt(x+n, y+1)));
	- 			drawstring(pt(x, y), buf, attribute);
	+ 			drawstring(pt(x, y), buf, attr);
	  			x += n;
	  			peekc = c;
	  			break;
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:890,928 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:878,916
	  	for(i=0; i<argc; i++) {
	  		switch(argv[i]) {
	  		case 0:
	- 			attribute = attdefault;
	- 			frgcolor = frgdefault;
	- 			bckcolor = bckdefault;
	+ 			attr = defattr;
	+ 			fgcolor = fgdefault;
	+ 			bgcolor = bgdefault;
	  			break;
	  		case 1:
	- 			attribute |= THighIntensity;
	+ 			attr |= THighIntensity;
	  			break;		
	  		case 4:
	- 			attribute |= TUnderline;
	+ 			attr |= TUnderline;
	  			break;		
	  		case 5:
	- 			attribute |= TBlink;
	+ 			attr |= TBlink;
	  			break;
	  		case 7:
	- 			attribute |= TReverse;
	+ 			attr |= TReverse;
	  			break;
	  		case 8:
	- 			attribute |= TInvisible;
	+ 			attr |= TInvisible;
	  			break;
	  		case 22:
	- 			attribute &= ~THighIntensity;
	+ 			attr &= ~THighIntensity;
	  			break;		
	  		case 24:
	- 			attribute &= ~TUnderline;
	+ 			attr &= ~TUnderline;
	  			break;		
	  		case 25:
	- 			attribute &= ~TBlink;
	+ 			attr &= ~TBlink;
	  			break;
	  		case 27:
	- 			attribute &= ~TReverse;
	+ 			attr &= ~TReverse;
	  			break;
	  		case 28:
	- 			attribute &= ~TInvisible;
	+ 			attr &= ~TInvisible;
	  			break;
	  		case 30:	/* black */
	  		case 31:	/* red */
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:932,941 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:920,929
	  		case 35:	/* purple */
	  		case 36:	/* cyan */
	  		case 37:	/* white */
	- 			frgcolor = argv[i]-30;
	+ 			fgcolor = colors[argv[i]-30];
	  			break;
	  		case 39:
	- 			frgcolor = frgdefault;
	+ 			fgcolor = fgdefault;
	  			break;
	  		case 40:	/* black */
	  		case 41:	/* red */
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/vt/vt.c:945,954 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/vt/vt.c:933,942
	  		case 45:	/* purple */
	  		case 46:	/* cyan */
	  		case 47:	/* white */
	- 			bckcolor = argv[i]-40;
	+ 			bgcolor = colors[argv[i]-40];
	  			break;
	  		case 49:
	- 			bckcolor = bckdefault;
	+ 			bgcolor = bgdefault;
	  			break;
	  		}
	  	}
 [rsc] --rw-rw-r-- M 786594 glenda sys 14466 Dec  5 15:35 sys/src/cmd/vt/main.c

Better checking in itoa, also format as long-long, which it is.
 [jmk] --rw-rw-r-- M 786594 glenda sys 20958 Dec  5 12:07 sys/src/cmd/acid/builtin.c
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/acid/builtin.c:83,88 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/acid/builtin.c:83,90
	  	0
	  };
	  
	+ char vfmt[] = "aBbcCdDfFgGiIoOqQrRsSuUVWxXYZ";
	+ 
	  void
	  mkprint(Lsym *s)
	  {
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/acid/builtin.c:678,683 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/acid/builtin.c:680,731
	  	r->fmt = 'V';
	  }
	  
	+ static char *fmtflags = "-0123456789. #,u";
	+ static char *fmtverbs = "bdox";
	+ 
	+ static int
	+ acidfmt(char *fmt, char *buf, int blen)
	+ {
	+ 	char *r, *w, *e;
	+ 	
	+ 	w = buf;
	+ 	e = buf+blen;
	+ 	for(r=fmt; *r; r++){
	+ 		if(w >= e)
	+ 			return -1;
	+ 		if(*r != '%'){
	+ 			*w++ = *r;
	+ 			continue;
	+ 		}
	+ 		if(*r == '%'){
	+ 			*w++ = *r++;
	+ 			if(*r == '%'){
	+ 				if(w >= e)
	+ 					return -1;
	+ 				*w++ = *r;
	+ 				continue;
	+ 			}
	+ 			while(*r && strchr(fmtflags, *r)){
	+ 				if(w >= e)
	+ 					return -1;
	+ 				*w++ = *r++;
	+ 			}
	+ 			if(*r == 0 || strchr(fmtverbs, *r) == nil)
	+ 				return -1;
	+ 			if(w+3 > e)
	+ 				return -1;
	+ 			*w++ = 'l';
	+ 			*w++ = 'l';
	+ 			*w++ = *r;
	+ 		}
	+ 	}
	+ 	if(w >= e)
	+ 		return -1;
	+ 	*w = 0;
	+ 
	+ 	return 0;
	+ }
	+ 
	  void
	  cvtitoa(Node *r, Node *args)
	  {
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/acid/builtin.c:684,694 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/acid/builtin.c:732,742
	  	Node res;
	  	Node *av[Maxarg];
	  	vlong ival;
	- 	char buf[128], *fmt;
	+ 	char buf[128], fmt[32];
	  
	  	if(args == 0)
	  err:
	- 		error("itoa(number [, printformat]): arg count");
	+ 		error("itoa(number [, fmt]): arg count");
	  	na = 0;
	  	flatten(av, args);
	  	if(na == 0 || na > 2)
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/acid/builtin.c:695,708 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/acid/builtin.c:743,757
	  		goto err;
	  	expr(av[0], &res);
	  	if(res.type != TINT)
	- 		error("itoa(integer): arg type");
	+ 		error("itoa(number [, fmt]): arg type");
	  	ival = res.ival;
	- 	fmt = "%lld";
	+ 	strncpy(fmt, "%lld", sizeof(fmt));
	  	if(na == 2){
	  		expr(av[1], &res);
	  		if(res.type != TSTRING)
	- 			error("itoa(integer, string): arg type");
	- 		fmt = res.string->string;
	+ 			error("itoa(number [, fmt]): fmt type");
	+ 		if(acidfmt(res.string->string, fmt, sizeof(buf)))
	+ 			error("itoa(number [, fmt]): malformed fmt");
	  	}
	  
	  	snprint(buf, sizeof(buf), fmt, ival);
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/acid/builtin.c:895,902 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/acid/builtin.c:944,949
	  	r->ival = regexec(rp, res.string->string, 0, 0);
	  	free(rp);
	  }
	- 
	- char vfmt[] = "aBbcCdDfFgGiIoOqQrRsSuUVWxXYZ";
	  
	  void
	  fmt(Node *r, Node *args)

Rely on vt to supply geometry.
 [rsc] --rw-rw-r-- M 786594 glenda sys 7906 Dec  5 15:35 sys/src/cmd/ssh/cmsg.c
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/ssh/cmsg.c:252,303 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/ssh/cmsg.c:252,276
	  }
	  
	  /*
	-  * clumsy hack -- rather than open the font and fetch
	-  * the real character width and height, we assume that
	-  * LINES and COLS are initially correct and use them to 
	-  * derive cwidth, cheight.  this is definitely a mistake,
	-  * but i don't care.  if you do, fix it.
	+  * assumes that if you care, you're running under vt
	+  * and therefore these are set.
	   */
	  int
	  readgeom(int *nrow, int *ncol, int *width, int *height)
	  {
	- 	int ret;
	- 	static int first=1;
	  	static int fd = -1;
	- 	static int cwidth, cheight;
	  	char buf[64];
	- 	int n;
	  
	- 	ret = 0;
	- 	/* defaults */
	- 	*width = 640;
	- 	*height = 480;
	- 
	- 	if(fd < 0)
	- 		fd = open("/dev/wctl", OREAD);
	- 	if(fd >= 0){
	- 		n = read(fd, buf, sizeof(buf));
	- 		if(n < 48){
	- 			close(fd);
	- 			fd = -1;
	- 			ret = -1;
	- 			goto Out;
	- 		}
	- 	}
	- 	*width = atoi(&buf[2*12]) - atoi(&buf[0*12]);
	- 	*height = atoi(&buf[3*12]) - atoi(&buf[1*12]);
	- 
	- Out:
	- 	*nrow = intgetenv("LINES", 0);
	- 	*ncol = intgetenv("COLS", 0);
	- 	if(first){
	- 		first = 0;
	- 		if(*nrow)
	- 			cwidth = *width/(*nrow);
	- 		if(*ncol)
	- 			cheight = *height/(*ncol);
	- 	}
	- 	return ret;
	+ 	if(fd < 0 && (fd = open("/dev/wctl", OREAD)) < 0)
	+ 		return -1;
	+ 	/* wait for event, but don't care what it says */
	+ 	if(read(fd, buf, sizeof buf) < 0)
	+ 		return -1;
	+ 	*nrow = intgetenv("LINES", 24);
	+ 	*ncol = intgetenv("COLS", 80);
	+ 	*width = intgetenv("XPIXELS", 640);
	+ 	*height = intgetenv("YPIXELS", 480);
	+ 	return 0;
	  }
	  
	  void
 [rsc] --rw-rw-r-- M 786594 glenda sys 9671 Dec  5 17:20 sys/src/cmd/ssh/ssh.c
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/ssh/ssh.c:59,65 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/ssh/ssh.c:59,65
	  void
	  usage(void)
	  {
	- 	fprint(2, "usage: ssh [-CiImPpRrw] [-A authlist] [-c cipherlist] [user@]hostname [cmd [args]]\n");
	+ 	fprint(2, "usage: ssh [-CiImPpRr] [-A authlist] [-c cipherlist] [user@]hostname [cmd [args]]\n");
	  	exits("usage");
	  }
	  
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/ssh/ssh.c:78,83 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/ssh/ssh.c:78,85
	  	atexitkill(getpid());
	  
	  	dowinchange = 0;
	+ 	if(getenv("LINES"))
	+ 		dowinchange = 1;
	  	usepty = -1;
	  	user = nil;
	  	ARGBEGIN{
	/n/sourcesdump/2005/1205/plan9/sys/src/cmd/ssh/ssh.c:127,135 - 
	/n/sourcesdump/2005/1206/plan9/sys/src/cmd/ssh/ssh.c:129,134
	  		break;
	  	case 'r':
	  		crstrip = 1;
	- 		break;
	- 	case 'w':
	- 		dowinchange = 1;
	  		break;
	  	default:
	  		usage();
 [rsc] --rw-rw-r-- M 786594 glenda sys 9671 Dec  5 17:20 sys/src/cmd/ssh/ssh.c


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