screen->logstart = buffer;
screen->logstart = VTbuffer;
static void Tekparse(){	register TScreen *screen = &term->screen;	register int c, x, y;	char ch;	for( ; ; ) {	    c = input();	    switch(Tparsestate[c]) {		 case CASE_REPORT:			/* report address */			if(screen->TekGIN) {				TekGINoff();				TekEnqMouse(0);			} else {				c = 064;	/* has hard copy unit */				if(screen->margin == MARGIN2)					c |= 02;				TekEnq(c, screen->cur_X, screen->cur_Y);			}			TekRecord->ptr[-1] = NAK; /* remove from recording */			Tparsestate = curstate;			break;		 case CASE_VT_MODE:			/* special return to vt102 mode */			Tparsestate = curstate;			TekRecord->ptr[-1] = NAK; /* remove from recording */#ifdef ALLOWLOGGING			if(screen->logging) {				FlushLog(screen);				screen->logstart = buffer;			}#endif			return;		 case CASE_SPT_STATE:			/* Enter Special Point Plot mode */			if(screen->TekGIN)				TekGINoff();			Tparsestate = curstate = Tspttable;			break;		 case CASE_GIN:			/* Do Tek GIN mode */			screen->TekGIN = &TekRecord->ptr[-1];				/* Set cross-hair cursor raster array */			if ((GINcursor = 			    make_colored_cursor (XC_tcross, screen->mousecolor,						 screen->mousecolorback)) != 0)				XDefineCursor (screen->display, TShellWindow,					       GINcursor);			Tparsestate = Tbyptable;	/* Bypass mode */			break;		 case CASE_BEL:			/* BEL */			if(screen->TekGIN)				TekGINoff();			if(!TekRefresh)				Bell(XkbBI_TerminalBell,0);			Tparsestate = curstate;	/* clear bypass condition */			break;		 case CASE_BS:			/* BS */			if(screen->TekGIN)				TekGINoff();			Tparsestate = curstate;	/* clear bypass condition */			TCursorBack();			break;		 case CASE_PT_STATE:			/* Enter Tek Point Plot mode */			if(screen->TekGIN)				TekGINoff();			Tparsestate = curstate = Tpttable;			break;		 case CASE_PLT_STATE:			/* Enter Tek Plot mode */			if(screen->TekGIN)				TekGINoff();			Tparsestate = curstate = Tplttable;			if((c = input()) == BEL)				screen->pen = PENDOWN;			else {				unput(c);				screen->pen = PENUP;			}			break;		 case CASE_TAB:			/* HT */			if(screen->TekGIN)				TekGINoff();			Tparsestate = curstate;	/* clear bypass condition */			TCursorForward();			break;		 case CASE_IPL_STATE:			/* Enter Tek Incremental Plot mode */			if(screen->TekGIN)				TekGINoff();			Tparsestate = curstate = Tipltable;			break;		 case CASE_ALP_STATE:			/* Enter Tek Alpha mode from any other mode */			if(screen->TekGIN)				TekGINoff();			/* if in one of graphics states, move alpha cursor */			if(nplot > 0)	/* flush line Tbuffer */				TekFlush();			Tparsestate = curstate = Talptable;			break;		 case CASE_UP:			/* cursor up */			if(screen->TekGIN)				TekGINoff();			Tparsestate = curstate;	/* clear bypass condition */			TCursorUp();			break;		 case CASE_COPY:			/* make copy */			if(screen->TekGIN)				TekGINoff();			TekCopy();			TekRecord->ptr[-1] = NAK; /* remove from recording */			Tparsestate = curstate;	/* clear bypass condition */			break;		 case CASE_PAGE:			/* Page Function */			if(screen->TekGIN)				TekGINoff();			TekPage();	/* clear bypass condition */			break;		 case CASE_BES_STATE:			/* Byp: an escape char */			Tparsestate = Tbestable;			break;		 case CASE_BYP_STATE:			/* set bypass condition */			Tparsestate = Tbyptable;			break;		 case CASE_IGNORE:			/* Esc: totally ignore CR, ESC, LF, ~ */			break;		 case CASE_ASCII:			/* Select ASCII char set */			/* ignore for now */			Tparsestate = curstate;			break;		 case CASE_APL:			/* Select APL char set */			/* ignore for now */			Tparsestate = curstate;			break;		 case CASE_CHAR_SIZE: 			/* character size selector */		        TekSetFontSize (c & 03);			Tparsestate = curstate;			break;		 case CASE_BEAM_VEC:			/* beam and vector selector */			/* only line types */			if((c &= LINEMASK) != screen->cur.linetype) {				if(nplot > 0)				    TekFlush();				if (c <= TEKNUMLINES)				    screen->cur.linetype = c;			}			Tparsestate = curstate;			break;		 case CASE_CURSTATE:			Tparsestate = curstate;			break;		 case CASE_PENUP:			/* Ipl: penup */			screen->pen = PENUP;			break;		 case CASE_PENDOWN:			/* Ipl: pendown */			screen->pen = PENDOWN;			break;		 case CASE_IPL_POINT:			/* Ipl: point */			x = screen->cur_X;			y = screen->cur_Y;			if(c & NORTH)				y++;			else if(c & SOUTH)				y--;			if(c & EAST)				x++;			else if(c & WEST)				x--;			if(screen->pen == PENDOWN)				TekDraw(x, y);			else				TekMove(x, y);			break;		 case CASE_PLT_VEC:			/* Plt: vector */			unput(c);			if(getpoint()) {				if(screen->pen == PENDOWN)					TekDraw(screen->cur.x, screen->cur.y);				else					TekMove(screen->cur.x, screen->cur.y);				screen->pen = PENDOWN;			}			break;		 case CASE_PT_POINT:			/* Pt: point */			unput(c);			if(getpoint()) {				TekMove(screen->cur.x, screen->cur.y);				TekDraw(screen->cur.x, screen->cur.y);			}			break;		 case CASE_SPT_POINT:			/* Spt: point */			/* ignore intensity character in c */			if(getpoint()) {				TekMove(screen->cur.x, screen->cur.y);				TekDraw(screen->cur.x, screen->cur.y);			}			break;		 case CASE_CR:			/* CR */			if(screen->TekGIN)				TekGINoff();			if(nplot > 0)	/* flush line Tbuffer */				TekFlush();			screen->cur_X = screen->margin == MARGIN1 ? 0 :			 TEKWIDTH / 2;			Tparsestate = curstate = Talptable;			break;		 case CASE_ESC_STATE:			/* ESC */			Tparsestate = Tesctable;			break;		 case CASE_LF:			/* LF */			if(screen->TekGIN)				TekGINoff();			TCursorDown();			if (!TekRefresh)				do_xevents();			break;		 case CASE_SP:			/* SP */			TCursorForward();			break;		 case CASE_PRINT:			/* printable character */			ch = c;			c = screen->cur.fontsize;			XDrawString(			    screen->display,			    TWindow(screen), 			    screen->TnormalGC,			    (int)(screen->cur_X * TekScale(screen)) + screen->border,			    (int)((TEKHEIGHT + TEKTOPPAD - screen->cur_Y) * TekScale(screen)) + screen->border,			    &ch,			    1);			TCursorForward();			break;		 case CASE_OSC:			/* FIXME:  someone should disentangle the input queues			 * of this code so that it can be state-driven.			 */			/* do osc escape */			{				Char buf2[512];				int c2, len = 0;				while ((c2 = Tinput()) != BEL) {					if (!isprint(c2 & 0x7f)					 || len+2 >= (int) sizeof(buf2))						break;					buf2[len++] = c2;				}				if (c2 == BEL)					do_osc(buf2, len);			}			Tparsestate = curstate;			break;		}	}}			