Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctrl+up/down don't scroll in zsh #181

Closed
Tyriar opened this issue Jul 13, 2016 · 13 comments
Closed

ctrl+up/down don't scroll in zsh #181

Tyriar opened this issue Jul 13, 2016 · 13 comments
Labels
type/bug Something is misbehaving

Comments

@Tyriar
Copy link
Member

Tyriar commented Jul 13, 2016

  1. Launch xterm with bash
  2. Open zsh
  3. ctrl+up/down scroll history, not scroll
@parisk
Copy link
Contributor

parisk commented Jul 13, 2016

Could this be a duplicate of #151?

@Tyriar
Copy link
Member Author

Tyriar commented Jul 13, 2016

I don't think ctrl+up/down is routed to the mouse wheel handler so probably not.

@apjanke
Copy link

apjanke commented Jul 20, 2016

It does look related to #151 and keypad cursor modes. Check out the xterm.js code for handling the up and down cursor keys.

        // up-arrow
        case 38:
          if (this.applicationCursor) {
            result.key = '\x1bOA';
            break;
          }
          if (ev.ctrlKey) {
            result.scrollDisp = -1;
          } else {
            result.key = '\x1b[A';
          }
          break;

The application-mode check is done first, and does an early return. The test for the Ctrl key is effectively inside the "normal keypad mode" branch of the logic. This also means that in application cursor keypad mode, the up/down arrow keys are being sent as plain cursor keys, with no modifier. In regular Xterm, modifiers take precedence over keypad mode.

@jerch
Copy link
Member

jerch commented Jul 21, 2016

Maybe fixed with #200, cant test it myself.

@parisk
Copy link
Contributor

parisk commented Jul 22, 2016

@Tyriar could you please test this out, since we merged #200?

@parisk parisk added the type/bug Something is misbehaving label Jul 22, 2016
@Tyriar
Copy link
Member Author

Tyriar commented Jul 22, 2016

Ctrl+up outputs ;5A and doesn't scroll, page down outputs ;5B and doesn't scroll. This is consistent with zsh under gnome-terminal so closing as fixed. Note that the scrolling situation is still bad, ctrl+shift+page up/down outputs ;6A and 6B with no scroll.

@Tyriar Tyriar closed this as completed Jul 22, 2016
@jerch
Copy link
Member

jerch commented Jul 22, 2016

ctrl+shift+page up/down outputs ;6A and 6B with no scroll.

Just installed zsh with and omz and can't reproduce it. I get the following on Ubuntu 14 with my laptop keyboard (same behavior/output for xterm and xterm.js-demo):
Shift+Ctrl+PageUp --> jump scroll up
Shift+Ctrl+PageDown --> jump scroll down
Shift+Ctrl+ArrowUp --> prints A
Shift+Ctrl+ArrowDown --> prints B

Tested again with gnome-terminal - Shift+Ctrl+ArrowUp scrolled instead of printing an 'A'. Did you mean PageUp/Down or ArrowUp/Down?
It seems gnome-terminal does not expose Shift+Ctrl+ArrowX to the PTY at all. If you run cat and press the keys xterm will print the corresponding escape sequence while gnome-terminal does not print anything. Might be a bug or a design decision in gnome-terminal.

@apjanke
Copy link

apjanke commented Jul 23, 2016

zsh with and omz

OMZ may change the behavior, because it defines additional key bindings which are not present in default zsh. Depending on what plugins you have loaded, it may add bindings for the Ctrl-Up and Ctrl-down character sequences.

It seems gnome-terminal does not expose Shift+Ctrl+ArrowX to the PTY at all. If you run cat and press the keys xterm will print the corresponding escape sequence while gnome-terminal does not print anything. Might be a bug or a design decision in gnome-terminal.

Design decision. Many terminal emulators and OSes "capture" some modified cursor key strokes and map them to scrolling or other navigation instead of passing them to the pty. This is analogous to the Ctrl-arrow scrolling behavior in xterm.js before #200. When comparing behavior for terminals, you need to check the key binding configuration. In gnome-terminal, look under Edit > Preferences > Shortcuts to see if a modified cursor key combination is mapped to a terminal action instead of being passed along to the PTY. Shift-Ctrl-Up and Shift-Ctrl-Down are bound to scrolling by default in gnome-terminal.

@Tyriar
Copy link
Member Author

Tyriar commented Jul 23, 2016

ctrl+shift+(most things) seems to be ignored by xterm as they are the only keybindings in vscode that seem to work when the focus is on the integrated terminal.

I'm thinking ctrl+shift+arrow should be handled by xterm.js, not the pty as @apjanke suggests.

@jerch
Copy link
Member

jerch commented Jul 23, 2016

Still not clear, why ctrl+shift+page up/down outputs ;6A and 6B for you. Seems the browser engine triggers the wrong keycode. Can you check the keycodes for ctrl+shift+page up/down? Do you have some keymapping active on X11 level?

@Tyriar
Copy link
Member Author

Tyriar commented Jul 24, 2016

var modifiers = ev.shiftKey << 0 | ev.altKey << 1 | ev.ctrlKey << 2 | ev.metaKey << 3;
// modifiers = 0b0101 = 5
...
result.key = '\x1b[1;' + (modifiers + 1) + 'D';
// result.key = '\x1b[1;6D';

I'm suggesting something like this:

var modifiers = ev.shiftKey << 0 | ev.altKey << 1 | ev.ctrlKey << 2 | ev.metaKey << 3;
if (modifiers === 5) {
  // handle any special keybindings like ctrl+shift+arrow/page up/down
  // don't set result.key so it's not send to pty
  return;
}

@jerch
Copy link
Member

jerch commented Jul 27, 2016

How about making this customizable?

@Tyriar
Copy link
Member Author

Tyriar commented Jul 27, 2016

Much easier to accomplish now that #186 is implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is misbehaving
Projects
None yet
Development

No branches or pull requests

4 participants