bugGNU nano - Bugs: bug #51685, Option+Left and Option+Right...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #51685: Option+Left and Option+Right toggle stuff on Apple Terminal

Submitter:  None
Submitted:  Tue 08 Aug 2017 02:50:13 AM UTC
   
 
Severity:  2 - Minor Status:  Wont Fix
Assigned to:  bens Open/Closed:  Closed

Jump to the original submission

Tue 26 Sep 2017 07:51:08 PM UTC, comment #11: 

Thanks for the escape sequences, Mike.  I've added the ones that iTerm2 produces when using "xterm Defaults", in commit c8a2f36e.

Since Apple's default Terminal app simply produces \eb and \ef for Option+Left and Option+Right, there is nothing nano can do about that, so I would mark this as "Cant Fix", or "Not Our Bug", but Savannah doesn't know those resolutions.

Benno Schulenberg <bens>
Group administrator
Fri 15 Sep 2017 10:09:46 PM UTC, comment #10: 

i just remembered the 2nd arg usage.  the number is used to differentiate modifiers.  here's xterm's page:
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-PC-Style-Function-Keys
                    Code     Modifiers
                  ---------+---------------------------
                     2     | Shift
                     3     | Alt
                     4     | Shift + Alt
                     5     | Control
                     6     | Shift + Control
                     7     | Alt + Control
                     8     | Shift + Alt + Control
                     9     | Meta
                     10    | Meta + Shift
                     11    | Meta + Alt
                     12    | Meta + Alt + Shift
                     13    | Meta + Ctrl
                     14    | Meta + Ctrl + Shift
                     15    | Meta + Ctrl + Alt
                     16    | Meta + Ctrl + Alt + Shift
                  ---------+---------------------------

so iTerm2 is report opt like meta instead of alt ?  odd.

Mike Frysinger <vapier>
Group Member
Fri 15 Sep 2017 08:50:26 PM UTC, comment #9: 

in macOS terminal emulators, option is supposed to be the same as alt.  of course, what the terminal emulator decides to transmit on such keystrokes is up to it.  below is what the defaults are for me under 10.12.6 (Sierra) and iTerm2 3.0.15.

Apple's Terminal.app
Opt+Up  \e[A
Opt+Down  \e[B
Opt+Right  \ef
Opt+Left   \eb
the up & down keystrokes look normal (CSI Cursor Up & Cursor Down), but wtf is going on with right+left ?  those look dumb.

iTerm2 (default is "Terminal.app compatible"):
Opt+Up  \e\e[A
Opt+Down  \e\e[B
Opt+Right \e\e[C
Opt+Left  \e\e[D
wut ?  it sends two escapes ?  if it weren't for that first escape, i'd say these bindings were ideal.  also, it's not what Terminal.app is doing ... i wonder if older versions did, but iTerm2 is still mimicing those older (braindead) versions ?

iTerm2 (using "xterm Defaults"):
Opt+Up  \e[1;9A
Opt+Down  \e[1;9B
Opt+Right \e[1;9C
Opt+Left  \e[1;9D
xterm uses 1;3, not 1;9.  not that it really matters as the CSI sequences here only process the first arg ... the 3/9 values are simply ignored.

if someone wants to probe their terminal locally, you can do:
  $ cat | hexdump -C
  <combo><enter><ctrl+d>
you'll then get the hex bytes the combo generated.

Mike Frysinger <vapier>
Group Member
Sun 13 Aug 2017 03:50:42 PM UTC, comment #8: 

When someone someday has some time to catch the escape sequences that Opt+Left and Opt+Right produce on an Apple Terminal, let me know.

Benno Schulenberg <bens>
Group administrator
Thu 10 Aug 2017 11:49:21 AM UTC, comment #7: 

Opt+Up and Down just move the cursor up and down - the same as if Opt isn't even pressed.

Yes I've compiled things on macOS before, and yes the capability exists, but I have a 4 wk newborn so my time is extremely limited!

Thanks again. And thanks for thinking of my problem while dreaming! haha

Anonymous
Thu 10 Aug 2017 09:54:48 AM UTC, comment #6: 

Yeah, when I woke this morning, I realized you could simply rebind M-B and M-F, if that is what your Option+Left and Option+Right produce.  The unbind commands are superfluous, by the way: the bind commands by themselves are enough.

And I suspected you weren't using iTerm2, because otherwise Scalora would have squeaked long ago.

Out of curiosity: what happens when you press Option+Up and Option+Down?

And how come you aren't able to build nano from source?  Surely MacOS allows you to install a compiler and any necessary header files?

I would mark this bug as "Has Workaround", but Savannah is very limited in the types of resolutions.

Benno Schulenberg <bens>
Group administrator
Thu 10 Aug 2017 12:05:39 AM UTC, comment #5: 

Forgot to answer your other question: I'm using Terminal (the Apple app); I haven't tried any other terminal apps.

Anonymous
Thu 10 Aug 2017 12:04:33 AM UTC, comment #4: 

I don't have the capability to do as you asked. However, you inadvertently solved my problem. I've created the following `.nanorc` file:
===
unbind M-B all
bind M-B prevword all
unbind M-F all
bind M-F nextword all
===

And all is right in the world.

Many thanks!

Anonymous
Wed 09 Aug 2017 07:32:32 PM UTC, comment #3: 

It is three years ago that I deciced to drop the ability to rebind the dedicated cursor-movement keys, and I don't quite remember why.  Probably because it made things simpler and faster.

But it is strange that pressing Option+Left toggles backups, and Option+Right toggles multibuffer.  To figure out what happens there, you need to do what I suggested: configure and build nano with --enable-debug, type those two key combos three times in a row, and attach the resulting TRAIL file.  Because it seems that those Option keystrokes produce escape sequences that just happen to contain the codes for Alt+B and Alt+F.  If those codes happen to be unique, it will be easy to alias them to Ctrl+Left and Ctrl+Right.

Also: on what terminal do you see this?  On an iTerm2?  And does it happen also on a different terminal?  On the standard Apple one?

Benno Schulenberg <bens>
Group administrator
Wed 09 Aug 2017 12:42:51 AM UTC, comment #2: 

Sorry that my post was ambiguous. (I think I downloaded a newer nano version between starting and finishing the bug report.)

When I hit Option+Left (which is the same as Alt+Left, and I believe M-Left), it shows this on the bottom status bar:  [ Backup files enabled ]

Hitting it again disables backup files.

Option+Right shows: [ Reading file into separate buffer disabled ]

Control+Left and Control+Right moves the cursor by one word at a time, as you suggested it would. This would suffice, however it's different than how it works with native Mac apps and even bash (see https://support.apple.com/en-us/HT201236 about halfway down "Option–Left Arrow -> Move the insertion point to the beginning of the previous word.").

I think it would be a nice feature to be able to dispose of a function that I don't care about (separate buffers & backup files) that's attached to a key binding that I do care about (alt+left/right). The fact of the matter is, I instinctively hit alt-Left so frequently while editing files that I have a permanent imprint on my forehead from all the facepalms. To me it just makes sense to be able to control the M-Left behavior, that's all. If it doesn't make sense to you, I can't demand a reason but wouldn't mind hearing it.



In response to your question: You ask how come I "realize it would be impossible"... the answer is simply because you choose not to allow it to be possible (as stated). Your reasons for doing so are unclear to me, and that's up to you.. but I've read multiple posts stating that the developer (presumably you) has chosen not to.. therefore unless someone forks the project, it is thusly impossible. If my logic is flawed, please enlighten me because I think many would enjoy the option to rebind modifier+arrow keys.

Anonymous
Tue 08 Aug 2017 05:13:15 PM UTC, comment #1: 

How come you realize that it would be impossible to rebind the Ctrl+Arrow keys?  They could very well be rebindable, if we included the code for that.  But I chose not to.

When you run 'nano --ignore somefile' and you type Alt+Left (or please say exactly what you type when you're on a Mac), then the cursor jumps back a word AND it says something about toggling multibuffer mode?  That is strange.  Because it is Ctrl+Left that should jump back a word, Alt+F should toggle multibuffer mode, and Alt+Left should say that it is an "Unbound key".

If you do actually get that strange "combined" behavior when typing Alt+Left, then please configure nano with --enable-debug, compile it, and run 'src/nano NEWS 2>TRAIL'.  Then type Alt+Right three times, and Alt+Left three times, and then ^X, and attach the resulting TRAIL file here.

Benno Schulenberg <bens>
Group administrator
Tue 08 Aug 2017 02:50:13 AM UTC, original submission:  

I realize that it's not possible to rebind Control-LEFT but I haven't seen a good enough reason that one cannot rebind alt- (or meta-, or on my Mac, option-) arrow keys, such as alt-RIGHT or M-RIGHT.

I get this warning:  Key name M-LEFT is invalid.

nano clearly knows how to interpret alt-LEFT when in the editor, because every time I do it (meaning to go back a word), it displays something about enabling multiple buffer files, which I honestly don't care a lick about.

I'll go ahead and reference #44688, since someone else will otherwise. This is not the same bug. That's specifically asking to rebind CONTROL-LEFT whereas I'm asking to rebind M-LEFT.

Thanks

Anonymous

 

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

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by vapier (Posted a comment)
  • -email is unavailable- added by bens (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-11-14 bens Open/ClosedOpen Closed
    2017-09-26 bens StatusNeed Info Wont Fix
    2017-08-13 bens Severity3 - Normal 2 - Minor
        StatusReady For Test Need Info
    2017-08-10 bens StatusNeed Info Ready For Test
        SummaryUnable to rebind Alt-LEFT (M-LEFT) Option+Left and Option+Right toggle stuff on Apple Terminal
    2017-08-08 bens StatusNone Need Info
        Assigned toNone bens

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code