bugGNU Octave - Bugs: bug #41337, Cannot retrieve command history...

 
 

bug #41337: Cannot retrieve command history from keyboard

Submitted by:  Andrew Schwartz <ozydingo>
Submitted on:  Fri 24 Jan 2014 05:58:45 PM UTC  
 
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Andrew Open/Closed:  Closed
Release:  3.8.0 Operating System:  Mac OS

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)

Sun 03 Aug 2014 09:41:29 AM UTC, comment #31: 

Closing this report, remaining issues with key-modifiers (if any) can be discussed in bug #41217.

Torsten Lilge <ttl>
Project Member
Tue 15 Jul 2014 07:37:01 AM UTC, comment #30: 

The issue about option (alt) modifier has been fixed with bug #41124. The next 3.8.2 bug fix release will include the fix.

Pantxo Diribarne <pantxo>
Project Member
Mon 14 Jul 2014 05:13:58 PM UTC, comment #29: 

I have tested the patch 3e53eca42f00 by applying it to the Octave 3.8.1 sources. With the patch applied, the cursor keys work. However, characters requiring the use of the alt key on non-US keyboards (I have a MacBook with Swiss-German keyboard layout) do not work. Due this not only applies to foreign letters with accents, but also to parentheses [], {}, and the backslash \, Octave is hardly usable from the command line window of the GUI.

Torsten Maehne <maehne>
Wed 26 Mar 2014 07:32:38 PM UTC, comment #28: 

I propose closing this bug report and working on the problem of configurable keybindings separately.

John W. Eaton <jwe>
Project Administrator
Wed 26 Mar 2014 07:31:26 PM UTC, comment #27: 

I added a comment and applied the mac layout patch on stable so it will be part of 3.8.2 (if there is one):

http://hg.savannah.gnu.org/hgweb/octave/rev/3e53eca42f00

John W. Eaton <jwe>
Project Administrator
Wed 26 Mar 2014 06:33:06 PM UTC, comment #26: 

FYI, the HEAD Homebrew option actually grabs the latest gui-release build. My experience is that it works quite well for a prerelease.

Michael C. Grant <mcgrant>
Wed 26 Mar 2014 06:29:58 PM UTC, comment #25: 

Is there any reason why the patch #30734 is neither included in 3.8.1 nor HEAD? It's a pity because this makes the GUI clearly less useful for many Mac users! For now I requested to add the patch to homebrew. However solving this upstream would be much better!

Sebastian <sschoeps>
Mon 17 Mar 2014 01:17:09 PM UTC, comment #24: 

Patch #30734 can be applied as is, it will let arrow keys work (which is a very important feature I think).
As for patch #30744, it was just meant to be a proof of concept so it should not be applied. The long term solution seems to be having configurable shortcuts, but I can prepare a patch for mac build only if Carlo intends to make a new dmg.

Pantxo Diribarne <pantxo>
Project Member
Mon 17 Mar 2014 05:56:24 AM UTC, comment #23: 

No, it wasn't. If I understand the discussion right, patch #30734 and #30744 are needed to fix this?

Torsten Lilge <ttl>
Project Member
Mon 17 Mar 2014 05:40:28 AM UTC, comment #22: 

Hi,
Was this patch applied in 3.8.1?

Carlo de Falco <cdf>
Project Member
Mon 03 Mar 2014 07:11:53 PM UTC, comment #21: 

Thanks for the clarifications. The arrow keys do indeed work if I also apply mac_layout2.patch.

Both test1 and test2 worked as you expected.

I would say that any final patch should be tweaked to move the interrupt command back to CTRL-C. Mac users will have significant muscle memory trained on CMD-C being exclusively for text copy, and of course CTRL-C is the interrupt key in the UNIX shell and in MATLAB's GUI as well.

Michael C. Grant <mcgrant>
Mon 03 Mar 2014 06:55:30 PM UTC, comment #20: 

Michael,

The arrows work for me when I apply Torsten's modified patch (mac_layout2.patch).

Now about shortcuts (CTRLswap patch), there is a confusion due to the fact that on mac there is a single menu for all windows. The menu item shortcuts are updated depending on what window has the focus.

When the terminal has focus, CMD+p and CMD+n are not defined, with or without the patch (see file/new and edit menu), so readline receives the shortcuts (CMD is treated as Meta).
The only shortcuts that are defined are CMD+c, CMD+v and CMD+z. The two first ones work as expected for me and I don't know what the third should do but it is triggered (see edit menu blink).

As far as I can see, shortcuts work if they are defined in the menu (in the context of the window which has focus) and out of the m file editor.

Can you test this:
 - test1: let e.g. command history window have focus and try CMD+SHIFT+n (should open "new function" dialog) or CMD+SHIFT+f (should open "find file" dialog)
 - test2: let the terminal have focus and

>>blabla #select the text and type CMD+c and CMD+v to copy/paste
>>pause (30) #CMD+c should interrupt
>>blabla #CTRL+a should got to begining of line CTRL+k kill the line ...

If this works it is all the patch intended to show: overriding default Qt CMD-CTRL swap let us use the Ctrl and CMD keys as we wish. 

Pantxo Diribarne <pantxo>
Project Member
Mon 03 Mar 2014 05:31:16 PM UTC, comment #19: 

Pantxo, I applied the CTRLswap patch, but I'm not sure if it's having the intended effect. I am able to access the command history with CTRL-p and CTRL-n, but the arrow keys don't work, and I would have expected this patch to activate CMD-p and CMD-n instead. Perhaps I'm misreading your intent, or you wanted me to apply the other patches in this bug report as well? My apologies for the confusion.

Michael C. Grant <mcgrant>
Sat 01 Mar 2014 05:10:16 PM UTC, comment #18: 

Maybe now would be a good time to start thinking about how to allow all keyboard shortcuts to be customized.

John W. Eaton <jwe>
Project Administrator
Sat 01 Mar 2014 03:35:43 PM UTC, comment #17: 

Michael, as a proof of concept I produced a patch. Can you test it please?

(file #30744)

Pantxo Diribarne <pantxo>
Project Member
Sat 01 Mar 2014 03:01:14 PM UTC, comment #16: 

>>My personal view is that the first priority should be to mimic >>standard or de-facto default Mac behavior. (I would say the same >>for Windows, in fact.) Second priority should be consistency >>across platforms.


>>*Roughly* speaking, swapping CTRL and CMD goes a long way >>towards achieving Mac-friendly behavior.


I also think that CMD should be used for application shortcuts so as to mimic  mac default behavior, that's why my proposition is to do the swap but in our code and to not let Qt do it for us. This is one way to avoid ctrl key sequences to be lost.
There may be smarter ones ...

Pantxo Diribarne <pantxo>
Project Member
Sat 01 Mar 2014 02:10:46 PM UTC, comment #15: 

Now about CTRL key. A solution could be to avoid Qt default behavior which is swapping CTRL and META(CMD).
I made a trial, adding the following at the beginning  of main_window::construct_menu_bar (void) (this is probably not the right place):

{
  QMenuBar *menu_bar = menuBar ();

  QCoreApplication::setAttribute (Qt::AA_MacDontSwapCtrlAndMeta, true);
...

Using this trick I can use ctrl modifier as in mac terminal, but hard coded shortcuts (like CMD+Z, CMD+C ...) don't work anymore as expected.

Replacing all instances of Qt::ControlModifier by a custom OctaveControlModifier (which would default to Qt::ControlModifier for all platforms and Qt::MetaModifier for mac) should do the rest of the job.

Do you think it's a viable approach or should we avoid such platform specific tricks?

Pantxo Diribarne <pantxo>
Project Member
Sat 01 Mar 2014 12:42:55 PM UTC, comment #14: 

Following comment #13 in bug #41124: the reason why e.g. ALT+p doesn't trigger the proper readline action as does ESC followed by "p" character is that you end with the equivalent of ESC followed by "pi" (the greek letter on my keyboard layout, this may be different for others).

Disabling the system wide behavior of option key is not an option because you end with no modifier at all: ALT+p is then equivalent to p and Qt doesn't see you have pressed ALT.

Instead of letting the current behavior, i.e. ALT+... -> ESC followed by ..., be configurable, I would simply disable it on mac platform until we have a proper solution.

There is a workaround: using ESC.

Pantxo Diribarne <pantxo>
Project Member
Fri 28 Feb 2014 03:43:19 PM UTC, comment #13: 

Hi,

I applied the patch and at startup (in the original terminal) I obtained a warning message that states that the header could not be properly parsed. I modified your patch: added \n at the end of each line, and removed escape \ at the last line. With attached modified patch I see no warning.

Finally, CTRL+... still doesn't work but all the arrows now work! Searching history (arrow up/down) and moving the cursor (left/right) work as expected.

(file #30734)

Pantxo Diribarne <pantxo>
Project Member
Thu 27 Feb 2014 09:16:36 PM UTC, comment #12: 

I have attached a patch for testing that uses the keytab from comment #10 when compiling for MAC OS

(file #30723)

Torsten Lilge <ttl>
Project Member
Sun 23 Feb 2014 08:56:17 PM UTC, comment #11: 

Bug #41676 marked as duplicate of this bug

Torsten Lilge <ttl>
Project Member
Wed 29 Jan 2014 10:15:03 AM UTC, comment #10: 

I see in libgui/libgterminal a file called default.keytab that defines some keybindings (actually I think octave doaesn't use this file but rather a fixed header file ExtendedDefaultTranslator.h)

I found a macbook.keytab at [1] that was written for supporting mac keyboard in Qterminal. Maybe using .keytab files would help here. This is my 2cents

[1] https://github.com/qterminal/qtermwidget/blob/master/lib/kb-layouts/macbook.keytab

Pantxo Diribarne <pantxo>
Project Member
Wed 29 Jan 2014 12:19:31 AM UTC, comment #9: 

Yes, the CMD+C test works for me.

Michael C. Grant <mcgrant>
Tue 28 Jan 2014 09:17:11 PM UTC, comment #8: 

Readline commands involving Meta key work for me if I use ESC followed by p,>,< ... (this is the default behavior in mac terminal also).

Michael, to be clear, only hard coded shortcuts (those in the GUI menu) using CMD work for me.
There is an exception though: CMD+C may copy a selected text or interrupt the execution of the current octave command (which involves readline). 

Does this wortk for you Michael ?

pause (10) #press CMD+C to interrupt

Pantxo Diribarne <pantxo>
Project Member
Tue 28 Jan 2014 08:22:49 PM UTC, comment #7: 

Actually, the CMD substitution that Pantxo suggests is not working for me, either. None of the key combinations suggested by the "Command History" section of the documentation work, and I haven't found a ctrl/shift/option/cmd combination that does.

Michael C. Grant <mcgrant>
Tue 28 Jan 2014 08:07:55 PM UTC, comment #6: 

Since qt is mapping the ctrl-key to the cmd-key on a Mac maybe this behavior causes the trouble in QTerminal which is used in the gui. Does any other key modifier happen to work for the readline commands?

Torsten Lilge <ttl>
Project Member
Mon 27 Jan 2014 06:29:04 PM UTC, comment #5: 

All of them are mapped to CMD instead of CTRL, but they do work. AFAICS, this Qt default behavior, and I am not suprised that hard coded shortcuts involving CTRL work that way.

The problem is that "real CTRL" key sequences don't seam to reach readline as they do in CLI.

Pantxo Diribarne <pantxo>
Project Member
Mon 27 Jan 2014 05:58:54 PM UTC, comment #4: 

Are you able to use the menu shortcuts using Ctrl?

Torsten Lilge <ttl>
Project Member
Mon 27 Jan 2014 05:45:04 PM UTC, comment #3: 

I am facing the same problem here on a macbook, using the dmg from octave-forge: none of the key sequences involving CTRL work (except CTRL+C/V which is mapped to CMD+C/V).

Retrieving history through up/down arrow keys doesn't work neither but this may be another issue.

Pantxo Diribarne <pantxo>
Project Member
Mon 27 Jan 2014 04:15:59 PM UTC, comment #2: 

I can confirm this in my local build. I'm building from the dev source (stable branch), with readline, Qt, etc. I can cycle through command history with the CLI (./run-ocrtave) but none of those keys have an effect in the GUI (./run-octave --force-gui).

Michael C. Grant <mcgrant>
Sat 25 Jan 2014 12:21:59 AM UTC, comment #1: 

Thanks for your report. I believe there are several ways to install Octave on MacOS, can you explain how you installed it or built it yourself? Is it built with readline support? Do you have any custom readline configuration? Do other readline key bindings work, such as Ctrl-A for beginning of line, Ctrl-E for end of line? Also, I take it from the bug header that you are using the experimental GUI?

Mike Miller <mtmiller>
Project Administrator
Fri 24 Jan 2014 05:58:45 PM UTC, original submission:  

Command history keyboard shortcuts, such as C-p, C-n, M-<, M->, have no effect on my system.

history and run_history works as documented.

Andrew Schwartz <ozydingo>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #30744:  CTRLswap_Poc.patch added by pantxo (3KiB - text/x-diff)
file #30734:  mac_layout2.patch added by pantxo (3KiB - text/x-diff)
file #30723:  mac_layout_v01.patch added by ttl (3KiB - text/x-diff)

 

Carbon-Copy List
  • -email is unavailable- added by maehne (Posted a comment)
  • -email is unavailable- added by sschoeps (Posted a comment)
  • -email is unavailable- added by sschoeps
  • -email is unavailable- added by cdf (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by ttl (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by mcgrant (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by ozydingo (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 project members can vote.

     

     

     

    Follow 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-08-25 jordigh Dependencies- => bugs #43066 is dependent
    2014-08-03 ttl StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2014-03-25 sschoeps Carbon-Copy- => Added sschoeps
    2014-03-17 cdf Dependencies- => bugs #41881 is dependent
    2014-03-01 pantxo Attached File- => Added CTRLswap_Poc.patch, #30744
    2014-02-28 pantxo Attached File- => Added mac_layout2.patch, #30734
    2014-02-27 ttl Attached File- => Added mac_layout_v01.patch, #30723
    2014-02-23 ttl Dependencies- => bugs #41676 is dependent
    2014-01-27 mtmiller StatusNeed Info => Confirmed
    2014-01-25 mtmiller StatusNone => Need Info

    Back to the top


    Powered by Savane 3.5