[comp.windows.x] 7 Bit ASCII Support for Xterm

rauletta@gmuvax2.gmu.edu (R. J. Auletta) (06/09/90)

The following patch file adds a new resource to xterm so that
all characters displayed have the 8th stripped (masked to zero)
before the character is either interpreted as either a control
code or displayed.

This is useful for accessing systems that treat the 8th bit
as parity or otherwise set the 8th bit when generating 7 bit
ASCII codes. Generally useful with tip and other communication
packages that do not strip the 7th bit before passing the
received codes to the controlling process.

Interacts with the resource eightBitInput in that the 8 bit character
will be stripped and an extended character will not be displayed.
The new sevenBitOutput has a default of true. To have 8 bit characters
displayed you must set this to false in possibly your .xrdb file,

*VT100.sevenBitOutput:  false

The patch file updates the man page, ptyx.h, and charproc.c.
In fact it could be considered a compatiblity mode with the
X11R3 xterm which did not support 8 bit characters.

Comments and suggestions are always welcome.


--Rich Auletta
  rauletta@gmuvax2.gmu.edu

Warning: Application of this patch may make later official patches
fail.

*** xterm.man.bak	Wed Jun  6 18:54:37 1990
--- xterm.man	Wed Jun  6 19:06:08 1990
***************
*** 451,456
  Specifies whether or not eight-bit characters should be accepted.  The
  default is ``true.''
  .TP 8
  .B "font (\fPclass\fB Font)"
  Specifies the name of the normal font.  The default is ``vtsingle.''
  .TP 8

--- 451,462 -----
  Specifies whether or not eight-bit characters should be accepted.  The
  default is ``true.''
  .TP 8
+ .B "sevenBitOutput (\fPclass\fB SevenBitOutput\fP)"
+ Specifies that the 8th bit be ignored when interpreting control
+ codes and displaying characters. Character codes 0x80 to 0xff are
+ mapped to 0x00 to 0x7f. 
+ The default is ``true.''
+ .TP 8
  .B "font (\fPclass\fB Font)"
  Specifies the name of the normal font.  The default is ``vtsingle.''
  .TP 8
*** ptyx.h.bak	Wed Jun  6 18:51:10 1990
--- ptyx.h	Wed Jun  6 18:50:51 1990
***************
*** 341,346
  	Cardinal	sel_atoms_size;	/*  how many atoms allocated */
  	Cardinal	selection_count; /* how many atoms in use */
  	Boolean		eight_bits;	/* use 8th bit instead of ESC prefix */
  	Pixmap		menu_item_bitmap;	/* mask for checking items */
  	Widget		mainMenu, vtMenu, tekMenu, fontMenu;
  	char*		menu_font_names[NMENUFONTS];

--- 341,347 -----
  	Cardinal	sel_atoms_size;	/*  how many atoms allocated */
  	Cardinal	selection_count; /* how many atoms in use */
  	Boolean		eight_bits;	/* use 8th bit instead of ESC prefix */
+ 	Boolean		seven_bits; /* Ignore 8th bit in displayed characters */
  	Pixmap		menu_item_bitmap;	/* mask for checking items */
  	Widget		mainMenu, vtMenu, tekMenu, fontMenu;
  	char*		menu_font_names[NMENUFONTS];
*** charproc.bak.c	Thu Jun  7 21:20:52 1990
--- charproc.c	Thu Jun  7 21:08:29 1990
***************
*** 85,90
  #define XtNcutNewline		"cutNewline"
  #define XtNcutToBeginningOfLine	"cutToBeginningOfLine"
  #define XtNeightBitInput	"eightBitInput"
  #define XtNgeometry		"geometry"
  #define XtNtekGeometry		"tekGeometry"
  #define	XtNinternalBorder	"internalBorder"

--- 85,91 -----
  #define XtNcutNewline		"cutNewline"
  #define XtNcutToBeginningOfLine	"cutToBeginningOfLine"
  #define XtNeightBitInput	"eightBitInput"
+ #define XtNsevenBitOutput	"sevenBitOutput"
  #define XtNgeometry		"geometry"
  #define XtNtekGeometry		"tekGeometry"
  #define	XtNinternalBorder	"internalBorder"
***************
*** 122,127
  #define XtCCutNewline		"CutNewline"
  #define XtCCutToBeginningOfLine	"CutToBeginningOfLine"
  #define XtCEightBitInput	"EightBitInput"
  #define XtCGeometry		"Geometry"
  #define	XtCJumpScroll		"JumpScroll"
  #define	XtCLogfile		"Logfile"

--- 123,129 -----
  #define XtCCutNewline		"CutNewline"
  #define XtCCutToBeginningOfLine	"CutToBeginningOfLine"
  #define XtCEightBitInput	"EightBitInput"
+ #define XtCSevenBitOutput	"SevenBitOutput"
  #define XtCGeometry		"Geometry"
  #define	XtCJumpScroll		"JumpScroll"
  #define	XtCLogfile		"Logfile"
***************
*** 321,326
  {XtNcursorColor, XtCForeground, XtRPixel, sizeof(Pixel),
  	XtOffset(XtermWidget, screen.cursorcolor),
  	XtRString, "XtDefaultForeground"},
  {XtNeightBitInput, XtCEightBitInput, XtRBoolean, sizeof(Boolean),
  	XtOffset(XtermWidget, screen.eight_bits), 
  	XtRBoolean, (caddr_t) &defaultTRUE},

--- 323,331 -----
  {XtNcursorColor, XtCForeground, XtRPixel, sizeof(Pixel),
  	XtOffset(XtermWidget, screen.cursorcolor),
  	XtRString, "XtDefaultForeground"},
+ {XtNsevenBitOutput, XtCSevenBitOutput, XtRBoolean, sizeof(Boolean),
+ 	XtOffset(XtermWidget, screen.seven_bits), 
+ 	XtRBoolean, (caddr_t) &defaultTRUE},
  {XtNeightBitInput, XtCEightBitInput, XtRBoolean, sizeof(Boolean),
  	XtOffset(XtermWidget, screen.eight_bits), 
  	XtRBoolean, (caddr_t) &defaultTRUE},
***************
*** 484,490
  	if(setjmp(vtjmpbuf))
  		parsestate = groundtable;
  	for( ; ; ) {
! 	        switch (parsestate[c = doinput()]) {
  		 case CASE_PRINT:
  			/* printable characters */
  			top = bcnt > TEXT_BUF_SIZE ? TEXT_BUF_SIZE : bcnt;

--- 489,500 -----
  	if(setjmp(vtjmpbuf))
  		parsestate = groundtable;
  	for( ; ; ) {
! 
!         switch ( parsestate[
! 	/* Strip the 8th bit off all characters before parsing */
! 		c = screen->seven_bits ? 0x7f & doinput() : doinput()
! 			   ])
! 		{
  		 case CASE_PRINT:
  			/* printable characters */
  			top = bcnt > TEXT_BUF_SIZE ? TEXT_BUF_SIZE : bcnt;
***************
*** 491,496
  			cp = bptr;
  			*--bptr = c;
  			while(top > 0 && isprint(*cp & 0x7f)) {
  				top--;
  				bcnt--;
  				cp++;

--- 501,510 -----
  			cp = bptr;
  			*--bptr = c;
  			while(top > 0 && isprint(*cp & 0x7f)) {
+ 
+ 		/* Strip the 8th bit before displaying the character*/
+  				if(screen->seven_bits)
+ 					*cp &= 0x7f;
  				top--;
  				bcnt--;
  				cp++;
***************
*** 2030,2035
     new->screen.always_highlight = request->screen.always_highlight;
     new->screen.pointer_cursor = request->screen.pointer_cursor;
     new->screen.eight_bits = request->screen.eight_bits;
     new->screen.allowSendEvents = request->screen.allowSendEvents;
     new->misc.titeInhibit = request->misc.titeInhibit;
     for (i = 0; i < NMENUFONTS; i++) {

--- 2044,2050 -----
     new->screen.always_highlight = request->screen.always_highlight;
     new->screen.pointer_cursor = request->screen.pointer_cursor;
     new->screen.eight_bits = request->screen.eight_bits;
+    new->screen.seven_bits = request->screen.seven_bits;
     new->screen.allowSendEvents = request->screen.allowSendEvents;
     new->misc.titeInhibit = request->misc.titeInhibit;
     for (i = 0; i < NMENUFONTS; i++) {