Skip to content

Conversation

@dabeibao
Copy link

The escape sequence is:
ESC[N q

N is between 0 and 6.

The escape sequence is:
    ESC[N q

N is between 0 and 6.
@achernya
Copy link
Collaborator

What is the context of this?

@dabeibao
Copy link
Author

dabeibao commented Oct 17, 2025

Please see the link:
https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797?permalink_comment_id=5165100#gistcomment-5165100

Many modern terminals (including Windows Terminal, mintty, etc.) support changing the cursor shape dynamically — and this pairs beautifully with Emacs Evil mode, so you can visually distinguish between Normal and Insert modes (like in Vim).

Normal mode:
图片

Insert mode:
图片

@achernya
Copy link
Collaborator

Is there any more authoritative documentation of these escape sequences?

@dabeibao
Copy link
Author

What about this: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html

Search 'CSI Ps SP q' in the page:

CSI Ps SP q
          Set cursor style (DECSCUSR), VT520.
            Ps = 0  ⇒  blinking block.
            Ps = 1  ⇒  blinking block (default).
            Ps = 2  ⇒  steady block.
            Ps = 3  ⇒  blinking underline.
            Ps = 4  ⇒  steady underline.
            Ps = 5  ⇒  blinking bar, xterm.
            Ps = 6  ⇒  steady bar, xterm.

@achimnol
Copy link

achimnol commented Nov 5, 2025

We have long standing PRs and issues for this feature.

/* cursor shape */
static void CSI_cursorshape( Framebuffer* fb, Dispatcher* dispatch )
{
int shape = dispatch->getparam( 0, -1 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm looking at the impl for Dispather::getparam and it looks like doesn't support returning values less than 1. But 0 is a valid cursor shape.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The defaultval should be 0.

@dabeibao
Copy link
Author

* [Apply Clang formatting to #1167 and resolve merge conflicts #1292](https://github.com/mobile-shell/mosh/pull/1292)

Seems this commit already implements it. But the title is somewhat misleading...

@eminence
Copy link
Member

Something's still not quite right when the terminal is reset. Try this:

printf '\x1b[6 q\x1bc'

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants