Skip to content

Home/End keys on numpad don't move cursor #408

Closed

Description

@LAC-Tech

Description

I have "Home" and "End" keys on my numpad.
I want to use them to navigate to the beginning and end of the line respectively:
Instead it prints out ^[[1~ and ^[[4~.

I don't think it's a problem with my setup. these numpad Home/End keys work on the following interpreters on this system

  • python
  • node
  • deno
  • ocaml (with rlwrap)

rlwrap irb produces the same results for me as above.

Result of irb_info

Please paste the result of irb_info command in IRB.

ex.)

irb(main):001:0> irb_info
=>
Ruby version: 3.1.2
IRB version: irb 1.4.1 (2021-12-25)
InputMethod: ReidlineInputMethod with Reline 0.3.0 and /home/lewis/.inputrc
RUBY_PLATFORM: x86_64-linux
LANG env: en_NZ.utf8
East Asian Ambiguous Width: 1

Terminal Emulator

Alacritty. Same issue on XTerm and UXTerm.

Setting Files

Are you using ~/.irbrc and ~/.inputrc?

no

Activity

  1. sshock commented on Oct 9, 2022

    @sshock

    Possibly related: #330 (comment)

    However, in your particular case, you may have additional problems because I use Alacritty as well and its terminfo is similar to XTerm. With both Alacritty and XTerm, Home and End (both the normal ones and the ones on the numpad when numlock is off) should not be sending ^[[1~ and ^[[4~ but rather ^[[H and ^[[F (or ^[OH and ^[OF when in application mode).

  2. LAC-Tech commented on Oct 10, 2022

    @LAC-Tech
    Author

    Are you familiar with reline? I had a brief poke around the source code but couldn't figure out where I might make this change.

  3. sshock commented on Oct 11, 2022

    @sshock

    Are you familiar with reline? I had a brief poke around the source code but couldn't figure out where I might make this change.

    What are you wanting to change? Multiple PRs already exist to fix several issues with the keys not working properly:

    Have you figured out what is going on with your terminal yet? You should start by making sure your terminal sends what it is supposed to. I use Alacritty too and I don't what you've done to make it send escapes codes that look more like the linux TERM than alacritty and xterm TERM. I think you should focus on that, although it is true after fixing that you may still be experiencing problems until one or more of the PRs above get merged in.

    You can use showkey -a to find out what your keys are sending.

  4. LAC-Tech commented on Oct 13, 2022

    @LAC-Tech
    Author

    There's 5 other interpreters (haskell, python, node, deno, ocaml) on this system that handle my home and end keys just fine. It's a little bit hard for me to imagine they all have extensive workarounds for my "weird" setup. It feels a lot more like reline is doing something brittle.

    But if there's a handful of PRs around this issue already, me adding another is unlikely to help, so I appreciate the context around this.

    Here's the showkey -a for Home and End.

    ^[[H 	 27 0033 0x1b
     	 91 0133 0x5b
     	 72 0110 0x48
    ^[[F 	 27 0033 0x1b
     	 91 0133 0x5b
     	 70 0106 0x46
    
  5. sshock commented on Oct 13, 2022

    @sshock

    Oh, good. Your Home and End are actually sending what they are supposed to.

    So yeah, either one of ruby/reline#433 or ruby/reline#462 would fix your problem.

    In the meantime, you can try this workaround or any of the other workarounds mentioned in that issue.

  6. st0012 commented on Jul 19, 2023

    @st0012
    Member

    I think this has been addressed by ruby/reline#569? cc @tompng

  7. tompng commented on Jul 19, 2023

    @tompng
    Member

    Home and End keys for \e[H and \e[F is fixed in ruby/reline#569
    Reline handles \e[1~ and \e[4~ only if terminfo has kend=\E[4~ and khome=\E[1~.

    Table of some tools handle \e[1~ \e[4~ by default or not

    \e[1~ \e[4~
    reline no no
    readline no no
    bash no no
    sh no no
    node yes yes
    emacs yes no
    vi yes yes
    python2, python3 (*) no no

    (unlike issue description, python2 and python3 does not handle \e[1~ \e[4~)

  8. LAC-Tech commented on Aug 28, 2023

    @LAC-Tech
    Author

    This will fix will be in an upcoming irb release?

    Not sure what you mean by python3 not handling home and end. I am typing it in the python interpreter right now (3.11.5) and it works absolutely fine. Where as irb (1.6.2) gives me:

    ^[[H^[[F               
    
  9. st0012 commented on Aug 28, 2023

    @st0012
    Member

    @LAC-Tech The issue has been fixed and released in Reline, so the issue should be gone once you upgraded it. But I'd recommend upgrading to the latest Reline + IRB with gem install irb.

  10. LAC-Tech commented on Aug 28, 2023

    @LAC-Tech
    Author

    Thanks so much! works great now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions