octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #56151] esc should clear command line, edits s


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #56151] esc should clear command line, edits shouldn't disable history
Date: Wed, 17 Apr 2019 18:41:12 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0

Follow-up Comment #18, bug #56151 (project octave):

I think there may be some confusion about what is happening with the arrow
keys.  I don't think it is that they are disabled, but when the cursor is not
at the beginning of the line, readline is always trying to search for the
previous (up arrow) or next (down arrow) line that matches what appears
between the beginning of the line and the cursor.  That's exactly what is
described in Octve's default system-wide inputrc file where we add the
bindings for up and down arrow to be:


## history-search-backward:
##
##   Search backward through the history for the string of characters
##   between the start of the current line and the point.  This is a
##   non-incremental search.  Bound to "\e[A", the ANSI escape
##   sequence for the UP arrow.

"\e[A": history-search-backward

## history-search-forward:
##
##   Search forward through the history for the string of characters
##   between the start of the current line and the point.  This is a
##   non-incremental search.  Bound to "\e[B", the ANSI escape
##   sequence for the DOWN arrow.

"\e[B": history-search-forward


We added these bindings because another Matlab user com^H^H^Hexplained that
Matlab performs searches with the arrow keys in this way.  Maybe that
explanation was not complete, or the behavior of readline is not exactly what
Matlab does.

When the cursor is not at the beginning of the line, it only appears to leave
you stuck if there are no other matches in the history list.  So if you move
up in the history and edit a line (leaving the cursor somewhere other than the
beginning of the line) and then type the up or down arrow readline will search
for lines that match the text between the beginning of the line and the
cursor.  Moving the cursor to the beginning of the line should make the arrow
keys move up or down by one entry in the history list instead of matching.

I don't think it's that readline's behavior here is necessarily bad, it's just
not what you were expecting.

Maybe removing the bindings shown above will help you?  If not, then I think
we need to understand *precisely* what Matlab does here in order for someone
to attempt to make Octave behave the same way.

Rik: For Octave's GUI terminal window, I think you can use the "\e[A", "\e[B",
"\e[C", and "\e[D" sequences for the arrow keys.  And these days, I think they
should work for most any terminal, but I could be wrong.

The default bindings for previous-history and next-history should include the
up and down arrow keys so if we change this globally, we should only have to
remove the bindings from Octave's default inputrc file, not add anything new.

But if you want to change this for yourself without editing a system-wide
file, adding


"\e[A": previous-history
"\e[B": next-history


to your ~/.inputrc file should do it.

Finally, you can use "Control-x k" at the Octave prompt to display all the
bindings that are currently active.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?56151>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]