On June 18, 2018 11:00:00 PM GMT+02:00, Richard Procter 
<richard.n.proc...@gmail.com> wrote:
>
>On 6/06/2018, at 10:20 AM, Alexander Hall wrote:
>
>> This adds a "clear-screen" editing command to the emacs editing mode.
>> This is the same name as bash and zsh uses, and then I stopped
>looking.
>> 
>> Thoughts? OK?
>
>It's unclear to me what need is being being addressed here --- are you
>wanting a way to quickly hide sensitive info typed by mistake at a
>commandline?

Hi. Your comments and concerns are appreciated.

My main use case for this is when I'm in the middle of typing a command, and 
then realize I would like have its output on a blank screen to make it easier 
to separate from the previous command.

>
>^Cclear^M is available, of course, or ^A^K, or the "bind -m
>'^L'=^Uclear'^J^Y'"
>that benno@ mentioned. On the console, one can switch VT. I suppose
>some
>window managers offer short-cuts to "lock screen", or can switch
>virtual
>desktops, or minimise the window.
>
>Yes, I could see how the patch might be warranted if this occured
>frequently, but how often do you find yourself needing it? Often enough
>to be annoyed by the side-effects you mentioned of benno's key binding?

Getting used to having it at work, I find it being a useful feature I'm using, 
and thus lacking, several times a day. I'm willing to accept it being 
considered featuritis.

I'd rather not have it pollute my buffers, since it has nothing to do with 
them. Oh, and it's screws up any intentions of using ^O. 

>It seems to me this patch would make ksh into a screen-orientated shell

I don't think this diff puts us there quite yet. 

>for the sake of reimplementing a rarely-used shortcut.

For me it's not rarely used. Unless of course I'm using OpenBSD's ksh.

/Alexander 

>
>best, 
>Richard.  
>
>> 
>> 
>> /Alexander
>> 
>> 
>> Index: emacs.c
>> ===================================================================
>> RCS file: /cvs/src/bin/ksh/emacs.c,v
>> retrieving revision 1.84
>> diff -u -p -r1.84 emacs.c
>> --- emacs.c  16 Jan 2018 17:17:18 -0000      1.84
>> +++ emacs.c  5 Jun 2018 22:03:49 -0000
>> @@ -146,6 +146,7 @@ static int       isu8cont(unsigned char);
>> /* proto's for keybindings */
>> static int   x_abort(int);
>> static int   x_beg_hist(int);
>> +static int  x_clear_screen(int);
>> static int   x_comp_comm(int);
>> static int   x_comp_file(int);
>> static int   x_complete(int);
>> @@ -202,6 +203,7 @@ static int       x_debug_info(int);
>> static const struct x_ftab x_ftab[] = {
>>      { x_abort,              "abort",                        0 },
>>      { x_beg_hist,           "beginning-of-history",         0 },
>> +    { x_clear_screen,       "clear-screen",                 0 },
>>      { x_comp_comm,          "complete-command",             0 },
>>      { x_comp_file,          "complete-file",                0 },
>>      { x_complete,           "complete",                     0 },
>> @@ -1004,12 +1006,19 @@ x_draw_line(int c)
>> {
>>      x_redraw(-1);
>>      return KSTD;
>> +}
>> 
>> +static int
>> +x_clear_screen(int c)
>> +{
>> +    x_redraw(-2);
>> +    return KSTD;
>> }
>> 
>> -/* Redraw (part of) the line.  If limit is < 0, the everything is
>redrawn
>> - * on a NEW line, otherwise limit is the screen column up to which
>needs
>> - * redrawing.
>> +/* Redraw (part of) the line.
>> + * A non-negative limit is the screen column up to which needs
>> + * redrawing. A limit of -1 redraws on a new line, while a limit
>> + * of -2 (attempts to) clear the screen.
>>  */
>> static void
>> x_redraw(int limit)
>> @@ -1018,9 +1027,15 @@ x_redraw(int limit)
>>      char    *cp;
>> 
>>      x_adj_ok = 0;
>> -    if (limit == -1)
>> +    if (limit == -2) {
>> +            char *clearstr = str_val(global("CLEARSTR"));
>> +            if (clearstr == null)
>> +                    clearstr = "\033[H\033[J";
>> +            x_e_puts(clearstr);
>> +    }
>> +    else if (limit == -1)
>>              x_e_putc('\n');
>> -    else
>> +    else if (limit >= 0)
>>              x_e_putc('\r');
>>      x_flush();
>>      if (xbp == xbuf) {
>> Index: ksh.1
>> ===================================================================
>> RCS file: /cvs/src/bin/ksh/ksh.1,v
>> retrieving revision 1.200
>> diff -u -p -r1.200 ksh.1
>> --- ksh.1    30 May 2018 21:20:52 -0000      1.200
>> +++ ksh.1    5 Jun 2018 22:03:49 -0000
>> @@ -1345,6 +1345,8 @@ Also, the
>> .Ic cd
>> built-in command will display the resulting directory when a match is
>found
>> in any search path other than the empty path.
>> +.It Ev CLEARSTR
>> +If set, overrides the default escape sequence to clear the screen.
>> .It Ev COLUMNS
>> Set to the number of columns on the terminal or window.
>> Currently set to the
>> @@ -4690,6 +4692,12 @@ Moves the cursor to the beginning of the
>> Uppercase the first character in the next
>> .Ar n
>> words, leaving the cursor past the end of the last word.
>> +.It clear-screen:
>> +Clears the screen and redraws the prompt and current input line.
>> +If the
>> +.Ev CLEARSTR
>> +parameter is set, it is used to clear the screen.
>> +Otherwise, a default escape sequence (^[[H^[2J) is used.
>> .It comment: ^[#
>> If the current line does not begin with a comment character, one is
>added at
>> the beginning of the line and the line is entered (as if return had
>been
>> 

Reply via email to