hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Cursor change on bell

Open jbergstroem opened this issue 10 years ago • 9 comments

If I change default cursor and hit bell (tab or w/e) it switches to block:

This is a23022d5e0a7b9d04552337f057a4ac9489b033b built/run on Sierra.

jbergstroem avatar Aug 29 '16 19:08 jbergstroem

I'm also experiencing this bug.

robindboer avatar Sep 04 '16 20:09 robindboer

I can have a look at this one.

maxdeviant avatar Oct 02 '16 04:10 maxdeviant

@robindboer Are you on Sierra as well? I haven't upgraded yet, so I'm wondering if the issue is specific to Sierra.

maxdeviant avatar Oct 02 '16 04:10 maxdeviant

@maxdeviant I'm on Sierra but I have also experienced this issue on El Capitan. Thanks for having a look at this issue. Looking forward to the solution.

robindboer avatar Oct 02 '16 10:10 robindboer

I'm able to reproduce consistently in zsh on OSX El Capitan.

maxdeviant avatar Oct 03 '16 02:10 maxdeviant

The problem appears to be somewhere within hterm, but I have yet to track it down.

If you unfocus and then refocus the pane, the cursor will change back to the config value, ~~since we call this.term.setCursorShape(nextProps.cursorShape); upon receiving props.~~

Looking inside of the node_modules/hterm-umdjs/dist/index.js, there are some places where it sets the cursor shape by itself:

hterm.VT.OSC['50']:

/**
 * Set the cursor shape.
 *
 * Parameter is expected to be in the form "CursorShape=number", where number is
 * one of:
 *
 *   0 - Block
 *   1 - I-Beam
 *   2 - Underline
 *
 * This is a bit of a de-facto standard supported by iTerm 2 and Konsole.  See
 * also: DECSCUSR.
 *
 * Invalid numbers will restore the cursor to the block shape.
 */
hterm.VT.OSC['50'] = function(parseState) {
  var args = parseState.args[0].match(/CursorShape=(.)/i);
  if (!args) {
    console.warn('Could not parse OSC 50 args: ' + parseState.args[0]);
    return;
  }

  switch (args[1]) {
    case '1':
      this.terminal.setCursorShape(hterm.Terminal.cursorShape.BEAM);
      break;

    case '2':
      this.terminal.setCursorShape(hterm.Terminal.cursorShape.UNDERLINE);
      break;

    default:
      this.terminal.setCursorShape(hterm.Terminal.cursorShape.BLOCK);
  }
};

hterm.VT.CSI[' q']:

/**
 * Set cursor style (DECSCUSR, VT520).
 *
 *   0 - Blinking block.
 *   1 - Blinking block (default).
 *   2 - Steady block.
 *   3 - Blinking underline.
 *   4 - Steady underline.
 */
hterm.VT.CSI[' q'] = function(parseState) {
  var arg = parseState.args[0];

  if (arg == '0' || arg == '1') {
    this.terminal.setCursorShape(hterm.Terminal.cursorShape.BLOCK);
    this.terminal.setCursorBlink(true);
  } else if (arg == '2') {
    this.terminal.setCursorShape(hterm.Terminal.cursorShape.BLOCK);
    this.terminal.setCursorBlink(false);
  } else if (arg == '3') {
    this.terminal.setCursorShape(hterm.Terminal.cursorShape.UNDERLINE);
    this.terminal.setCursorBlink(true);
  } else if (arg == '4') {
    this.terminal.setCursorShape(hterm.Terminal.cursorShape.UNDERLINE);
    this.terminal.setCursorBlink(false);
  } else {
    console.warn('Unknown cursor style: ' + arg);
  }
};

I'm not fully sure what these do, and am having trouble figuring out if they are actually called at all, but they do seem like primary suspects for this bug.

maxdeviant avatar Oct 03 '16 03:10 maxdeviant

Interestingly enough, it seems like hterm.Terminal.prototype.setCursorShape is only called once during runtime. When the cursor changes to BLOCK in the repro case, that method is not fired 😐

maxdeviant avatar Oct 03 '16 03:10 maxdeviant

I am also experiencing this issue. One detail though, if you unfocus the window, then refocus it, the cursor will change back.

I may have time to look into it, but I can't make any promises. 😄

catskull avatar Oct 18 '16 21:10 catskull

Encounter this issue on macOS Sierra and Hyper 0.8.3.873, I change cursor shape to BEAM in hyper.js but it sometime still block

se77en avatar Dec 05 '16 09:12 se77en