*** /mit/release.73/source/bsd-4.3/common/sys/machineio.vax_bsd43/qv.c	Tue Sep  6 05:34:52 1988
--- machineio.vax_bsd43/qv.c	Thu Oct 24 19:17:51 1991
***************
*** 199,204 ****
--- 199,205 ----
  	int shift;			/* state variables	*/
  	int cntrl;
  	int lock;
+ 	int meta;
  	char last;			/* last character	*/
  } qv_keyboard;
  
***************
*** 545,552 ****
  		case CNTRL:
  			qv_keyboard.cntrl ^= 0xffff;
  			return;
  		case ALLUP:
! 			qv_keyboard.cntrl = qv_keyboard.shift = 0;
  			return;
  		case REPEAT:
  			c = qv_keyboard.last;
--- 546,556 ----
  		case CNTRL:
  			qv_keyboard.cntrl ^= 0xffff;
  			return;
+ 		case META:
+ 			qv_keyboard.meta  ^= 0xffff;
+ 			return;
  		case ALLUP:
! 			qv_keyboard.cntrl =  qv_keyboard.meta = qv_keyboard.shift = 0;
  			return;
  		case REPEAT:
  			c = qv_keyboard.last;
***************
*** 577,584 ****
  			string = q_special[ c & 0x7f ];
  			while( *string )
  			(*linesw[tp->t_line].l_rint)(*string++, tp);
! 		} else
  			(*linesw[tp->t_line].l_rint)(c, tp);
  	} else {
  		/*
  		 * Mouse channel is open put it into the event queue
--- 581,595 ----
  			string = q_special[ c & 0x7f ];
  			while( *string )
  			(*linesw[tp->t_line].l_rint)(*string++, tp);
! 		} else {
! 			if( qv_keyboard.meta )
! #ifdef META_8BIT
! 				c |= 0x80;
! #else
! 			(*linesw[tp->t_line].l_rint)(0x1b, tp);
! #endif
  			(*linesw[tp->t_line].l_rint)(c, tp);
+ 		}
  	} else {
  		/*
  		 * Mouse channel is open put it into the event queue
***************
*** 763,769 ****
  	ui = qvinfo[qv];
  	unit = qv<<2;
  	qvaddr = (struct qvdevice *)ui->ui_addr;
! 	tp0 = &qv_tty[(unit % 4 )+QVMOUSECHAN];
  	/*
  	 * See if the mouse has moved.
  	 */
--- 774,781 ----
  	ui = qvinfo[qv];
  	unit = qv<<2;
  	qvaddr = (struct qvdevice *)ui->ui_addr;
! /* orig	tp0 = &qv_tty[(unit % 4 )+QVMOUSECHAN]; */
! 	tp0 = &qv_tty[unit+QVMOUSECHAN];
  	/*
  	 * See if the mouse has moved.
  	 */
***************
*** 891,901 ****
--- 903,916 ----
  	unit &= 03;
  
  	s = spl5();
+ 
  	/*
  	 * If it's currently active, or delaying, no need to do anything.
  	 */
  	if (tp->t_state&(TS_TIMEOUT|TS_BUSY|TS_TTSTOP))
  		goto out;
+ 	
+ 
  	/*
  	 * Display chars until the queue is empty, if the second subchannel
  	 * is open direct them there. Drop characters from subchannels other
***************
*** 903,908 ****
--- 918,924 ----
  	 */
  
  	while( tp->t_outq.c_cc ) {
+ 
  		c = getc(&tp->t_outq);
  		if( (unit & 0x03)  == 0 )
  			if( tp0->t_state & TS_ISOPEN ){
***************
*** 965,970 ****
--- 981,994 ----
   * by a window manager.
   *
   */
+ 
+ /*
+  * Values for character attribute bit mask
+  */
+ #define CHAR_NONE      0
+ #define CHAR_REVERSE   1
+ #define CHAR_UNDERLINE 2
+ 
  qvputc( c )
  register char c;
  {
***************
*** 978,985 ****
      NORM = 0, ESC, ESCBRAK,
    } state = NORM;
    static int num_row=0, num_col=0, cur_num=0;
  	
- 
    /*
     * This routine may be called in physical mode by the dump code
     * so we check and punt if that's the case.
--- 1002,1009 ----
      NORM = 0, ESC, ESCBRAK,
    } state = NORM;
    static int num_row=0, num_col=0, cur_num=0;
+   static char_attr=0;
  
    /*
     * This routine may be called in physical mode by the dump code
     * so we check and punt if that's the case.
***************
*** 1053,1073 ****
  
  	/* inline expansion for speed */
  
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
! 	*b_row = *f_row++; b_row += ote;
  	/* the following is so that ansi marginning works... */
  	if( ++qp->col >=  qp->max_col ) {
  	  qp->col = 0 ;
--- 1077,1102 ----
  
  	/* inline expansion for speed */
  
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 	
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 	
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 	*b_row = (char_attr & CHAR_UNDERLINE)?((char_attr & CHAR_REVERSE)?0:0xff):
!                 ((char_attr & CHAR_REVERSE)?(*f_row ^ 0xff):(*f_row)); f_row++; b_row += ote;
! 	*b_row = (char_attr & CHAR_REVERSE)?(*f_row++ ^ 0xff):(*f_row++); b_row += ote;
! 			    
  	/* the following is so that ansi marginning works... */
  	if( ++qp->col >=  qp->max_col ) {
  	  qp->col = 0 ;
***************
*** 1155,1165 ****
--- 1184,1220 ----
        state = NORM;
        return(0);
        
+     case 'm':
+       /* \E[7m = reverse video
+        * \E[m  = disable modes
+        * \E[16m = bitrot characters
+        */
+       
+       switch(cur_num) {
+       case 0:
+ 	/* clear modes */
+ 	char_attr = CHAR_NONE;
+ 	break;
+       case 4:
+ 	/* set reverse video */
+ 	char_attr |= CHAR_UNDERLINE;
+ 	break;
+       case 7:
+ 	/* set reverse video */
+ 	char_attr |= CHAR_REVERSE;
+ 	break;
+       }
+ 
+       cur_num = 0;
+       state = NORM;
+       return(0);
+       
      default:
        state = NORM;
        return(0);
      }
      break;
+ 
    default:
      state = NORM;
      return(0);
