From atlka@pg.gda.pl Tue Nov 26 11:28:16 MET 1996
Article: 22 of gnu.bash.bug
x-gateway: relay3.UU.NET from bug-bash to gnu.bash.bug; Mon, 25 Nov 1996 09:03:36 EST
Path: knorke.saar.de!wg.saar.de!News.Saar.DE!news.coli.uni-sb.de!news-kar1.dfn.de!news-stu1.dfn.de!news.belwue.de!swidir.switch.ch!in2p3.fr!univ-lyon1.fr!jussieu.fr!esiee.fr!news.sgi.com!newsfeed.internetmci.com!uunet!in3.uu.net!wendy-fate.uu.net!atlka
From: atlka@cent01.oi.pg.gda.pl (Adam Tla/lka)
Subject: Re: Problem with setup of .inputrc file
Date: 25 Nov 1996 13:34:13 GMT
Organization: Politechnika Gdanska
Message-ID: <slrn59j83u.426.atlka@cent01.oi.pg.gda.pl>
References: <9611212115.AA02203.SM@odin.INS.CWRU.Edu>
Reply-To: atlka@pg.gda.pl
NNTP-Posting-Host: cent01.oi.pg.gda.pl
X-Newsreader: slrn (0.9.1.1 BETA UNIX)
Approved: bug-bash-request@prep.ai.mit.edu
Newsgroups: gnu.bash.bug
Sender: bug-bash-request@prep.ai.mit.edu
Lines: 205

> SunOS 4.1.4 termcap manual says that the following key sequences should
>be defined:
>
>kD	delete-character key
>kh	home key
>kH	home-down key (end)
>
>If they're not, you should be able to run
>
>	cat -v > /dev/null
>
>and see what prints on the screen when you press the keys.

	I can send a small patch to 1.14.7 to obtain automatic Home, End,
Backspace, Delete and ESC-Left, ESC-Right, ESC-Backspace, ESC-Delete key
seqences working without need to set .inputrc. Of course information in
termcap/terminfo should be proper.

Here it is:
______________________________________________________________________________
diff -rNu bash-1.14.7/.patchlevel bash-1.14.8/.patchlevel
--- bash-1.14.7/.patchlevel	Mon Aug 26 17:57:41 1996
+++ bash-1.14.8/.patchlevel	Tue Nov  5 18:58:21 1996
@@ -1 +1 @@
-7
+8
diff -rNu bash-1.14.7/cpp-Makefile bash-1.14.8/cpp-Makefile
--- bash-1.14.7/cpp-Makefile	Sun Jun 11 20:44:05 1995
+++ bash-1.14.8/cpp-Makefile	Tue Nov  5 18:00:07 1996
@@ -300,7 +300,9 @@
 /**/# The GNU coding standards don't recognize the possibility that
 /**/# other information besides optimization and debugging might be
 /**/# passed to cc.  A different name should have been used.
+#if !defined (CFLAGS)
 CFLAGS = -O -g
+#endif
 
 SYSTEM_FLAGS = $(LINEBUF) $(VPRINTF) $(UNISTD) $(STDLIB) $(LIMITSH) \
        $(GROUPS) $(RESOURCE) $(PARAM) $(SIGHANDLER) $(SYSDEP) $(WAITH) \
@@ -414,7 +416,9 @@
 /* Right now we assume that you have the full source code to Bash.  If
    you simply have the library and header files installed, then
    undefine HAVE_READLINE_SOURCE. */
+#ifndef DYNAMIC_READLINE
 #define HAVE_READLINE_SOURCE
+#endif
 
 #if defined (HAVE_READLINE_SOURCE)
 
@@ -547,7 +551,11 @@
 
 /* Guessed at symbol for LIBRARIES, below. */
 #  if defined (USE_TERMCAP_EMULATION)
+#  if defined (USE_NCURSES)
+TERMCAP_LIBRARY = -lncurses -lm
+# else
 TERMCAP_LIBRARY = -lcurses
+# endif
 #  else /* !USE_TERMCAP_EMULATION */
 TERMCAP_LIBRARY = -ltermcap
 #  endif /* !USE_TERMCAP_EMULATION */
diff -rNu bash-1.14.7/lib/readline/readline.c bash-1.14.8/lib/readline/readline.c
--- bash-1.14.7/lib/readline/readline.c	Wed May 24 16:43:28 1995
+++ bash-1.14.8/lib/readline/readline.c	Tue Nov  5 10:51:28 1996
@@ -21,7 +21,7 @@
    have a copy of the license, write to the Free Software Foundation,
    675 Mass Ave, Cambridge, MA 02139, USA. */
 #define READLINE_LIBRARY
-
+#include <locale.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <fcntl.h>
@@ -992,10 +992,9 @@
 
   /* Check for LC_CTYPE and use its value to decide the defaults for
      8-bit character input and output. */
-  t = getenv ("LC_CTYPE");
-  if (t && (strcmp (t, "iso-8859-1") == 0 || strcmp (t, "iso_8859_1") == 0 ||
-  	    strcmp (t, "ISO-8859-1") == 0))
-    {
+   if (((t = getenv ("LANG")) && (strcmp (t, "C"))) 
+		   || ((t = getenv ("LC_CTYPE")) && (strcmp (t, "C")))) {
+      setlocale(LC_CTYPE, "");
       _rl_meta_flag = 1;
       _rl_convert_meta_chars_to_ascii = 0;
       _rl_output_meta_chars = 1;
@@ -1045,6 +1044,8 @@
       _rl_bind_if_unbound ("\033[B", rl_get_next_history);
       _rl_bind_if_unbound ("\033[C", rl_forward);
       _rl_bind_if_unbound ("\033[D", rl_backward);
+      rl_set_key ("\033\033[D", rl_backward_word, _rl_keymap);
+      rl_set_key ("\033\033[C", rl_forward_word, _rl_keymap);
     }
 
   f = rl_function_of_keyseq ("\033OA", _rl_keymap, (int *)NULL);
@@ -1054,6 +1055,8 @@
       _rl_bind_if_unbound ("\033OB", rl_get_next_history);
       _rl_bind_if_unbound ("\033OC", rl_forward);
       _rl_bind_if_unbound ("\033OD", rl_backward);
+      rl_set_key ("\033\033OD", rl_backward_word, _rl_keymap);
+      rl_set_key ("\033\033OC", rl_forward_word, _rl_keymap);
     }
 }
 
@@ -1221,7 +1224,11 @@
 
 /* How to initialize and reset the arrow keys, if this terminal has any. */
 char *term_ks, *term_ke;
-
+/* some editing key sequences */
+char *term_kI, *term_kD, *term_kb,
+     *term_kN, *term_kP,
+     *term_kh, *term_a7;
+	  
 /* Re-initialize the terminal considering that the TERM/TERMCAP variable
    has changed. */
 rl_reset_terminal (terminal_name)
@@ -1314,11 +1321,18 @@
   "ei", &term_ei,
   "ic", &term_ic,
   "im", &term_im,
+  "kD", &term_kD,
+  "kI", &term_kI,
+  "kN", &term_kN,
+  "kP", &term_kP,
+  "kb", &term_kb,
   "kd", &term_kd,
+  "ke", &term_ke,
+  "kh", &term_kh,
   "kl", &term_kl,
   "kr", &term_kr,
-  "ku", &term_ku,
   "ks", &term_ks,
+  "ku", &term_ku,
   "ke", &term_ke,
   "le", &term_backspace,
   "mm", &term_mm,
@@ -1329,6 +1343,7 @@
   "pc", &term_pc,
   "up", &term_up,
   "vb", &visible_bell,
+  "@7", &term_a7,
 };
 
 #define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string))
@@ -1346,6 +1361,17 @@
   tcap_initialized = 1;
 }
 
+static char *esc_sequence(char *s)
+{
+       	char *p;
+	if (s && (p = xmalloc(strlen(s) + 2))) {
+		*p = '\033' ;
+		strcpy(p + 1, s);
+		return p;
+	} else
+		return (char *)0;
+} 
+
 static int
 init_terminal_io (terminal_name)
      char *terminal_name;
@@ -1450,10 +1476,19 @@
   xkeymap = _rl_keymap;
 
   _rl_keymap = emacs_standard_keymap;
+  rl_set_key (esc_sequence(term_kl), rl_backward_word, _rl_keymap);
+  rl_set_key (esc_sequence(term_kr), rl_forward_word, _rl_keymap);
+  rl_set_key (esc_sequence(term_kb), rl_backward_kill_word, _rl_keymap);
+  rl_set_key (esc_sequence(term_kD), rl_kill_word, _rl_keymap);
+
   _rl_bind_if_unbound (term_ku, rl_get_previous_history);
   _rl_bind_if_unbound (term_kd, rl_get_next_history);
   _rl_bind_if_unbound (term_kr, rl_forward);
   _rl_bind_if_unbound (term_kl, rl_backward);
+  _rl_bind_if_unbound (term_kh, rl_beg_of_line);
+  _rl_bind_if_unbound (term_a7, rl_end_of_line);
+  _rl_bind_if_unbound (term_kD, rl_delete);
+  _rl_bind_if_unbound (term_kb, rl_rubout);
 
 #if defined (VI_MODE)
   _rl_keymap = vi_movement_keymap;
diff -rNu bash-1.14.7/machines.h bash-1.14.8/machines.h
--- bash-1.14.7/machines.h	Mon Dec 18 20:13:22 1995
+++ bash-1.14.8/machines.h	Tue Nov  5 18:03:14 1996
@@ -895,6 +895,9 @@
 #    if defined (__GNUC__)
 #      define HAVE_FIXED_INCLUDES
 #    endif /* __GNUC__ */
+#    define USE_TERMCAP_EMULATION
+#    define USE_NCURSES
+/* #    define DYNAMIC_READLINE */
 #    undef USE_GNU_MALLOC
 #    undef HAVE_SETLINEBUF
 #    undef HAVE_GETWD

______________________________________________________________________________


-- 
 . .  Adam Tla/lka      mailto:atlka@pg.gda.pl    ^v^ ^v^ ^v^
  )   System  & Network Administration Group           ~~~~~~
  -  Computer Center,  Technical University of Gdansk, Poland


