patchGNU Octave - Patches: patch #8534, For GUI undo, send Cntrl-U to...


patch #8534: For GUI undo, send Cntrl-U to Readline rather than callback command_editor.

Submitted by:  Dan Sebald <sebald>
Submitted on:  Sat 13 Sep 2014 05:42:51 PM UTC  
Category:  Core : other Priority:  3 - Low
Status:  Wont Do Privacy:  Public
Assigned to:  None Open/Closed:  Closed

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Sat 18 Jan 2020 11:33:07 AM UTC, comment #7: 

Review for Octave 6.

No interest for five years.  GUI code change a lot.

Closing item.

Kai Torben Ohlhus <siko1056>
Project Member
Fri 19 Sep 2014 06:12:24 AM UTC, comment #6: 

Yes, the global shortcuts is what I was looking for.  (I remember looking at preferences, but honestly I think I clicked on a different application I had open.)

The option is good, very nice actually with its ability to individually modify the assigned shortcuts.

Guess I'm on the fence right now about copy/paste/undo shortcuts not being deactivated along with others, simply because of the confusion it can cause.  I see that Copy (i.e., Ctrl-C) will interrupt the terminal if nothing is selected, but if something is selected then it will copy to the clipboard.  Try the following: type

>> Here is a partial line

and when nothing is highlighted and with "Disable global shortcuts" option active select the Edit::Copy drop down menu.  The terminal window does an interrupt.

Cntrl-V can't be passed to Readline (Cntrl-v means literal next character) unless perhaps Qt's binding for Paste is changed in the option menu.

Dan Sebald <sebald>
Fri 19 Sep 2014 05:32:33 AM UTC, comment #5: 

I am not sure what you mean with "an option for Readline-only bindings and Qt-only bindings". Currently there is an option in the shortcut tab whether shortcuts are used for readline or for the gui when the terminal has focus. If used for readline, all qt-shortcuts are disabled except for copy, paste and undo.

Torsten Lilge <ttl>
Project Member
Fri 19 Sep 2014 12:18:03 AM UTC, comment #4: 

I just realized the current implementation has two "undo"s. That is, the "Cntrl-z" shortcut and the green undo arrow behave differently. Type this:

Nope, I was wrong on that.  The two undos behave the same and I put a printf in the callback routine to verify cntrl-z is using the function.

What I don't like about hardcoding Cnrl-Z and undo is that no other window can have its form of undo.  Maybe that's not a problem, but it sure seems like "Undo" should change context with focus.

I'm wondering if the best option is to have an option for Readline-only bindings and Qt-only bindings for the focused terminal window.  If control characters go to Readline, then maybe change the window title to "Command Window (readline)", whereas if control characters go to Qt, the the window title is "Command Window".

Dan Sebald <sebald>
Thu 18 Sep 2014 10:57:25 PM UTC, comment #3: 

I thought about the re-assigning of key bindings, but I don't know what to do there other than leave it that way.  The octave code is calling:

octave_rl_do_undo (void)
  return rl_do_undo ();

and I think that rl_do_undo () is a library function.  So, conceptually there is an "undo" in readline, and most of the documentation out there points to C-u.

What about Cntrol-z?  Can that be reassigned (or even used) for the terminal?  C-z seems to be grouped with C-c as a stty signal--what the implies about bindings, I don't know.  Nonetheless, C-z can't be sent to the terminal (could be programmed to allow it, but currently doesn't).

I just realized the current implementation has two "undo"s.  That is, the "Cntrl-z" shortcut and the green undo arrow behave differently.  Type this:

I went to sea<backspace>e the sea.

Now type Cntrl-z a few times and watch what happens.  (Basically "untypes".)  Then type the same thing again and then press the green arrow.  (The whole line default Cntrl-u in Readline.)

Hmm, there seems to be a perhaps non-minor conflict here, and maybe some options are needed.  Right now, Qt shortcuts aren't working in the terminal window.  Is that good or bad?  Depends on viewpoint.  For example, Cntl-o Qt shortcut is to open a file.  But it only works when focus is outside of the terminal window (click in the workspace window, then type Cntrl-o).  Wouldn't a user expect that when typing at the command line that Cntrl-o would put up the "open" dialog box?

I way around this would be to have an option

[x] Command line uses Readline bindings
[ ] Command line uses Qt bindings

and then have as a shortcut to changing that option something in the right mouse click popup window.  Also, there could probably be an "Undo" in the right click popup window.

Dan Sebald <sebald>
Tue 16 Sep 2014 05:37:36 PM UTC, comment #2: 

Yes, absolutely. So this patch would accomplish sending a Ctrl-u to the command window when focused, but that may or may not do anything related to an "undo" readline action. Ctrl-u means "unix-line-discard" for me (erase the entire input line), not "undo", which is bound to Ctrl-_ by default.

The rest of this patch is probably fine, but I don't think the TerminalView can really do anything about an undo action from the GUI.

Mike Miller <mtmiller>
Project Administrator
Tue 16 Sep 2014 04:17:41 PM UTC, comment #1: 

Isn't it possible to configure readline in .inputrc in a way that Ctrl-U is not the undo but any other action?

Torsten Lilge <ttl>
Project Member
Sat 13 Sep 2014 05:42:51 PM UTC, original submission:  

Here is a changeset to change the manner in which Undo is implemented in the GUI.  Similar to the following patch which removes the need to access the core command_editor:

the attached patch will do the same by placing the undo operation for the terminal not at the main_window level, but at the TerminalView level.

This is a more object-oriented form of design in which the implementation of undo, specific to the object, is part of the object.  That is, "Undo" can be interpretted in different ways by different widgets.  For the terminal it means one thing, for the editor something different, and for new features it might mean something different.

What is done at the main_window level is to associate the Undo operation with whatever widget becomes in focus.  This is the more conventional behavior of GUI design these days, I think.  To reflect this, the Undo action will enable/disable the icon and Cntrl-Z based upon whether the tab widget has an Undo implementaton (i.e., slot).

Dan Sebald <sebald>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #32088:  octave-gui_undo_action-2014sep13.patch added by sebald (6KiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by ttl (Posted a comment)
  • -email is unavailable- added by sebald (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-01-18 siko1056 CategoryNone => Core : other
        Priority5 - Normal => 3 - Low
        StatusNone => Wont Do
        Open/ClosedOpen => Closed
    2014-09-13 sebald Attached File- => Added octave-gui_undo_action-2014sep13.patch, #32088

    Back to the top

    Powered by Savane 3.5