Subject: HP Terminal support for PINE and PICO -- Patch Included

From: Daniel Simmons <[email-masked]>
Date: Tue, 16 Nov 1993 17:58:30 -0700

OK.  I finally got around to patching up pine and pico so that they will
work (mostly) with HP-type terminals.  There are two basic problems with
HP terminals:

1. Arrow keys -- The contributed patch supplied with the latest releases
   of pine helps here but didn't quite fix all my problems.

2. Use of reverse video -- HP terminals use "magic cookies" to mark
   where display enhancements (reverse, bold, underline, etc.) start
   and stop on a particular line.  They DO NOT work in a stream
   oriented mode like dec terminals (and the rest of the world).  This
   means that if you want a particular region of the screen to be in
   reverse, you must:

	- move to the target location (DO THIS FIRST)
	- turn on reverse video
	- write the stuff
	- turn off reverse video (do this BEFORE moving away)
	- move to next location

   Pine and pico were built on a very different set of assumptions
   about how terminals work.  (You can detect the mutant HP terminal
   stuff by looking for xs in termcap or xhp in terminfo.)

So, I jumped into the code and hacked things a bit.  The patch
included below will fix 90% of the problems.  Unfortunately, most of
the changes are MAJOR hacks.  The terminal library for pine
incorporates move to a location and print into one routine expecting
to turn reverse on and off from outside that routine.  My solution was
to add extra moves before turning reverse on and off.

The results:

	- Pine seems to work great from both HP and other terminals.
	- Other terminals will have two or three extra (useless) bytes
	  sent on occasion, but this seems relatively minor.
	- Pico occasionally screws up the highlighting of blocks (it
	  also has a rather annoying tendancy to loose the mark, but
	  I'm not so sure that I introduced this one).
	- Pico only highlights the first character during spell checks
	  instead of the whole word.
	- Standalone pico has a very slightly different "modified"
	  message displayed in the titlebar which hides a reverse
	  glitch.  (You wouldn't notice if I didn't tell you, but you
	  might wonder why in the world I modified that particular
	  message.)

Shameless plea to the wonderful maintainers of pine (was that
obsequious enough? :-):

  Is there any way we could work together to incorporate more general
  versions of these patches into the actual pine code so that they
  will be present in future releases?  The code in these patches could
  have been written much better, but that would have required
  restructuring your terminal i/o libs...  I just wanted to make the
  minimal changes to get it working (proof of concept?).

Enough of all that.  Here are the patches.  Use at your own risk.  Oh,
by the way, I #ifdef'd everything with the symbol HPTERM_SUPPORT.  So,
I also am including patches to makefile.hpp in the pine and pico
subdirectories which add -DHPTERM_SUPPORT to the C compiler flags.

For curiosity sake...  If you use these patches, would you please drop
me an email to let me know.  Thanks.

---------------- cut here -----------------

diff -c ../pine-3.87-clean/pico/composer.c pico/composer.c
*** ../pine-3.87-clean/pico/composer.c	Tue Nov 16 14:48:52 1993
--- pico/composer.c	Tue Nov 16 14:56:23 1993
***************
*** 1907,1913 ****
--- 1907,1919 ----
      movecursor(i, 0);
      if(state)
        (*term.t_rev)(1);
+ #ifndef HPTERM_SUPPORT
  
+ #else
+     else
+       (*term.t_rev)(0);
+     
+ #endif /* HPTERM_SUPPORT */
      while(bufp[1] != '\0')			/* putc upto last char */
        pputc(*bufp++, 1);
  
diff -c ../pine-3.87-clean/pico/display.c pico/display.c
*** ../pine-3.87-clean/pico/display.c	Tue Nov 16 14:48:52 1993
--- pico/display.c	Tue Nov 16 16:00:48 1993
***************
*** 992,998 ****
  #endif
  
  	if ((bp->b_flag&BFCHG) != 0)                /* "MOD" if changed. */
! 	  cp = "Modified  ";
  	else
  	  cp = "          ";
  
--- 992,998 ----
  #endif
  
  	if ((bp->b_flag&BFCHG) != 0)                /* "MOD" if changed. */
! 	  cp = "*Modified*";
  	else
  	  cp = "          ";
  
***************
*** 2151,2154 ****
  	wstripe(term.t_nrow-i,0,s,'~');
      }
  }
- 
--- 2151,2153 ----
diff -c ../pine-3.87-clean/pico/makefile.hpp pico/makefile.hpp
*** ../pine-3.87-clean/pico/makefile.hpp	Tue Nov 16 14:48:57 1993
--- pico/makefile.hpp	Tue Nov 16 15:35:51 1993
***************
*** 40,50 ****
  #
  
  #includes symbol info for debugging 
! DASHO=		-g
  #for normal build
! #DASHO=		-O
  
! CFLAGS=	-Dhpp -DPOSIX -DJOB_CONTROL
  
  # switches for library building
  LIBCMD=		ar
--- 40,50 ----
  #
  
  #includes symbol info for debugging 
! #DASHO=		-g
  #for normal build
! DASHO=		-O
  
! CFLAGS=	-Dhpp -DPOSIX -DJOB_CONTROL -DHPTERM_SUPPORT
  
  # switches for library building
  LIBCMD=		ar
***************
*** 90,93 ****
  
  clean:
  		rm -f *.a *.o *~ osdep.c osdep.h
- 
--- 90,92 ----
diff -c ../pine-3.87-clean/pico/spell.c pico/spell.c
*** ../pine-3.87-clean/pico/spell.c	Tue Nov 16 14:49:04 1993
--- pico/spell.c	Tue Nov 16 14:56:24 1993
***************
*** 163,168 ****
--- 163,171 ----
  
  	    curwp->w_flag |= WFMOVE;		/* put cursor back */
  	    update();
+ #ifdef HPTERM_SUPPORT
+ 	    (*term.t_rev)(0);
+ #endif /* HPTERM_SUPPORT */
  	    pputs(wb, 0);			/* un-highlight */
  
  	    switch(status){
diff -c ../pine-3.87-clean/pico/tcap.c pico/tcap.c
*** ../pine-3.87-clean/pico/tcap.c	Tue Nov 16 14:49:05 1993
--- pico/tcap.c	Tue Nov 16 16:00:17 1993
***************
*** 98,103 ****
--- 98,106 ----
  
  char *KU, *KD, *KL, *KR;
  char *KPPU, *KPPD, *KPHOME, *KPEND;
+ #ifdef HPTERM_SUPPORT
+ char *KS, *KE;			/* start and end keypad mode (HP terminals) */
+ #endif /* HPTERM_SUPPORT */
  
  struct KBSTREE *kpadseqs = NULL;
  
***************
*** 180,185 ****
--- 183,192 ----
      SR = tgetstr("sr", &p);
      TI = tgetstr("ti", &p);
      TE = tgetstr("te", &p);
+ #ifdef HPTERM_SUPPORT
+     KS = tgetstr("ks", &p);
+     KE = tgetstr("ke", &p);
+ #endif /* HPTERM_SUPPORT */
  
      eolexist = (CE != NULL);	/* will we be able to use clear to EOL? */
      revexist = (SO != NULL);
***************
*** 316,326 ****
--- 323,343 ----
  	if (CS != NULL)
  	  putpad(tgoto(CS, term.t_nrow, 0)) ;
      }
+ #ifdef HPTERM_SUPPORT
+     
+     if(KS)                              /* enter keypad transmit mode */
+       putpad(KS);
+ #endif /* HPTERM_SUPPORT */
  }

  tcapclose()
  {
+ #ifdef HPTERM_SUPPORT
+     if(KS && KE)                        /* get out of keypad transmit mode */
+       putpad(KE);
+       
+ #endif /* HPTERM_SUPPORT */
      if(!Pmaster){
  	if(gmode&MDFKEY)
  	  puts("\033[99l");		/* reset UW-NCSA telnet keys */
***************
*** 570,575 ****
--- 587,593 ----
  tcaprev(state)		/* change reverse video status */
  int state;	        /* FALSE = normal video, TRUE = reverse video */
  {
+ #ifndef HPTERM_SUPPORT
      static int cstate = FALSE;
  
      if(state == cstate)		/* no op if already set! */
***************
*** 576,581 ****
--- 594,601 ----
        return(0);
  
      if(cstate = state){		/* remember last setting */
+ #else
+     if(state == TRUE){
  	if (SO != NULL)
  	  putpad(SO);
      } 
***************
*** 583,588 ****
--- 603,609 ----
  	if (SE != NULL)
  	  putpad(SE);
      }
+ #endif /* HPTERM_SUPPORT */    
  }

diff -c ../pine-3.87-clean/pine/addrbook.c pine/addrbook.c
*** ../pine-3.87-clean/pine/addrbook.c	Tue Nov 16 14:47:47 1993
--- pine/addrbook.c	Tue Nov 16 14:56:26 1993
***************
*** 482,496 ****
--- 482,510 ----
      
          case Single:
              if(field == 0 || field == 1) {
+ #ifdef HPTERM_SUPPORT
+ 	        MoveCursor(line, 0);
+ #endif /* HPTERM_SUPPORT */
                  if(cursor == 1)
                    StartInverse();
+ #ifdef HPTERM_SUPPORT
+ 		else
+ 		  EndInverse();
+ #endif /* HPTERM_SUPPORT */
                  PutLine1(line, 0, col1_control, ab_disp->abe->nickname);
                  if(cursor == 1)
                    EndInverse();
              }
              if((field == 0 || field == 2) && col2_width != 0) {
+ #ifdef HPTERM_SUPPORT
+   	        MoveCursor(line, col1_width + 1);
+ #endif /* HPTERM_SUPPORT */
                  if(cursor == 2)
                    StartInverse();
+ #ifdef HPTERM_SUPPORT
+ 		else
+ 		  EndInverse();
+ #endif /* HPTERM_SUPPORT */
                  PutLine1(line, col1_width + 1, col2_control,
                                                       ab_disp->abe->fullname);
                  if(cursor == 2)
***************
*** 497,504 ****
--- 511,525 ----
                    EndInverse();
              }
              if((field == 0 || field == 3) && col3_width != 0) {
+ #ifdef HPTERM_SUPPORT
+ 	        MoveCursor(line, col3_pos);
+ #endif /* HPTERM_SUPPORT */
                  if(cursor == 3)
                    StartInverse();
+ #ifdef HPTERM_SUPPORT
+ 		else
+ 		  EndInverse();
+ #endif /* HPTERM_SUPPORT */
                  PutLine1(line, col3_pos, col3_control,ab_disp->abe->addr.addr);
                  if(cursor == 3)
                    EndInverse();
***************
*** 507,521 ****
--- 528,556 ----
      
          case ListHead:
              if(field == 0 || field == 1) {
+ #ifdef HPTERM_SUPPORT
+ 	        MoveCursor(line, 0);
+ #endif /* HPTERM_SUPPORT */
                  if(cursor == 1)
                    StartInverse();
+ #ifdef HPTERM_SUPPORT
+ 		else
+ 		  EndInverse();
+ #endif /* HPTERM_SUPPORT */
                  PutLine1(line, 0, col1_control, ab_disp->abe->nickname);
                  if(cursor == 1)
                    EndInverse();
              }
              if((field == 0 || field == 2) && col2_width != 0) {
+ #ifdef HPTERM_SUPPORT
+ 	        MoveCursor(line, col1_width+1);
+ #endif /* HPTERM_SUPPORT */
                  if(cursor == 2)
                    StartInverse();
+ #ifdef HPTERM_SUPPORT
+ 		else
+ 		  EndInverse();
+ #endif /* HPTERM_SUPPORT */
                  PutLine1(line, col1_width+ 1, col2_control,
                                                       ab_disp->abe->fullname);
                  if(cursor == 2)
***************
*** 536,543 ****
--- 571,585 ----
                    }
              }
              if(col3_width != 0) {
+ #ifdef HPTERM_SUPPORT
+ 	        MoveCursor(line, col3_pos);
+ #endif /* HPTERM_SUPPORT */
                  if(cursor != 0)
                    StartInverse();
+ #ifdef HPTERM_SUPPORT
+ 		else
+ 		  EndInverse();
+ #endif /* HPTERM_SUPPORT */
                  PutLine1(line, col3_pos, col3_control, ab_disp->addr_in_list);
                  if(cursor != 0)
                    EndInverse();
diff -c ../pine-3.87-clean/pine/folder.c pine/folder.c
*** ../pine-3.87-clean/pine/folder.c	Tue Nov 16 14:48:11 1993
--- pine/folder.c	Tue Nov 16 14:56:28 1993
***************
*** 755,760 ****
--- 755,764 ----
  	    for(tc = fs.context_list; tc ; tc = tc->next)
  	      free_folders_in_context(tc);
  
+ #ifdef HPTERM_SUPPORT
+ 	    ps->mangled_header = 1;
+ 	    
+ #endif /* HPTERM_SUPPORT */
  	    return(0);

***************
*** 1058,1065 ****
--- 1062,1076 ----
      if((f = folder_entry(index, context->folders))->name == NULL)
        return;
  
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(FIRST_DLINE + (f->d_line - fd->top_row), f->d_col);
+ #endif /* HPTERM_SUPPORT */
      if(hilite)
        StartInverse();
+ #ifdef HPTERM_SUPPORT
+     else
+       EndInverse();
+ #endif /* HPTERM_SUPPORT */
  
      if(context->type&FTYPE_BBOARD){
  	sprintf(tmp_20k_buf, "%s%s", f->prefix, 
diff -c ../pine-3.87-clean/pine/mailindx.c pine/mailindx.c
*** ../pine-3.87-clean/pine/mailindx.c	Tue Nov 16 14:47:37 1993
--- pine/mailindx.c	Tue Nov 16 14:56:30 1993
***************
*** 370,379 ****
--- 370,390 ----
  			(*build_header_line(state->current_sorted_msgno)=='+')
  			   ? (void *) '+': (void *) '-');
              } else {
+ #ifdef HPTERM_SUPPORT
+ 	        MoveCursor(2 + (int)(old_current_sorted_msgno - old_top_ent),
+ 			   0);
+ 		EndInverse();
+ #endif /* HPTERM_SUPPORT */
                  PutLine0(2 + (int)(old_current_sorted_msgno - old_top_ent),
                           0, build_header_line(old_current_sorted_msgno));
+ #ifdef HPTERM_SUPPORT
+ 		MoveCursor(2 + (int)(state->current_sorted_msgno - old_top_ent),
+ 			   0);
+ #endif /* HPTERM_SUPPORT */
                  StartInverse();
+ #ifndef HPTERM_SUPPORT
  
+ #endif /* HPTERM_SUPPORT */
                  PutLine0(2 + (int)(state->current_sorted_msgno - old_top_ent),
                           0,build_header_line(state->current_sorted_msgno));
                  EndInverse();
***************
*** 636,644 ****
--- 647,660 ----
      mail_fetchflags(stream, sequence);
      m = mail_elt(stream, (long)msgno);
      string = status_string(m);
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(2 + (int)screen_line, 2);
+ #endif /* HPTERM_SUPPORT */
      if(!ps_global->low_speed)
        StartInverse();
+ #ifndef HPTERM_SUPPORT
      MoveCursor(2 + (int)screen_line, 2);
+ #endif /* HPTERM_SUPPORT */
      Write_to_screen(string);
      if(!ps_global->low_speed)
        EndInverse();
diff -c ../pine-3.87-clean/pine/makefile.hpp pine/makefile.hpp
*** ../pine-3.87-clean/pine/makefile.hpp	Tue Nov 16 14:48:04 1993
--- pine/makefile.hpp	Tue Nov 16 15:26:08 1993
***************
*** 57,70 ****
  RM=          rm -f
  LN=          ln -s
  MAKE=        make
! OPTIMIZE=    # -O
  PROFILE=     # -pg
! DEBUG=       -g -DDEBUG
  
  LIBES=       -ltermcap -lnet 
  LOCLIBES=    ../pico/libpico.a ../c-client/c-client.a
  
! CFLAGS= -DHPP $(OPTIMIZE) $(PROFILE) $(DEBUG)
  
  obj=    addrbook.o addrutil.o adrbklib.o args.o context.o filter.o \
  	folder.o help.o helptext.o imap.o init.o mailcmd.o mailindx.o \
--- 57,70 ----
  RM=          rm -f
  LN=          ln -s
  MAKE=        make
! OPTIMIZE=    -O
  PROFILE=     # -pg
! DEBUG=       # -g -DDEBUG
  
  LIBES=       -ltermcap -lnet 
  LOCLIBES=    ../pico/libpico.a ../c-client/c-client.a
  
! CFLAGS= -DHPP -DHPTERM_SUPPORT $(OPTIMIZE) $(PROFILE) $(DEBUG)
  
  obj=    addrbook.o addrutil.o adrbklib.o args.o context.o filter.o \
  	folder.o help.o helptext.o imap.o init.o mailcmd.o mailindx.o \
diff -c ../pine-3.87-clean/pine/pine.c pine/pine.c
*** ../pine-3.87-clean/pine/pine.c	Tue Nov 16 14:48:02 1993
--- pine/pine.c	Tue Nov 16 14:56:32 1993
***************
*** 1183,1190 ****
--- 1183,1197 ----
          sprintf(buf, mkeys[dline-3].descrip,
                  use_fkeys ? "" : pretty_command(mkeys[dline-3].key));
          buf[ps_global->ttyo->screen_cols] = '\0';
+ #ifdef HPTERM_SUPPORT
+ 	MoveCursor(dline, 4);
+ #endif /* HPTERM_SUPPORT */
  	if(dline-3 == current_default_menu_item)
  	  StartInverse();
+ #ifdef HPTERM_SUPPORT
+ 	else
+ 	  EndInverse();
+ #endif /* HPTERM_SUPPORT */
          PutLine0(dline, 4, buf);
  	if(dline-3 == current_default_menu_item)
  	  EndInverse();
***************
*** 1441,1450 ****
--- 1448,1464 ----
      PutLine0(l++, 6,
       "latest UW version of NCSA telnet for either, and probably Kermit too.");
      PutLine0(l, 10, "Command:");
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(l, 19);
+ #endif /* HPTERM_SUPPORT */
      if(strcmp(ps_global->VAR_PRINTER, ANSI_PRINTER) == 0) {
          matched_printer = 1;
          StartInverse();
      }
+ #ifdef HPTERM_SUPPORT
+     else
+         EndInverse();
+ #endif /* HPTERM_SUPPORT */
      PutLine0(l++, 19, ANSI_PRINTER);
      if(strcmp(ps_global->VAR_PRINTER, ANSI_PRINTER) == 0)
        EndInverse();
***************
*** 1455,1465 ****
--- 1469,1486 ----
          "Using this option may require setting your \"PRINTER\" environment");
      PutLine0(l++, 6,    "variable using the standard UNIX utilities.");
      PutLine0(l, 10 , "Command: ");
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(l, 19);
+ #endif /* HPTERM_SUPPORT */
      if(ps_global->VAR_STANDARD_PRINTER != NULL &&
         strcmp(ps_global->VAR_PRINTER, ps_global->VAR_STANDARD_PRINTER) == 0) {
          matched_printer = 1;
          StartInverse();
      }
+ #ifdef HPTERM_SUPPORT
+     else
+         EndInverse();
+ #endif /* HPTERM_SUPPORT */
      PutLine0(l++, 19, ps_global->VAR_STANDARD_PRINTER != NULL ?
               ps_global->VAR_STANDARD_PRINTER : "");
      if(ps_global->VAR_STANDARD_PRINTER != NULL &&
***************
*** 1478,1485 ****
--- 1499,1513 ----
      PutLine0(l++, 6,
        "commands and options on your system may be different these examples.");
      PutLine0(l, 10,  "Command: ");
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(l, 19);
+ #endif /* HPTERM_SUPPORT */
      if(!matched_printer)  
        StartInverse();
+ #ifdef HPTERM_SUPPORT
+     else
+       EndInverse();
+ #endif /* HPTERM_SUPPORT */
      PutLine0(l, 19, ps_global->VAR_PERSONAL_PRINT_COMMAND == NULL ? "" :
                     ps_global->VAR_PERSONAL_PRINT_COMMAND);
      if(!matched_printer)
***************
*** 1506,1511 ****
--- 1534,1542 ----
  
      PutLine0(ps_global->ttyo->screen_rows - 4, 13,
  		 "PINE is a trademark of the University of Washington.");
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(ps_global->ttyo->screen_rows - 3, 0);
+ #endif /* HPTERM_SUPPORT */
      StartInverse();
      PutLine0(ps_global->ttyo->screen_rows - 3, 0,
  		 "Type any character to continue : ");
diff -c ../pine-3.87-clean/pine/screen.c pine/screen.c
*** ../pine-3.87-clean/pine/screen.c	Tue Nov 16 14:47:43 1993
--- pine/screen.c	Tue Nov 16 14:56:33 1993
***************
*** 635,640 ****
--- 635,643 ----
      }
      tb = format_titlebar();
      if(display_on_screen) {
+ #ifdef HPTERM_SUPPORT
+         MoveCursor(0, 0);
+ #endif /* HPTERM_SUPPORT */
          StartInverse();
          PutLine0(0, 0, tb);
          EndInverse();
***************
*** 646,651 ****
--- 649,657 ----
  void 
  redraw_titlebar()
  {
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(0,0);
+ #endif /* HPTERM_SUPPORT */
      StartInverse();
      PutLine0(0, 0, format_titlebar());
      EndInverse();
***************
*** 868,873 ****
--- 874,882 ----
      l_change = strlen(s_new) - strlen(s_old);

+ #ifdef HPTERM_SUPPORT
+     MoveCursor(0, as.cur_mess_col);
+ #endif /* HPTERM_SUPPORT */
      StartInverse();
      if(l_change == 0) {
          PutLine0(0, as.cur_mess_col, s_new);
***************
*** 894,899 ****
--- 903,911 ----
              }
          }
      }
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(1, 0);
+ #endif /* HPTERM_SUPPORT */
      EndInverse();
      fflush(stdout);
      as.current_message = new_message_number;
***************
*** 926,933 ****
--- 938,951 ----
     if(old_percent == new_percent)
       return;
  
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(0, as.percent_column);
+ #endif /* HPTERM_SUPPORT */
      StartInverse();
      PutLine1(0, as.percent_column, "%3d", (void *)new_percent);
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(1, 0);
+ #endif /* HPTERM_SUPPORT */
      EndInverse();
      fflush(stdout);
  }
***************
*** 952,957 ****
--- 970,978 ----
  
      as.current_page = new_page;
  
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(0, as.page_column);
+ #endif /* HPTERM_SUPPORT */
      StartInverse();
      if(NUM_LEN(new_page) != NUM_LEN(as.current_page))  {
          PutLine1(0, as.page_column, "%s", int2string(new_page));
***************
*** 962,967 ****
--- 983,991 ----
          PutLine2(0,as.page_column,
                   "%s of %s   ",tmp,int2string(as.total_pages));
      }
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(1, 0);
+ #endif /* HPTERM_SUPPORT */
      EndInverse();
      fflush(stdout);
  }
***************
*** 992,999 ****
--- 1016,1029 ----
  				 : mc->answered ? MS_ANS
  				   : (!mc->seen) ? MS_NEW : 0;
  
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(0, as.del_column);
+ #endif /* HPTERM_SUPPORT */
      StartInverse();
      PutLine0(0, as.del_column, BAR_STATUS(as.msg_state));
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(1, 0);
+ #endif /* HPTERM_SUPPORT */
      EndInverse();
      fflush(stdout);
      return(1);
diff -c ../pine-3.87-clean/pine/status.c pine/status.c
*** ../pine-3.87-clean/pine/status.c	Tue Nov 16 14:47:39 1993
--- pine/status.c	Tue Nov 16 14:56:34 1993
***************
*** 467,472 ****
--- 467,479 ----
  
      col = Centerline(row, obuff);
      EndInverse();
+ #ifdef HPTERM_SUPPORT
+ /* Deal with magic cookie (HP) terminals)... */
+     MoveCursor(row, col);
+     StartInverse();
+     MoveCursor(row, 0);
+     EndInverse();
+ #endif /* HPTERM_SUPPORT */
      fflush(stdout);
      return(col);
  }
***************
*** 711,716 ****
--- 718,726 ----
  {
      int x;
  
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(l, c);
+ #endif /* HPTERM_SUPPORT */
      StartInverse();
      PutLine0(l, c, q);
      x = c + strlen(q);
diff -c ../pine-3.87-clean/pine/ttyin.c pine/ttyin.c
*** ../pine-3.87-clean/pine/ttyin.c	Tue Nov 16 14:47:34 1993
--- pine/ttyin.c	Tue Nov 16 14:56:36 1993
***************
*** 1276,1283 ****
--- 1276,1285 ----
      }

+ #ifndef HPTERM_SUPPORT
      StartInverse();  /* Always in inverse  */
  
+ #endif /* HPTERM_SUPPORT */
      /*
       * if display length isn't wide enough to support input,
       * shorten up the prompt...
***************
*** 1296,1301 ****
--- 1298,1308 ----
      dline.vlen  = --field_len;		/* -1 for terminating NULL */
      dline.vbase = field_pos = 0;
  
+ #ifdef HPTERM_SUPPORT
+     MoveCursor(real_y_base, x_base);
+     StartInverse();  /* Always in inverse  */
+ 
+ #endif /* HPTERM_SUPPORT */
      PutLine0(real_y_base, x_base, prompt);
      /* make sure passed in string is shorter than field_len */
      /* and adjust field_pos..                               */
***************
*** 1491,1496 ****
--- 1498,1506 ----
                (*ps_global->redrawer)();
              redraw_keymenu();
  
+ #ifdef HPTERM_SUPPORT
+ 	    MoveCursor(real_y_base, x_base);
+ #endif /* HPTERM_SUPPORT */
              StartInverse();
              
              PutLine0(real_y_base, x_base, prompt);
***************
*** 1568,1575 ****
--- 1578,1590 ----
        fs_give((void **)&kill_buffer);
  
      removing_trailing_white_space(string);
+ #ifndef HPTERM_SUPPORT
      EndInverse();
+ #endif /* HPTERM_SUPPORT */
      MoveCursor(real_y_base, x_base); /* Move the cursor to show we're done */
+ #ifdef HPTERM_SUPPORT
+     EndInverse();
+ #endif /* HPTERM_SUPPORT */
      fflush(stdout);
      return(return_v);
  }
***************
*** 1602,1607 ****
--- 1617,1625 ----
  	  *passwd == 2;		/* only blat once */
  
  	extra = 0;
+ #ifdef HPTERM_SUPPORT
+ 	StartInverse();
+ #endif /* HPTERM_SUPPORT */
  	MoveCursor(dline.row, dline.col);
  	while(extra++ < dline.dlen)
  	  Writechar(' ', 0);
***************
*** 1677,1682 ****
--- 1695,1703 ----
  
      if(pfp != pbp || *pfp != *vfp){			/* anything to paint? */
  	MoveCursor(dline.row, dline.col + (int)(pfp - dline.dl));
+ #ifdef HPTERM_SUPPORT
+ 	StartInverse();
+ #endif /* HPTERM_SUPPORT */
  
  	while(pfp <= pbp){
  	    if(vfp <= vbp && *vfp)
diff -c ../pine-3.87-clean/pine/ttyout.c pine/ttyout.c
*** ../pine-3.87-clean/pine/ttyout.c	Tue Nov 16 14:47:38 1993
--- pine/ttyout.c	Tue Nov 16 15:17:49 1993
***************
*** 130,136 ****
--- 130,141 ----
              *_startinsert, *_endinsert, *_insertchar, *_deletechar,
              *_deleteline, *_insertline,
              *_scrollregion, *_scrollup, *_scrolldown,
+ #ifndef HPTERM_SUPPORT
              *_termcap_init, *_termcap_end;
+ #else
+             *_termcap_init, *_termcap_end,
+             *_keypad_start, *_keypad_end;
+ #endif /* HPTERM_SUPPORT */
  static int   _lines, _columns;
  char  termname[40];
  #ifndef USE_TERMINFO
***************
*** 268,273 ****
--- 273,282 ----
      _scrollup          = tgetstr("sr", &ptr);
      _termcap_init      = tgetstr("ti", &ptr);
      _termcap_end       = tgetstr("te", &ptr);
+ #ifdef HPTERM_SUPPORT
+     _keypad_start      = tgetstr("ks", &ptr);
+     _keypad_end        = tgetstr("ke", &ptr);
+ #endif /* HPTERM_SUPPORT */
      _lines	       = tgetnum("li");
      _columns	       = tgetnum("co");
  #endif
***************
*** 338,345 ****
--- 347,362 ----
  {
      if(_termcap_init != NULL) {
          tputs(_termcap_init, 1, outchar);
+ #ifndef HPTERM_SUPPORT
  	fflush(stdout);
+ #endif /* HPTERM_SUPPORT */
      }
+ #ifdef HPTERM_SUPPORT
+     if(_keypad_start != NULL) {
+     	tputs(_keypad_start, 1, outchar);
+     }
+     fflush(stdout);
+ #endif /* HPTERM_SUPPORT */
  }

***************
*** 405,410 ****
--- 422,431 ----
      EndInverse();
      MoveCursor( _lines - 1, 0);
      NewLine();
+ #ifdef HPTERM_SUPPORT
+     if(_keypad_end != NULL)
+       tputs(_keypad_end, 1, outchar);
+ #endif /* HPTERM_SUPPORT */
      if(_termcap_end != NULL)
        tputs(_termcap_end, 1, outchar);
      fflush(stdout);

--------
Daniel Simmons          electronic mail : [email-masked]
Idaho State University       voice mail : (208) 236-3199
Computer Center              snail mail : Box 8037, Pocatello