Subject: MicroEMACS 3.9e standout bugs (fix)
From: [email-masked] (George M. Sipe)
Date: 25 Nov 87 20:39:39 GMT
Newsgroups: comp.emacs,comp.sources.bugs

The recently posted version of MicroEMACS (3.9e) does not include the
standout patches required for terminals with embedded attributes (which
require a display position for standout begin/end - e.g. most TVI, LSI,
Qume, etc. terminals and compatible).  If FIXSG is set (defined as set
when TERMCAP is set), then for terminal entries which have non-zero
'sg' attributes defined, the mode lines will be properly managed.

I have re-integrated the patch previously posted for releases 3.8i and
3.9l for the 3.9e release.  Hopefully, this patch will be in future
releases as promised by Daniel Lawrence, MicroEMACS author.  This is
now the third time I've posted this patch.  Please let me know if you
find it useful.

I have tested the patch on a variety of terminals without any
problems.  No problems were reported from the use of this patch in the
previous releases.  The patch in context diff format appears below.

George M. Sipe,		Phone: (404) 662-1533
Tolerant Systems, 6961 Peachtree Industrial, Norcross, GA  30071
UUCP: ...!{decvax,hplabs,ihnp4,linus,rutgers,seismo}!gatech!rebel!george

*** display.c_orig	Wed Nov 25 15:12:50 1987
--- display.c	Wed Nov 25 15:18:54 1987
***************
*** 623,628
  	register int nbflag;	/* non-blanks to the right flag? */
  	int rev;		/* reverse video flag */
  	int req;		/* reverse video request flag */

  	/* set up pointers to virtual and physical lines */

--- 623,631 -----
  	register int nbflag;	/* non-blanks to the right flag? */
  	int rev;		/* reverse video flag */
  	int req;		/* reverse video request flag */
+ #if	TERMCAP & FIXSG & REVSTA
+ 	int sook;		/* standout ok flag */
+ #endif

  	/* set up pointers to virtual and physical lines */
***************
*** 655,661
  
  		/* scan through the line and dump it to the screen and
  		   the virtual screen array				*/
! 		cp3 = &vp1->v_text[term.t_ncol];
  		while (cp1 < cp3) {
  			TTputc(*cp1);
  			++ttcol;

--- 658,672 -----
  
  		/* scan through the line and dump it to the screen and
  		   the virtual screen array				*/
! #if	TERMCAP & FIXSG & REVSTA
! 		if (req && SG > 0) {		/* Skip over 'spaces' */
! 		    ttcol += SG;
! 		    cp1 += SG;
! 		    cp2 += SG;
! 		    cp3 = &vp1->v_text[term.t_ncol-SG];
! 		} else
! #endif
! 			cp3 = &vp1->v_text[term.t_ncol];
  		while (cp1 < cp3) {
  			TTputc(*cp1);
  			++ttcol;
***************
*** 702,707
  	cp3 = &vp1->v_text[term.t_ncol];
  	cp4 = &vp2->v_text[term.t_ncol];
  
  	while (cp3[-1] == cp4[-1]) {
  		--cp3;
  		--cp4;

--- 713,725 -----
  	cp3 = &vp1->v_text[term.t_ncol];
  	cp4 = &vp2->v_text[term.t_ncol];
  
+ #if	TERMCAP & FIXSG & REVSTA
+ 	if (req && SG > 0)			/* Adjust for 'spaces' */
+ 	    sook = (cp1 - &vp1->v_text[0]) > 0;
+ 	else
+ 	    sook = FALSE;
+ #endif
+ 
  	while (cp3[-1] == cp4[-1]) {
  		--cp3;
  		--cp4;
***************
*** 722,727
  
  	movecursor(row, cp1 - &vp1->v_text[0]);	/* Go to start of line. */
  #if	REVSTA
  	TTrev(rev);
  #endif

--- 740,748 -----
  
  	movecursor(row, cp1 - &vp1->v_text[0]);	/* Go to start of line. */
  #if	REVSTA
+ #if	TERMCAP & FIXSG
+ 	if (!sook) TTrev(rev);
+ #else
  	TTrev(rev);
  #endif
  #endif
***************
*** 724,729
  #if	REVSTA
  	TTrev(rev);
  #endif
  
  	while (cp1 != cp5) {		/* Ordinary. */
  		TTputc(*cp1);

--- 745,751 -----
  #else
  	TTrev(rev);
  #endif
+ #endif
  
  	while (cp1 != cp5) {		/* Ordinary. */
  		TTputc(*cp1);
***************
*** 737,742
  			*cp2++ = *cp1++;
  	}
  #if	REVSTA
  	TTrev(FALSE);
  #endif
  	vp1->v_flag &= ~VFCHG;		/* flag this line as updated */

--- 759,767 -----
  			*cp2++ = *cp1++;
  	}
  #if	REVSTA
+ #if	TERMCAP & FIXSG
+ 	if (!sook) TTrev(FALSE);
+ #else
  	TTrev(FALSE);
  #endif
  #endif
***************
*** 739,744
  #if	REVSTA
  	TTrev(FALSE);
  #endif
  	vp1->v_flag &= ~VFCHG;		/* flag this line as updated */
  	return(TRUE);
  #endif

--- 764,770 -----
  #else
  	TTrev(FALSE);
  #endif
+ #endif
  	vp1->v_flag &= ~VFCHG;		/* flag this line as updated */
  	return(TRUE);
  #endif
***************
*** 829,834
      n += 8;
  #endif
  
      vtputc(lchar);
      vtputc(lchar);
      vtputc(' ');

--- 855,864 -----
      n += 8;
  #endif
  
+ #if	TERMCAP & FIXSG & REVSTA
+     if (revexist && SG > 0)			/* Initial spaces. */
+ 	for (i = 0; i < SG; ++i) vtputc(' ');
+ #endif
      vtputc(lchar);
      vtputc(lchar);
      vtputc(' ');
***************
*** 870,875
          ++n;
          }
  
      while (n < term.t_ncol)             /* Pad to full width. */
          {
          vtputc(lchar);

--- 900,909 -----
          ++n;
          }
  
+ #if	TERMCAP & FIXSG & REVSTA
+     if (revexist && SG > 0)		/* Adjust for standouts. */
+ 	n += SG * 3;
+ #endif
      while (n < term.t_ncol)             /* Pad to full width. */
          {
          vtputc(lchar);
***************
*** 875,880
          vtputc(lchar);
          ++n;
          }
  }
  
  upmode()	/* update all the mode lines */

--- 909,923 -----
          vtputc(lchar);
          ++n;
          }
+ #if	TERMCAP & FIXSG & REVSTA
+ /* The 'so' position will show as a reverse space, while the 'se'
+    position will be a normal space.  To balance the (visible)
+    reverse spaces at each end of the mode line, twice as many
+    spaces must exist at the end than do at the beginning.
+ */
+     if (revexist && SG > 0)		/* Trailing spaces. */
+ 	for (i = 0; i < SG * 2; ++i) vtputc(' ');
+ #endif
  }
  
  upmode()	/* update all the mode lines */
*** edef.h_orig	Wed Nov 25 15:12:52 1987
--- edef.h	Wed Nov 25 15:12:51 1987
***************
*** 125,130
  char	tap[NPAT];			/* Reversed pattern array.	*/
  char	rpat[NPAT];			/* replacement pattern		*/
  
  /* The variable matchlen holds the length of the matched
   * string - used by the replace functions.
   * The variable patmatch holds the string that satisfies

--- 125,134 -----
  char	tap[NPAT];			/* Reversed pattern array.	*/
  char	rpat[NPAT];			/* replacement pattern		*/
  
+ #if	FIXSG & REVSTA
+ int	SG;				/* number of standout glitches	*/
+ #endif
+ 
  /* The variable matchlen holds the length of the matched
   * string - used by the replace functions.
   * The variable patmatch holds the string that satisfies
***************
*** 263,268
  extern	char    pat[];                  /* Search pattern		*/
  extern	char	tap[];			/* Reversed pattern array.	*/
  extern	char	rpat[];			/* replacement pattern		*/
  
  extern unsigned int matchlen;
  extern unsigned int mlenold;

--- 267,276 -----
  extern	char    pat[];                  /* Search pattern		*/
  extern	char	tap[];			/* Reversed pattern array.	*/
  extern	char	rpat[];			/* replacement pattern		*/
+ 
+ #if	FIXSG & REVSTA
+ extern	int	SG;			/* number of standout glitches	*/
+ #endif
  
  extern unsigned int matchlen;
  extern unsigned int mlenold;
*** estruct.h_orig	Wed Nov 25 15:12:21 1987
--- estruct.h	Wed Nov 25 15:12:19 1987
***************
*** 74,79
  #define VT52    0                       /* VT52 terminal (Zenith).      */
  #define RAINBOW 0                       /* Use Rainbow fast video.      */
  #define TERMCAP 0                       /* Use TERMCAP                  */
  #define	IBMPC	1			/* IBM-PC CGA/MONO/EGA driver	*/
  #define	DG10	0			/* Data General system/10	*/
  #define	TIPC	0			/* TI Profesional PC driver	*/

--- 79,85 -----
  #define VT52    0                       /* VT52 terminal (Zenith).      */
  #define RAINBOW 0                       /* Use Rainbow fast video.      */
  #define TERMCAP 0                       /* Use TERMCAP                  */
+ #define	FIXSG	TERMCAP			/* Fix stand-out glitch		*/
  #define	IBMPC	1			/* IBM-PC CGA/MONO/EGA driver	*/
  #define	DG10	0			/* Data General system/10	*/
  #define	TIPC	0			/* TI Profesional PC driver	*/
*** tcap.c_orig	Wed Nov 25 15:12:54 1987
--- tcap.c	Wed Nov 25 15:12:53 1987
***************
*** 117,122
  	SO = tgetstr("so", &p);
  	if (SO != NULL)
  		revexist = TRUE;
  
          if(CL == NULL || CM == NULL || UP == NULL)
          {

--- 117,125 -----
  	SO = tgetstr("so", &p);
  	if (SO != NULL)
  		revexist = TRUE;
+ #if	FIXSG & REVSTA
+ 	SG = tgetnum("sg");	/* standout glitch 	*/
+ #endif
  
          if(CL == NULL || CM == NULL || UP == NULL)
          {
***************
*** 167,173
  int state;		/* FALSE = normal video, TRUE = reverse video */
  
  {
! 	static int revstate = FALSE;
  	if (state) {
  		if (SO != NULL)
  			putpad(SO);

--- 170,178 -----
  int state;		/* FALSE = normal video, TRUE = reverse video */
  
  {
! 	static int oldstate = TRUE + TRUE;
! 	if (state == oldstate) return;
! 	oldstate = state;
  	if (state) {
  		if (SO != NULL)
  			putpad(SO);
-- 
George M. Sipe,		Phone: (404) 662-1533
Tolerant Systems, 6961 Peachtree Industrial, Norcross, GA  30071
UUCP: ...!{decvax,hplabs,ihnp4,linus,rutgers,seismo}!gatech!rebel!george