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

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


Make vt ever-better.
 [jmk] --rw-rw-r-- M 551037 glenda sys 1776 Dec  1 14:00 sys/src/cmd/vt/cons.h
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/cons.h:47,53 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/cons.h:47,53
	  	char	*sequence;
	  };
	  extern struct funckey *fk;
	- extern struct funckey vt100fk[], vt220fk[], ansifk[];
	+ extern struct funckey vt100fk[], vt220fk[], ansifk[], xtermfk[];
	  
	  extern int	x, y, xmax, ymax, olines;
	  extern int	peekc, attribute;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/cons.h:71,79 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/cons.h:71,84
	  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 cursoron;
	+ extern Font *fnt;
	+ extern int	wflag;
	  
	  extern void curson(int);
	  extern void cursoff(void);
 [jmk] --rw-rw-r-- M 551037 glenda sys 1245 Dec  1 14:00 sys/src/cmd/vt/event.c
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/event.c:7,12 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/event.c:7,13
	  #define	BUFSIZ	4000
	  
	  extern int	outfd;
	+ extern int	wctlout;
	  
	  int	hostpid;
	  
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/event.c:31,38 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/event.c:32,46
	  		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)
 [jmk] --rw-rw-r-- M 551037 glenda sys 3361 Dec  1 14:00 sys/src/cmd/vt/hp.c
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/hp.c:199,205 - 
	/n/sourcesdump/2005/1202/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), font, buf, DxorS);
	+ 			string(&screen, pt(x, y), fnt, buf, DxorS);
	  			if (standout)
	  				rectf(&screen,
	  				      Rpt(pt(x,y),pt(x+n,y+1)),
 [jmk] --rw-rw-r-- M 551037 glenda sys 16737 Dec  1 14:00 sys/src/cmd/vt/main.c
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/main.c:48,68 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:48,78
	  char	*histp;
	  char	hist[HISTSIZ];
	  int	yscrmin, yscrmax;
	- int	bckcolor, frgcolor;
	- int	attribute;
	+ int	bckcolor, frgcolor, bckdefault, frgdefault;
	+ int	attribute, attdefault;
	+ int	wctlout;
	+ int	wflag;
	  
	  Image	*bordercol;
	  Image	*cursback;
	  Image	*black;
	- Image	*white;
	  Image	*red;
	  Image	*green;
	  Image	*blue;
	  Image	*cyan;
	- Image	*magenta;
	- Image	*yellow;
	+ 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];
	  
	  /* terminal control */
	  struct ttystate ttystate[2] = { {0, 1}, {0, 1} };
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/main.c:75,80 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:85,91
	  int	outfd = -1;
	  Biobuf	*snarffp = 0;
	  
	+ Font	*fnt;
	  char	*host_buf;
	  char	*hostp;			/* input from host */
	  int	host_bsize = 2*BSIZE;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/main.c:122,127 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:133,139
	  {
	  	int dayglo = 1;
	  	char *p;
	+ 	char *fname = 0;
	  
	  	rfork(RFENVG|RFNAMEG|RFNOTEG);
	  
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/main.c:128,133 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:140,148
	  	term = "vt100";
	  	fk = vt100fk;
	  	ARGBEGIN{
	+ 	case 'f':
	+ 		fname = EARGF(useage());
	+ 		break;
	  	case 'a':
	  		term = "ansi";
	  		fk = ansifk;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/main.c:136,141 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:151,160
	  		term = "vt220";
	  		fk = vt220fk;
	  		break;
	+ 	case 'x':
	+ 		fk = xtermfk;
	+ 		term = "xterm";
	+ 		break;
	  	case 's': /* for sape */
	  		dayglo = 0;
	  		break;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/main.c:147,152 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:166,174
	  		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/1201/plan9/sys/src/cmd/vt/main.c:159,200 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:181,257
	  	}
	  	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 = font->height ;
	- 	CW = stringwidth(font, "m");
	+ 	NS = fnt->height;
	+ 	CW = stringwidth(fnt, "m");
	+ 
	  	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, DBlack);
	- 	white =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, DWhite);
	- 	red =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, DRed);
	- 	green =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, DGreen);
	- 	yellow =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, DYellow);
	- 	blue =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, DBlue);
	- 	magenta =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, DMagenta);
	- 	cyan =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, DCyan);
	- 	grey =  allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, DPalegreygreen);
	  
	- 	colortab[0] = black;
	- 	colortab[1] = red;
	- 	colortab[2] = green;
	- 	colortab[3] = yellow;
	- 	colortab[4] = blue;
	- 	colortab[5] = magenta;
	- 	colortab[6] = cyan;
	- 	colortab[7] = grey;
	+ 	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);
	  
	- 	if(dayglo) {
	- 		bckcolor = 0;
	- 		frgcolor = 7;
	+ 	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 {
	- 		bckcolor = 7;
	- 		frgcolor = 0;
	- 		colortab[7] = white;
	- 	}	
	+ 		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;
	+ 	}
	  
	  	eresized(0);
	  
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/main.c:229,236 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:286,292
	  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/1201/plan9/sys/src/cmd/vt/main.c:238,249 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:294,304
	  {
	  	Image *col;
	  
	- 	if(!cursoron){
	- 		cursoff();
	+ 	draw(cursback, cursback->r, screen, nil, pt(x, y));
	+ 
	+ 	if(!cursoron)
	  		return;
	- 	}
	  
	- 	draw(cursback, cursback->r, screen, nil, pt(x, y));
	  	if(bl)
	  		col = red;
	  	else
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/main.c:421,426 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:476,487
	  				case Kright:
	  					sendfk("right key");
	  					break;
	+ 				case Kpgup:
	+ 					sendfk("page up");
	+ 					break;
	+ 				case Kpgdown:
	+ 					sendfk("page down");
	+ 					break;
	  				case KF|1:
	  					sendfk("F1");
	  					break;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/main.c:540,545 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:601,608
	  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/1201/plan9/sys/src/cmd/vt/main.c:555,560 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:618,628
	  	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/1201/plan9/sys/src/cmd/vt/main.c:690,695 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:758,764
	  {
	  	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);
	  }
	  
	  void
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/main.c:709,714 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:778,784
	  	y -= half;
	  	if(olines)
	  		olines -= half;
	+ 	flushimage(display, 1);
	  }
	  
	  int
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/main.c:827,843 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/main.c:897,931
	  drawstring(Point p, char *str, int attribute)
	  {
	  	Image *txt, *bg;
	+ 	Rune *rstr;
	+ 	int i, n;
	  	
	  	if(!(attribute & TReverse)) {
	- 		txt = colortab[frgcolor];
	- 		bg = colortab[bckcolor];
	+ 		if(attribute & THighIntensity || bckcolor){
	+ 			txt = hicolortab[frgcolor];
	+ 			bg = colortab[bckcolor];
	+ 		}else{
	+ 			txt = colortab[frgcolor];
	+ 			bg = colortab[bckcolor];
	+ 		}
	  	} else {
	- 		txt = colortab[bckcolor];
	- 		bg = colortab[frgcolor];
	+ 		if(attribute & THighIntensity || bckcolor){
	+ 			txt = colortab[bckcolor];
	+ 			bg = colortab[frgcolor];
	+ 		}else{
	+ 			txt = colortab[bckcolor];
	+ 			bg = colortab[frgcolor];
	+ 		}
	  	}
	- 	if(attribute & THighIntensity)
	- 		txt = white;
	  
	- 	draw(screen, Rpt(p, addpt(p, stringsize(font, str))), bg, nil, p);
	- 	string(screen, p, txt, ZP, font, str);
	+ 	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);
	  }
 [jmk] --rw-rw-r-- M 551037 glenda sys 20180 Dec  1 14:00 sys/src/cmd/vt/vt.c
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:65,70 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:65,91
	  	{ "right key",		"\033[C", },
	  };
	  
	+ struct funckey xtermfk[NKEYS] = {
	+ 	{ "page up",	"\033[5~", },
	+ 	{ "page down",	"\033[6~", },
	+ 	{ "up key",		"\033[A", },
	+ 	{ "down key",		"\033[B", },
	+ 	{ "left key",		"\033[D", },
	+ 	{ "right key",		"\033[C", },
	+ 	{ "F1",			"\033[11~", },
	+ 	{ "F2",			"\033[12~", },
	+ 	{ "F3",			"\033[13~", },
	+ 	{ "F4",			"\033[14~", },
	+ 	{ "F5",			"\033[15~", },
	+ 	{ "F6",			"\033[17~", },
	+ 	{ "F7",			"\033[18~", },
	+ 	{ "F8",			"\033[19~", },
	+ 	{ "F9",			"\033[20~", },
	+ 	{ "F10",		"\033[21~", },
	+ 	{ "F11",		"\033[22~", },
	+ 	{ "F12",		"\033[23~", },
	+ };
	+ 
	  char gmap[256] = {
	  	['_']	' ',	/* blank */
	  	['\\']	'*',	/* diamond */
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:103,111 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:124,140
	  static void setattr(int argc, int *argv);
	  
	  void
	+ fixops(int *operand)
	+ {
	+ 	if(operand[0] < 1)
	+ 		operand[0] = 1;
	+ }
	+ 
	+ void
	  emulate(void)
	  {
	  	char buf[BUFS+1];
	+ 	int i;
	  	int n;
	  	int c;
	  	int operand[10];
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:113,118 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:142,148
	  	int savex, savey, saveattribute, saveisgraphics;
	  	int isgraphics;
	  	int g0set, g1set;
	+ 	int dch;
	  
	  	isgraphics = 0;
	  	g0set = 'B';	/* US ASCII */
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:166,172 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:196,202
	  		case '\013':
	  		case '\014':
	  			newline();
	- 			attribute = 0;
	+ 			//attribute = attdefault;
	  			if (ttystate[cs->raw].nlcr)
	  				x = 0;
	  			break;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:173,179 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:203,209
	  
	  		case '\015':		/* carriage return */
	  			x = 0;
	- 			attribute = 0;
	+ 			//attribute = attdefault;
	  			if (ttystate[cs->raw].crnl)
	  				newline();
	  			break;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:208,214 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:238,244
	  			break;
	  
	  		case '\033':
	- 			switch(get_next_char()){
	+ 			switch(dch = get_next_char()){
	  			/*
	  			 * 1 - graphic processor option on (no-op; not installed)
	  			 */
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:225,230 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:255,261
	  			 * 7 - save cursor position.
	  			 */
	  			case '7':
	+ //print("save\n");
	  				savex = x;
	  				savey = y;
	  				saveattribute = attribute;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:235,240 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:266,272
	  			 * 8 - restore cursor position.
	  			 */
	  			case '8':
	+ //print("restore\n");
	  				x = savex;
	  				y = savey;
	  				attribute = saveattribute;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:245,252 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:277,284
	  			 * c - Reset terminal.
	  			 */
	  			case 'c':
	+ print("resetterminal\n");
	  				cursoron = 1;
	- 				curson(0);
	  				ttystate[cs->raw].nlcr = 0;
	  				break;
	  
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:357,366 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:389,398
	  				 * A semi-colon or ? delimits arguments.
	  				 */
	  				memset(operand, 0, sizeof(operand));
	- 				operand[0] = number(buf, nil);
	+ 				operand[0] = number(buf, &i);
	  				noperand = 1;
	  				while(buf[0] == ';' || buf[0] == '?'){
	- 					if(noperand < nelem(operand)) {
	+ 					if(noperand < nelem(operand)){
	  						noperand++;
	  						operand[noperand-1] = number(buf, nil);
	  					} else
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:370,376 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:402,408
	  				/*
	  				 * do escape2 stuff
	  				 */
	- 				switch(buf[0]){
	+ 				switch(dch = buf[0]){
	  					/*
	  					 * c - same as ESC Z: what are you?
	  					 */
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:399,405 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:431,438
	  						if(noperand == 1){
	  							switch(operand[0]){	
	  							case 20:	/* set line feed mode */
	- 								ttystate[cs->raw].nlcr = 0;
	+ print("linefeedmode\n");
	+ 								ttystate[cs->raw].nlcr = 1;
	  								break;
	  							case 30:	/* screen invisible (? not supported through VT220) */
	  								break;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:418,424 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:451,457
	  							case 5:	/* set normal video on screen */
	  								break;
	  							case 6:	/* set origin to absolute */
	- print("OL\n");
	+ //print("OL\n");
	  								originrelative = 0;
	  								x = y = 0;
	  								break;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:431,437 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:464,469
	  								break;
	  							case 25:	/* text cursor off (VT220) */
	  								cursoron = 0;
	- 								cursoff();
	  								break;
	  							}
	  						}
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:438,451 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:470,493
	  						break;
	  
	  					/*
	+ 					* s - some dec private stuff. actually [ ? num s, but we can't detect it.
	+ 					*/
	+ 					case 's':
	+ 						break;
	+ 
	+ 					/*
	  					 * h - set various options.
	  					 */
	  					case 'h':
	  //print("h%d:%d,%d\n", noperand, operand[0], operand[1]);
	  						if(noperand == 1){
	- 							switch(operand[0]){	
	+ 							switch(operand[0]){
	+ 							default:
	+ //print("escape2 'h' unknown operand %d (n:%d)\n", operand[0], noperand-1);
	+ 								break;
	  							case 20:	/* set newline mode */
	- 								ttystate[cs->raw].nlcr = 1;
	+ print("newlinemode\n");
	+ 								ttystate[cs->raw].nlcr = 0;
	  								break;
	  							case 30:	/* screen visible (? not supported through VT220) */
	  								break;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:452,457 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:494,502
	  							}
	  						}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;
	  							case 2:	/* set ANSI */
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:458,469 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:503,515
	  								break;
	  							case 3:	/* set 132 columns */
	  								setdim(-1, 132);
	- 							break;
	+ 								break;
	  							case 4:	/* set smooth scrolling */
	  								break;
	  							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/1201/plan9/sys/src/cmd/vt/vt.c:477,483 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:523,528
	  								break;
	  							case 25:	/* text cursor on (VT220) */
	  								cursoron = 1;
	- 								curson(0);
	  								break;
	  							}
	  						}
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:499,504 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:544,550
	  							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/1201/plan9/sys/src/cmd/vt/vt.c:509,515 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:555,561
	  					 * q - turn on list of LEDs; turn off others.
	  					 */
	  					case 'q':
	- //						print("LED\n");
	+ //print("LED\n");
	  						break;
	  
	  					/*
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:518,523 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:564,570
	  					 * 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/1201/plan9/sys/src/cmd/vt/vt.c:550,558 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:597,605
	  					/*
	  					 * A - cursor up.
	  					 */
	+ 					case 'e':
	  					case 'A':
	- 						if(operand[0] == 0)
	- 							operand[0] = 1;
	+ 						fixops(operand);
	  						y -= operand[0];
	  						if(y < yscrmin)
	  							y = yscrmin;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:565,572 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:612,618
	  					 * B - cursor down
	  					 */
	  					case 'B':
	- 						if(operand[0] == 0)
	- 							operand[0] = 1;
	+ 						fixops(operand);
	  						y += operand[0];
	  						if(y > yscrmax)
	  							y=yscrmax;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:575,583 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:621,629
	  					/*
	  					 * C - cursor right
	  					 */
	+ 					case 'a':
	  					case 'C':
	- 						if(operand[0] == 0)
	- 							operand[0] = 1;
	+ 						fixops(operand);
	  						x += operand[0];
	  						/*
	  						 * VT-100-UG says not to go past the
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:584,590 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:630,636
	  						 * right margin.
	  						 */
	  						if(x > xmax)
	- 							x=xmax;
	+ 							x = xmax;
	  						break;
	  
	  					/*
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:591,598 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:637,643
	  					 * D - cursor left
	  					 */
	  					case 'D':
	- 						if(operand[0] == 0)
	- 							operand[0] = 1;
	+ 						fixops(operand);
	  						x -= operand[0];
	  						if(x < 0)
	  							x = 0;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:599,624 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:644,685
	  						break;
	  
	  					/*
	+ 					 *	G - cursor to column
	+ 					 */
	+ 					case '\'':
	+ 					case 'G':
	+ 						fixops(operand);
	+ 						x = operand[0] - 1;
	+ 						if(x > xmax)
	+ 							x = xmax;
	+ 						break;
	+ 
	+ 					/*
	  					 * H and f - cursor motion.  operand[0] is row and
	  					 * operand[1] is column, origin 1.
	  					 */
	  					case 'H':
	  					case 'f':
	+ 						fixops(operand+1);
	  						x = operand[1] - 1;
	- 						if(x < 0)
	- 							x = 0;
	  						if(x > xmax)
	  							x = xmax;
	+ 
	+ 						/* fallthrough */
	+ 
	+ 					/*
	+ 					 * d - cursor to line n (xterm)
	+ 					 */
	+ 					case 'd':
	+ 						fixops(operand);
	  						y = operand[0] - 1;
	- 						if(y < 0)
	- 							y = 0;
	  						if(originrelative){
	  							y += yscrmin;
	  							if(y > yscrmax)
	- 								y = ymax;
	- 						}else{
	- 							if(y > yscrmax)
	  								y = yscrmax;
	+ 						}else{
	+ 							if(y > ymax)
	+ 								y = ymax;
	  						}
	  						break;
	  
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:677,686 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:738,779
	  						break;
	  
	  					/*
	+ 					 *	P - delete character(s) from right of cursor (xterm)
	+ 					 */
	+ 					case 'P':
	+ 						fixops(operand);
	+ 						i = x + operand[0];
	+ 						draw(screen, Rpt(pt(x, y), pt(xmax+1, y+1)), screen, nil, pt(i, y));
	+ 						clear(Rpt(pt(xmax-operand[0], y), pt(xmax+1, y+1)));
	+ 						break;
	+ 
	+ 					/*
	+ 					 *	@ - insert blank(s) to right of cursor (xterm)
	+ 					 */
	+ 					case '@':
	+ 						fixops(operand);
	+ 						i = x + operand[0];
	+ 						draw(screen, Rpt(pt(i, y), pt(xmax+1, y+1)), screen, nil, pt(x, y));
	+ 						clear(Rpt(pt(x, y), pt(i, y+1)));
	+ 						break;
	+ 
	+ 
	+ 					/*
	+ 					 *	X - erase character(s) at cursor and to the right (xterm)
	+ 					 */
	+ 					case 'X':
	+ 						fixops(operand);
	+ 						i = x + operand[0];
	+ 						clear(Rpt(pt(x, y), pt(i, y+1)));
	+ 						break;
	+ 
	+ 					/*
	  					 * L - insert a line at cursor position (VT102 and later)
	  					 */
	  					case 'L':
	- 						scroll(y, yscrmax, y+1, y);
	+ 						fixops(operand);
	+ 						for(i = 0; i < operand[0]; ++i)
	+ 							scroll(y, yscrmax, y+1, y);
	  						break;
	  
	  					/*
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:687,695 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:780,805
	  					 * M - delete a line at cursor position (VT102 and later)
	  					 */
	  					case 'M':
	- 						scroll(y+1, yscrmax+1, y, yscrmax);
	+ 						fixops(operand);
	+ 						for(i = 0; i < operand[0]; ++i)
	+ 							scroll(y+1, yscrmax+1, y, yscrmax);
	  						break;
	  
	+ 					/*
	+ 					 * S,T - scroll up/down (xterm)
	+ 					 */
	+ 					case 'T':
	+ 						fixops(operand);
	+ 						for(i = 0; i < operand[0]; ++i)
	+ 							scroll(yscrmin, yscrmax, yscrmin+1, yscrmin);
	+ 						break;
	+ 
	+ 					case 'S':
	+ 						fixops(operand);
	+ 						for(i = 0; i < operand[0]; ++i)
	+ 							scroll(yscrmin+1, yscrmax+1, yscrmin, yscrmin);
	+ 						break;
	+ 
	  					case '=':	/* ? not supported through VT220 */
	  						number(buf, nil);
	  						switch(buf[0]) {
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:703,708 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:813,819
	  					 * Anything else we ignore for now...
	  					 */
	  					default:
	+ print("unknown escape2 '%c' (0x%x)\n", dch, dch);
	  						break;
	  				}
	  
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:715,724 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:826,851
	  				peekc = '\033';
	  				break;
	  
	+ 			/* set title */
	+ 			case ']':	/* it's actually <esc> ] num ; title <bel> */
	+ 				{
	+ 					int ch, fd;
	+ 					number(buf, nil);
	+ 					i = 0;
	+ 					while((ch = get_next_char()) != '\a')
	+ 						if(i < sizeof buf)
	+ 							buf[i++] = ch;
	+ 					fd = open("/dev/label", OWRITE);
	+ 					write(fd, buf, i);
	+ 					close(fd);
	+ 				}
	+ 				break;
	+ 
	  			/*
	  			 * Ignore other commands.
	  			 */
	  			default:
	+ print("unknown command '%c' (0x%x)\n", dch, dch);
	  				break;
	  
	  			}
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:763,769 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:890,898
	  	for(i=0; i<argc; i++) {
	  		switch(argv[i]) {
	  		case 0:
	- 			attribute = 0;
	+ 			attribute = attdefault;
	+ 			frgcolor = frgdefault;
	+ 			bckcolor = bckdefault;
	  			break;
	  		case 1:
	  			attribute |= THighIntensity;
	/n/sourcesdump/2005/1201/plan9/sys/src/cmd/vt/vt.c:795,819 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/cmd/vt/vt.c:924,954
	  		case 28:
	  			attribute &= ~TInvisible;
	  			break;
	- 		case 30:
	- 		case 31:
	- 		case 32:
	- 		case 33:
	- 		case 34:
	- 		case 35:
	- 		case 36:
	- 		case 37:
	+ 		case 30:	/* black */
	+ 		case 31:	/* red */
	+ 		case 32:	/* green */
	+ 		case 33:	/* brown */
	+ 		case 34:	/* blue */
	+ 		case 35:	/* purple */
	+ 		case 36:	/* cyan */
	+ 		case 37:	/* white */
	  			frgcolor = argv[i]-30;
	  			break;
	- 		case 40:
	- 		case 41:
	- 		case 42:
	- 		case 43:
	- 		case 44:
	- 		case 45:
	- 		case 46:
	- 		case 47:
	+ 		case 39:
	+ 			frgcolor = frgdefault;
	+ 			break;
	+ 		case 40:	/* black */
	+ 		case 41:	/* red */
	+ 		case 42:	/* green */
	+ 		case 43:	/* brown */
	+ 		case 44:	/* blue */
	+ 		case 45:	/* purple */
	+ 		case 46:	/* cyan */
	+ 		case 47:	/* white */
	  			bckcolor = argv[i]-40;
	+ 			break;
	+ 		case 49:
	+ 			bckcolor = bckdefault;
	  			break;
	  		}
	  	}

Don't error during initialization.
 [jmk] --rw-rw-r-- M 551037 glenda sys 23556 Dec  1 14:19 sys/src/9/pc/ether83815.c
	/n/sourcesdump/2005/1201/plan9/sys/src/9/pc/ether83815.c:594,606 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/9/pc/ether83815.c:594,609
	  	ctlr = ether->ctlr;
	  
	  	/*
	- 	 * Allocate and initialise the receive ring;
	- 	 * allocate and initialise the transmit ring;
	- 	 * unmask interrupts and start the transmit side
	+ 	 * Allocate suitable aligned descriptors
	+ 	 * for the transmit and receive rings;
	+ 	 * initialise the receive ring;
	+ 	 * initialise the transmit ring;
	+ 	 * unmask interrupts and start the transmit side.
	  	 */
	- 	ctlr->rdr = malloc(ctlr->nrdr*sizeof(Des));
	- 	if (ctlr->rdr == nil)
	- 		error(Enomem);
	+ 	des = xspanalloc((ctlr->nrdr+ctlr->ntdr)*sizeof(Des), 32, 0);
	+ 	ctlr->tdr = des;
	+ 	ctlr->rdr = des+ctlr->ntdr;
	+ 
	  	last = nil;
	  	for(des = ctlr->rdr; des < &ctlr->rdr[ctlr->nrdr]; des++){
	  		des->bp = iallocb(Rbsz);
	/n/sourcesdump/2005/1201/plan9/sys/src/9/pc/ether83815.c:616,622 - 
	/n/sourcesdump/2005/1202/plan9/sys/src/9/pc/ether83815.c:619,624
	  	ctlr->rdrx = 0;
	  	csr32w(ctlr, Rrxdp, PADDR(ctlr->rdr));
	  
	- 	ctlr->tdr = xspanalloc(ctlr->ntdr*sizeof(Des), 8*sizeof(ulong), 0);
	  	last = nil;
	  	for(des = ctlr->tdr; des < &ctlr->tdr[ctlr->ntdr]; des++){
	  		des->cmdsts = 0;


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