[gnu.bash.bug] fixed bug with IC and im in termcap

pwolfe@kailand.kai.com (Patrick Wolfe) (12/04/89)

I fixed the bug in readline that I reported yesterday that caused command line
editing problems on terminals with both IC (or ic) and im defined in the
termcap entry.

Enclosed you will find a context diff of readline.c that fixes this problem.

The first difference is where one duplicate command is deleted.  The second is
in the "start_insert" subroutine.  If both "im" (enter insert mode) and "IC" or
"ic" (insert blank characters) were defined, insert mode was entered AND some
blank characters were inserted.  My fix adds an "else", so if you have insert
mode, use it, otherwise use insert blank characters.

        Patrick Wolfe
        System Manager, Kuck & Associates
	work: pwolfe@kailand.kai.com  or  uunet!kailand!pwolfe
	home: pat@pawnix.kai.com  or  uunet!kailand!pawnix!pat


===================================================================
RCS file: readline.c,v
retrieving revision 1.1
diff -c -r1.1 readline.c
*** /tmp/,RCSt1004592	Sun Dec  3 16:47:03 1989
--- readline.c	Sun Dec  3 11:11:54 1989
***************
*** 1833,1839 ****
    term_IC = tgetstr ("IC", &buffer);
    term_ic = tgetstr ("ic", &buffer);
    term_ip = tgetstr ("ip", &buffer);
-   term_IC = tgetstr ("IC", &buffer);
  
    /* "An application program can assume that the terminal can do
        character insertion if *any one of* the capabilities `IC',
--- 1833,1838 ----
***************
*** 1890,1910 ****
  start_insert (count)
       int count;
  {
!   if (term_im && *term_im)
      tputs (term_im, 1, output_character_function);
! 
!   if (term_IC && *term_IC &&
!       (count > 1 || !term_ic || !*term_ic))
!     {
!       char *tgoto (), *buffer;
!       buffer = tgoto (term_IC, 0, count);
!       tputs (buffer, 1, output_character_function);
!     }
!   else
!     {
!       if (term_ic && *term_ic)
! 	while (count--)
! 	  tputs (term_ic, 1, output_character_function);
      }
  }
  
--- 1889,1915 ----
  start_insert (count)
       int count;
  {
!   if (term_im && *term_im) /* if we have an insert mode, use it */
      tputs (term_im, 1, output_character_function);
!   else {
! 	/*
! 	 * else if we have a function to insert multiple characters at once,
! 	 * or there is no single character insert function
! 	 * use it to insert blanks (which will be overwritten later)
! 	 */
! 	  if (term_IC && *term_IC &&
! 	      (count > 1 || !term_ic || !*term_ic))
! 	    {
! 	      char *tgoto (), *buffer;
! 	      buffer = tgoto (term_IC, 0, count);
! 	      tputs (buffer, 1, output_character_function);
! 	    }
! 	  else
! 	    {	/* call single character insert function multiple times */
! 	      if (term_ic && *term_ic)
! 		while (count--)
! 		  tputs (term_ic, 1, output_character_function);
! 	    }
      }
  }
  



-- 

        Patrick Wolfe
        System Manager, Kuck & Associates
	work: pwolfe@kailand.kai.com  or  uunet!kailand!pwolfe
	home: pat@pawnix.kai.com  or  uunet!kailand!pawnix!pat

news@bbn.COM (News system owner ID) (12/08/89)

Actually, I think the correct order of prefrence is IC, then im/ei,
then ic, because on bitmapped terminals, it's *much* more efficient to
do one blit rather than N to open up the space, and on non-bitmapped
terminals, the cost is about the same either way.  It also seems to me
to be less distracting.

Scrolling regions vs. multiple line insert/delete is almost, but not
quite, the same sort of thing.

		-- Paul Placeway
		   (new address: <pplaceway@bbn.com>)