Open akinomyoga opened 3 years ago
This is what other terminals do and I completely agree with this fix (though I think "steady block" is a typo of "blink block").
Woops, this is indeed a typo in the docs :+1:
@akinomyoga Just looked at the code - we have indeed no fixed default setting in the options for the cursor style, instead the setting gets used as initial value, but later changes overwrite that setting (with hardcoded 0|1 as BLINKING BLOCK).
@Tyriar To get rid of the hardcoded default I suggest to add the cursor style to DEC private modes in CoreService
, this way we can keep the option setting untouched and use it as default on DECSCUSR() or DECSCUSR(0) and reset.
Hey @jerch, I came from https://github.com/microsoft/vscode/issues/211394 - I've looked into this a bit and would like to work on this issue.
If I understand correctly, it seems that we want to add cursorStyle
in coreService.decPrivateModes
and use that as the terminal cursor, and use optionsService.options.cursorStyle
as the default value to revert to? What are your thoughts on adding a defaultCursor variable in optionsService.options
instead? Thanks in advance!
I'm unfamiliar with the codebase of xterm.js
, but I don't think the cursor style should be stored in decPrivateModes
. By its name and its members, it's obvious that decPrivateModes
contains (a part of) the states of DEC Modes, which are set by the control functions DECSET
and DECRST
. DECSCUSR
is unrelated to DECSET
/DECRST
.
I also think the cursor set by DECSCUSR
is not just cursorStyle
in the codebase, but both cursorStyle
and cursorBlink
should be considered here.
I think it is natural to manage the current values of cursorStyle
and cursorBlink
along with isCursorHidden
above. I guess the optionsService.options
should contain the default values of cursorStyle
and cursorBlink
.
Record the initial cursorStyle in DEC?
@kevinc16 Sorry for the late response.
Yes you are right - we basically lack a separation of initial default state to current state, which makes it impossible to revert to the initial state since it is not preserved.
@akinomyoga Yepp, decPrivateModes
is meant as a stateholder of the currently active/inactive instance modes. This gets initialized during startup from the option's service, if there is a configurable option, otherwise from a hard-coded value.
To get things into perspective, we actually would need both for the full deal:
@Tyriar , am coming here from VSCode issue #211394
I am resuming work after a while as I was away.
I am proposing that we can update the InputHandler in Xterm.js to correctly handle DECSCUSR 0 by resetting the cursor to the user's preferred style. This ensures consistency with expected terminal behavior.
Would that be a good step? @Tyriar @jerch inputs will be appreciated.
@Arup-Chauhan yep
Hi @Tyriar , raised a draft PR to work on this, have some questions, please take a look, thanks!
This was first reported at https://github.com/akinomyoga/ble.sh/issues/95. In Visual Studio Code (VSCode), when a Bash plugin
ble.sh
is loaded in a Bash session, the cursor shape becomes alwaysBlock
regardless of the user setting of the cursor shape.This seems to be caused by the behavior of xterm.js for the control function DECSCUSR() (empty) and DECSCUSR(0) (0). I expect these parameters, empty and 0, change the cursor shape to the default one configured by the user, but, in xterm.js, empty and 0 are always treated as 1 (Blinking Block) which is just the default value for the user setting.
Behavior of other terminals
In all the other terminals that I tested (including Mintty, Alacritty, RLogin, GNOME Terminal (VTE), and Windows Terminal), when the user changed the default cursor shape from Block to another, DECSCUSR() and DECSCUSR(0) change the cursor shape to the user-configured default rather than to Block. The behavior can be checked with the following commands after the user default is changed.
I couldn't check xterm's behavior because I don't know how to change the default value for the cursor shape in xterm.
We can also find a related discussion in a code comment of VTE:
In the original DEC implementation of
DECSCUSR
, the parametersempty
and0
meant the block style, but I guess it is just because the default cursor shape of VT series couldn't be configured so was always the block style (but maybe VT allowed some user configuration, see the previous item of the VTE comment). Anyway, empty and 0 typically meant the default for some other control functions, so I believe it is a natural guess that empty and 0 for DECSCUSR are also intended for the default cursor shape.Note on ZDM
Here's a related note on the mode
ZDM
from @jerch:Fix
From the same comment by @jerch,
This is what other terminals do and I completely agree with this fix (though I think "steady block" is a typo of "blink block").