Skip to content

rxvt-unicode control-arrowkeys incompatible with mosh #161

Closed

Description

@keithw

For control-arrowkey, xterm and gnome-terminal (and I think Terminal.app) send ^[[1;5D

But rxvt-unicode sends ^[Od .

Unfortunately this confuses mosh (which puts the user in application-mode cursor keys and translates them to ANSI if necessary, which requires no lookahead). See terminaluserinput.cpp

Solution 1: More lookahead to correctly translate rxvt-unicode cursor keys (we have to see what the byte is AFTER ^[O, aka SS3, to know whether it needs to be translated to ANSI mode). I don't want to do more lookahead though, because it means delaying when a byte gets sent to the server in some cases, and it's easier to just never do this.

Solution 2: Stop translating cursor keys, and just propagate the application's choice of cursor key mode all the way to the outer terminal, and maintain it as part of the synchronized state. This has some appeal, but I'm not sure what the difficulties will be without trying it.

Solution 3: Declare it a bug in rxvt-unicode.

Thanks to Meelap for identifying this.

Activity

  1. peterjeremy commented on Apr 13, 2012

    @peterjeremy
    Contributor

    It's not clear how the lookahead required in ESC O d is any different to that in ESC [ 1 ; 5 D. If anything, SS3 sequences are easier to parse because they are fixed length.

  2. keithw commented on Apr 13, 2012

    @keithw
    MemberAuthor

    The difficulty is in the opposite direction: with mosh, the user's terminal is always in application mode, so it's always going to send ESC O D. If the application has requested ANSI mode (the default), we need to translate that to ESC [ D (and we do that in terminaluserinput.cpp with very simple logic).

    This can be done with no lookahead -- we just say that if the previous byte was ESC and the current byte is O and the virtual terminal is in ANSI mode, we translate the current byte to be [. This works fine with the xterm/gnome-terminal/Terminal.app syntax because SS3 is only used for application-mode cursor keys. The control-arrow sequences use CSI and are invariant -- they don't change based on cursor key mode.

    urxvt screws this up by sending an "application-mode" sequence for control-arrowkey (SS3 d) that is also invariant based on cursor key mode. But of course we are interpreting the SS3 as signalling an application-mode cursor key that needs to be translated to ANSI mode. Hence the problem, which is hard to solve without looking ahead at the next byte after the SS3.

  3. keithw commented on Apr 16, 2012

    @keithw
    MemberAuthor

    We are going to have to fix this anyway, because xterm uses SS3 to signal F1-F4.

  4. anarcat commented on May 12, 2016

    @anarcat

    for the record, i do not believe this is fixed at all. but this seems to be tracked in #178...

  5. tsmithe commented on Sep 16, 2016

    @tsmithe

    If this is indeed tracked in #178, then the work-around suggested there does not seem to work for me. I also do not believe that this is fixed.

  6. added a commit that references this issue on Jul 18, 2026
    c15d3d0
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions