🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #10167

Patches to readline VI mode

#10167
From: USENET News System.
Date: Mon, 02 Apr 1990 17:50
142 lines
4052 bytes
Sender: 
Reply-To: pesrem@tumuc.UUCP (Peter Schauer)
Followup-To: 
Distribution: gnu
Organization: Technical University of Munich, West-Germany
Keywords: 
From: pes@tumuc.e-technik.tu-muenchen.dbp.de (Peter Schauer)
Path: tumuc!pes

No flames for using VI mode please, the following patches make readline
behave more like the "true" vi and allow function keys with ESC codes
as key macros. Please could you take care that the bash and gdb readlines
are kept in sync ?

Peter Schauer		 pes@tumuc.e-technik.tu-muenchen.dbp.de

*** ./readline/readline.c.orig	Tue Feb 27 10:19:35 1990
--- ./readline/readline.c	Fri Mar 23 17:46:42 1990
***************
*** 2700,2709 ****
        return;
      }
  
    if (count > 1)
      {
        int orig_point = rl_point;
!       rl_forward (count);
        rl_kill_text (orig_point, rl_point);
        rl_point = orig_point;
      }
--- 2700,2717 ----
        return;
      }
  
+ #ifdef VI_MODE
+   if ((count > 1) || ((count == 1) && (rl_editing_mode == vi_mode)))
+ #else
    if (count > 1)
+ #endif
      {
        int orig_point = rl_point;
!       while (count && (rl_point < rl_end))
! 	{
! 	rl_point++;
! 	count--;
! 	}
        rl_kill_text (orig_point, rl_point);
        rl_point = orig_point;
      }
***************
*** 4814,4819 ****
--- 4822,4828 ----
    char *keys;
    int keys_len;
    register int i;
+   int start;
  
    /* If no keys to bind to, exit right away. */
    if (!keyseq || !*keyseq)
***************
*** 4831,4838 ****
    if (rl_translate_keyseq (keyseq, keys, &keys_len))
      return;
  
    /* Bind keys, making new keymaps as necessary. */
!   for (i = 0; i < keys_len; i++)
      {
        if (i + 1 < keys_len)
  	{
--- 4840,4864 ----
    if (rl_translate_keyseq (keyseq, keys, &keys_len))
      return;
  
+   /* Handle mapping of the ESC Key in vi mode */
+   start = 0;
+ #ifdef VI_MODE
+   if ((rl_editing_mode == vi_mode) && (keys[0] == ESC))
+     {
+     start++;
+     map = vi_movement_keymap;
+     if(keys[1] == ESC)
+       {
+       extern KEYMAP_ENTRY_ARRAY vi_escape_keymap;
+ 
+       start++;
+       map = vi_escape_keymap;
+       }
+     }
+ #endif
+ 
    /* Bind keys, making new keymaps as necessary. */
!   for (i = start; i < keys_len; i++)
      {
        if (i + 1 < keys_len)
  	{
*** ./readline/vi_mode.c.orig	Thu Oct 19 22:26:53 1989
--- ./readline/vi_mode.c	Fri Mar 23 17:46:44 1990
***************
*** 402,408 ****
       int count, key;
  {
    if (!uppercase_p (key))
!     rl_forward (1);
  
    rl_yank ();
    rl_backward (1);
--- 402,411 ----
       int count, key;
  {
    if (!uppercase_p (key))
!     {
!     if(rl_point != rl_end)
!       rl_point++;
!     }
  
    rl_yank ();
    rl_backward (1);
***************
*** 449,455 ****
--- 452,463 ----
      return (-1);
  
    if ((c == 'w' || c == 'W') && rl_point < rl_end)
+     {
      rl_point--;
+     while((rl_point > 0) && whitespace (the_line[rl_point]))
+ 	rl_point--;
+     rl_point++;
+     }
  
    if (rl_mark < rl_point)
      exchange (rl_point, rl_mark);
***************
*** 849,854 ****
--- 857,863 ----
      vi_replace_map[i].function = rl_vi_overstrike;
  
    vi_replace_map[RUBOUT].function = rl_vi_overstrike_delete;
+   vi_replace_map[CTRL('H')].function = rl_vi_overstrike_delete;
    vi_replace_map[ESC].function = rl_vi_movement_mode;
    vi_replace_map[RETURN].function = rl_newline;
    vi_replace_map[NEWLINE].function = rl_newline;
Technical Details
Message-ID: <983@tumuc.UUCP>
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!tumuc!news

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,b4d468cd96e0dd32,start
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 1990-04-02 21:31:03 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!tumuc!news
From: news@tumuc.UUCP (USENET News System.)
Newsgroups: gnu.gdb.bug
Subject: Patches to readline VI mode
Message-ID: <983@tumuc.UUCP>
Date: 2 Apr 90 17:50:19 GMT
Organization: Technical University of Munich, W-Germany
Lines: 142
Posted: Mon Apr  2 18:50:19 1990