NetBSD Problem Report #1229

From gnats  Fri Jul 14 13:42:02 1995
Received: from pgoyette.bdt.com (root@pgoyette.bdt.com [204.182.11.88]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id NAA12410 for <gnats-bugs@gnats.netbsd.org>; Fri, 14 Jul 1995 13:41:57 -0400
Message-Id: <199507152124.OAA00280@pgoyette.bdt.com>
Date: Sat, 15 Jul 1995 14:24:34 -0700
From: paul@pgoyette.bdt.com
Reply-To: paul@pgoyette.bdt.com
To: gnats-bugs@gnats.netbsd.org
Subject: ite.c does not fully emulate vt100
X-Send-Pr-Version: 3.2

>Number:         1229
>Category:       port-mac68k
>Synopsis:       ite.c does not fully emulate vt100
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 14 13:50:02 +0000 1995
>Closed-Date:    Thu Sep 28 03:01:35 +0000 1995
>Last-Modified:  Thu Jul 24 18:26:53 +0000 1997
>Originator:     Paul Goyette
>Release:        NetBSD-current 7/14/95
>Organization:
--------------------------------------------------------------------
| Paul Goyette            | Key available via finger or key server |
| Paul@pgoyette.bdt.com   | Fingerprint: 0E 40 D2 FC 2A 13 74 A0   |
|                         |              E4 69 D5 BE 65 E4 56 C6   |
--------------------------------------------------------------------
>Environment:
Machine:  Mac IIci, 24MB RAM
		System:   NetBSD pgoyette.bdt.com 1.0A NetBSD 1.0A 
			  (PGOYETTE) #40: Sat Jul 15 14:06:29 PDT 1995 
			  paul@pgoyette.bdt.com:/usr/src/sys/arch/mac68k/compile/PGOYETTE mac68k

>Description:
	Certain "escape" commands which get generated by termcap
	utilities such as vi are not emulated in /sys/arch/mac68k/dev/ite.c.
	This results (in vi) in incorrect scrolling.
>How-To-Repeat:
	Using vi, edit a file longer than a full screen of text.  Use 
	the down-arrow key to move to the last displayed line, and then
	use the down-arrow again to move to the next (first non-displayed)
	line.  The new line is displayed on the bottom of the screen, but
	the previous text does not scroll up.  Similar problems occur at
	the top of the screen.
>Fix:
	Patch to /sys/arch/mac68k/dev/ite.c follows.  This patch implements
	the "Set Scroll Region" escape sequence (\E[<top>;<bottom>r) as well
	as the Set Tab Stop (\EH) and Clear All Tabs (\E[3g) sequences.

*** ite.c.orig	Mon Jul 10 00:05:08 1995
--- ite.c	Sat Jul 15 14:05:12 1995
***************
*** 124,129 ****
--- 124,133 ----
  void    itestart();
  static void ite_putchar(char ch);

+ /* VT100 tab stops & scroll region */
+ static char tab_stops[255];
+ static int  scrreg_top, scrreg_bottom;
+ 
  /*
   * Bitmap handling functions
   */
***************
*** 313,325 ****
  {
  	unsigned long *from, *to;
  	int     i, linelongs, tocopy, copying;
- 
  	linelongs = videorowbytes * CHARHEIGHT / 4;

! 	to = (unsigned long *) videoaddr;
  	from = to + linelongs;

! 	tocopy = (scrrows - 1) * linelongs;
  	while (tocopy > 0) {
  		copying = (tocopy > 16383) ? 16383 : tocopy;
  		bcopy(from, to, copying * 4);
--- 317,328 ----
  {
  	unsigned long *from, *to;
  	int     i, linelongs, tocopy, copying;
  	linelongs = videorowbytes * CHARHEIGHT / 4;

! 	to = (unsigned long *) videoaddr + ((scrreg_top-1) * linelongs);
  	from = to + linelongs;

! 	tocopy = (scrreg_bottom - scrreg_top) * linelongs;
  	while (tocopy > 0) {
  		copying = (tocopy > 16383) ? 16383 : tocopy;
  		bcopy(from, to, copying * 4);
***************
*** 328,334 ****
  		tocopy -= copying;
  	}
  	to = (unsigned long *) videoaddr;
! 	bzero(to + (scrrows - 1) * linelongs, linelongs * sizeof(long));
  }

  static void 
--- 331,337 ----
  		tocopy -= copying;
  	}
  	to = (unsigned long *) videoaddr;
! 	bzero(to + (scrreg_bottom - 1) * linelongs, linelongs * sizeof(long));
  }

  static void 
***************
*** 336,348 ****
  {
  	unsigned long *from, *to;
  	int     i, linelongs;
- 
  	linelongs = videorowbytes * CHARHEIGHT / 4;

! 	to = (unsigned long *) videoaddr + linelongs * scrrows;
  	from = to - linelongs;

! 	for (i = (scrrows - 1) * linelongs; i > 0; i--) {
  		*--to = *--from;
  	}
  	for (i = linelongs; i > 0; i--) {
--- 339,350 ----
  {
  	unsigned long *from, *to;
  	int     i, linelongs;
  	linelongs = videorowbytes * CHARHEIGHT / 4;

! 	to = (unsigned long *) videoaddr + linelongs * (scrreg_bottom);
  	from = to - linelongs;

! 	for (i = (scrreg_bottom - scrreg_top) * linelongs; i > 0; i--) {
  		*--to = *--from;
  	}
  	for (i = linelongs; i > 0; i--) {
***************
*** 406,417 ****
  		writechar(' ', i, y, ATTR_NONE);
  	}
  }

  static void 
  putc_normal(char ch)
  {
  	switch (ch) {
! 		case '\a':	/* Beep			 */
  		asc_ringbell();
  		break;
  	case 127:		/* Delete		 */
--- 408,437 ----
  		writechar(' ', i, y, ATTR_NONE);
  	}
  }
+ static void
+ reset_tabs(void)
+ {
+ 	int i;
+ 
+ 	for (i = 0; i<= scrcols; i++) {
+ 		tab_stops[i] = ((i % 8) == 0);
+ 	}
+ }
+ 
+ static void
+ vt100_reset(void)
+ {
+ 	reset_tabs;
+ 	scrreg_top    = 1;
+ 	scrreg_bottom = scrrows;
+ 	attr = ATTR_NONE;
+ }

  static void 
  putc_normal(char ch)
  {
  	switch (ch) {
! 	case '\a':		/* Beep			 */
  		asc_ringbell();
  		break;
  	case 127:		/* Delete		 */
***************
*** 426,438 ****
  	case '\t':		/* Tab			 */
  		do {
  			ite_putchar(' ');
! 		} while (x % 8 != 0);
  		break;
  	case '\n':		/* Line feed		 */
! 		y++;
! 		if (y >= scrrows) {
  			scrollup();
! 			y = scrrows - 1;
  		}
  		break;
  	case '\r':		/* Carriage return	 */
--- 446,458 ----
  	case '\t':		/* Tab			 */
  		do {
  			ite_putchar(' ');
! 		} while (tab_stops[x] = 0);
  		break;
  	case '\n':		/* Line feed		 */
! 		if (y == scrreg_bottom - 1) {
  			scrollup();
! 		} else {
! 			y++;
  		}
  		break;
  	case '\r':		/* Carriage return	 */
***************
*** 447,456 ****
  		if (ch >= ' ') {
  			if (hanging_cursor) {
  				x = 0;
! 				y++;
! 				if (y >= scrrows) {
  					scrollup();
! 					y = scrrows - 1;
  				}
  				hanging_cursor = 0;
  			}
--- 467,476 ----
  		if (ch >= ' ') {
  			if (hanging_cursor) {
  				x = 0;
! 				if (y == scrreg_bottom - 1) {
  					scrollup();
! 				} else {
! 					y++;
  				}
  				hanging_cursor = 0;
  			}
***************
*** 460,466 ****
  			} else {
  				x++;
  			}
! 			if (x >= scrcols) {
  				x = 0;
  				y++;
  			}
--- 480,486 ----
  			} else {
  				x++;
  			}
! 			if (x >= scrcols) {	/* can we ever get here? */
  				x = 0;
  				y++;
  			}
***************
*** 479,496 ****
  		vt100state = ESsquare;
  		break;
  	case 'D':		/* Line feed		 */
! 		y++;
  		break;
  	case 'H':		/* Set tab stop		 */
! 		/* Not supported */
  		break;
  	case 'M':		/* Cursor up		 */
! 		if (y == 0) {
  			scrolldown();
  		} else {
  			y--;
  		}
  		break;
  	case '7':		/* Save cursor		 */
  		savex = x;
  		savey = y;
--- 499,523 ----
  		vt100state = ESsquare;
  		break;
  	case 'D':		/* Line feed		 */
! 		if (y == scrreg_bottom - 1) {
! 			scrollup();
! 		} else {
! 			y++;
! 		}
  		break;
  	case 'H':		/* Set tab stop		 */
! 		tab_stops[x] = 1;
  		break;
  	case 'M':		/* Cursor up		 */
! 		if (y == scrreg_top - 1) {
  			scrolldown();
  		} else {
  			y--;
  		}
  		break;
+ 	case '>':
+ 		vt100_reset();
+ 		break;
  	case '7':		/* Save cursor		 */
  		savex = x;
  		savey = y;
***************
*** 513,522 ****
  	vt100state = ESnormal;
  	switch (ch) {
  	case 'A':		/* Up			 */
! 		y-= par[0] ? par[0] : 1;
  		break;
  	case 'B':		/* Down			 */
! 		y+= par[0] ? par[0] : 1;
  		break;
  	case 'C':		/* Right		 */
  		x+= par[0] ? par[0] : 1;
--- 540,565 ----
  	vt100state = ESnormal;
  	switch (ch) {
  	case 'A':		/* Up			 */
! 		i = par[0];
! 		do {
! 			if (y == scrreg_top - 1) {
! 				scrolldown();
! 			} else {
! 				y--;
! 			};
! 			i--;
! 		} while (i > 0);
  		break;
  	case 'B':		/* Down			 */
! 		i = par[0];
! 		do {
! 			if (y == scrreg_bottom - 1) {
! 				scrollup();
! 			} else {
! 				y++;
! 			};
! 			i--;
! 		} while (i > 0);
  		break;
  	case 'C':		/* Right		 */
  		x+= par[0] ? par[0] : 1;
***************
*** 536,542 ****
  		clear_line(par[0]);
  		break;
  	case 'g':		/* Clear tab stops	 */
! 		/* Not supported */
  		break;
  	case 'm':		/* Set attribute	 */
  		for (i = 0; i < numpars; i++) {
--- 579,587 ----
  		clear_line(par[0]);
  		break;
  	case 'g':		/* Clear tab stops	 */
! 		if (numpars >= 1 && par[0] == 3) {
! 			reset_tabs();
! 		}
  		break;
  	case 'm':		/* Set attribute	 */
  		for (i = 0; i < numpars; i++) {
***************
*** 557,563 ****
  		}
  		break;
  	case 'r':		/* Set scroll region	 */
! 		/* Not supported */
  		break;
  	}
  }
--- 602,618 ----
  		}
  		break;
  	case 'r':		/* Set scroll region	 */
! 		/* ensure top < bottom, and both within limits */
! 		if ((numpars > 0) && (par[0] < scrrows)) {
! 			scrreg_top = par[0];
! 		} else {
! 			scrreg_top = 1;
! 		}
! 		if ((numpars > 1) && (par[1] <= scrrows) && (par[1] > par[0])) {
! 			scrreg_bottom = par[1];
! 		} else {
! 			scrreg_bottom = scrrows;
! 		}
  		break;
  	}
  }
***************
*** 945,950 ****
--- 1000,1007 ----
  	height = (videosize >> 16) & 0xffff;
  	scrrows = height / CHARHEIGHT;
  	scrcols = width / CHARWIDTH;
+ 
+ 	vt100_reset();

  	switch (videobitdepth) {
  	default:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: briggs 
State-Changed-When: Wed Sep 27 23:01:35 EDT 1995 
State-Changed-Why:  
Patch checked and applied soon after submission (checked in on 7/17/95). 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.