Ping

On Sat, 21 Nov 2020 18:59:25 +0200
Πάτερος Πέτρος <[email protected]> wrote:

> Hello everyone,
> 
> I am sending this because of an issue I had with a ported version of
> your ksh(1) on Linux (you can find the port at
> https://github.com/ibara/oksh), but everything I say here are also
> tested on a VM running OpenBSD 6.8.
Still an issue on  6.9 GENERIC.MP#379 amd64

> When using the 6.8 version I noticed that (in vi editing mode) hitting
> Ctrl+L (^L) attempts to clear the screen, both in normal and insert
> mode. The problem is that it clears the screen and then it prints
> only the last line of the prompt (PS1). The problem is when a multiline
> PS1 is in use, in which case the prompt is not printed as expected.
I do use a 2-line $PS1 prompt. Ctrl+L works (prints full $PS1) in emacs mode,
does not work correct in vi mode (prints last line of $PS1)

> It seems reasonable to me that this behviour is a bug, so I attempted
> to edit vi.c and came up with the first of the following patches.
Does what it says, with multiline $PS1. Reattached below.
Ramdisk's SMALL version is not affected, because vi mode is not compiled in.

> Also, now there is no way to ask redraw of the wrinting line
> (that is what ^L were doing previously). In normal mode that
> was remapped to ^R. I think that it is useful in insert mode
> also. You can see the second patch for this.
Maybe later?

> I hope that this will at least bring the issue to your attention.
> 
> Thank you for your time.



First patch reattached from a cvs diff
Index: vi.c
===================================================================
RCS file: /var/cvs/src/bin/ksh/vi.c,v
retrieving revision 1.57
diff -u -p -r1.57 vi.c
--- vi.c        20 Sep 2020 14:40:45 -0000      1.57
+++ vi.c        9 Mar 2021 12:57:30 -0000
@@ -55,7 +55,7 @@ static int    Endword(int);
 static int     grabhist(int, int);
 static int     grabsearch(int, int, int, char *);
 static void    do_clear_screen(void);
-static void    redraw_line(int);
+static void    redraw_line(int, int);
 static void    refresh_line(int);
 static int     outofwin(void);
 static void    rewindow(void);
@@ -719,7 +719,7 @@ vi_cmd(int argcnt, const char *cmd)
                        break;
 
                case CTRL('r'):
-                       redraw_line(1);
+                       redraw_line(1, 0);
                        break;
 
                case '@':
@@ -1737,18 +1737,18 @@ do_clear_screen(void)
                        neednl = 0;
        }
 #endif
-       redraw_line(neednl);
+       redraw_line(neednl, 1);
 }
 
 static void
-redraw_line(int neednl)
+redraw_line(int neednl, int full)
 {
        (void) memset(wbuf[win], ' ', wbuf_len);
        if (neednl) {
                x_putc('\r');
                x_putc('\n');
        }
-       vi_pprompt(0);
+       vi_pprompt(full);
        cur_col = pwidth;
        morec = ' ';
 }
@@ -2109,7 +2109,7 @@ complete_word(int command, int count)
                        vi_error();
                        x_print_expansions(nwords, words, is_command);
                        x_free_words(nwords, words);
-                       redraw_line(0);
+                       redraw_line(0, 0);
                        return -1;
                }
                /*
@@ -2183,7 +2183,7 @@ print_expansions(struct edstate *e)
        }
        x_print_expansions(nwords, words, is_command);
        x_free_words(nwords, words);
-       redraw_line(0);
+       redraw_line(0, 0);
        return 0;
 }
 

> ### /* first patch */
> diff --git a/bin/ksh/vi.c b/bin/ksh/vi.c
> index 53be5a76d50..5a45ab67710 100644
> --- a/bin/ksh/vi.c
> +++ b/bin/ksh/vi.c
> @@ -55,7 +55,7 @@ static int  Endword(int);
>   static int  grabhist(int, int);
>   static int  grabsearch(int, int, int, char *);
>   static void do_clear_screen(void);
> -static void  redraw_line(int);
> +static void  redraw_line(int, int);
>   static void refresh_line(int);
>   static int  outofwin(void);
>   static void rewindow(void);
> @@ -719,7 +719,7 @@ vi_cmd(int argcnt, const char *cmd)
>                       break;
> 
>               case CTRL('r'):
> -                     redraw_line(1);
> +                     redraw_line(1, 0);
>                       break;
> 
>               case '@':
> @@ -1737,18 +1737,18 @@ do_clear_screen(void)
>                       neednl = 0;
>       }
>   #endif
> -     redraw_line(neednl);
> +     redraw_line(neednl, 1);
>   }
> 
>   static void
> -redraw_line(int neednl)
> +redraw_line(int neednl, int full)
>   {
>       (void) memset(wbuf[win], ' ', wbuf_len);
>       if (neednl) {
>               x_putc('\r');
>               x_putc('\n');
>       }
> -     vi_pprompt(0);
> +     vi_pprompt(full);
>       cur_col = pwidth;
>       morec = ' ';
>   }
> @@ -2109,7 +2109,7 @@ complete_word(int command, int count)
>                       vi_error();
>                       x_print_expansions(nwords, words, is_command);
>                       x_free_words(nwords, words);
> -                     redraw_line(0);
> +                     redraw_line(0, 0);
>                       return -1;
>               }
>               /*
> @@ -2183,7 +2183,7 @@ print_expansions(struct edstate *e)
>       }
>       x_print_expansions(nwords, words, is_command);
>       x_free_words(nwords, words);
> -     redraw_line(0);
> +     redraw_line(0, 0);
>       return 0;
>   }
> 
> ### /* end of first patch */
> ### /* second patch */
> --- a/bin/ksh/vi.c
> +++ b/bin/ksh/vi.c
> @@ -658,6 +658,10 @@ vi_insert(int ch)
>               do_clear_screen();
>               break;
> 
> +     case CTRL('r'):
> +             redraw_line(1, 0);
> +             break;
> +
>       case CTRL('i'):
>               if (Flag(FVITABCOMPLETE)) {
>                       complete_word(0, 0);
> ### /* end of second patch */
> 

Reply via email to