vimterminalconsoleansi-escapevt100

What does the ESC [?1c escape sequence do on the Linux console?


While trying to make vim work correctly on my operating system's console, I noticed it writes to stdout the following escape sequence before scrolling: \x1b[?1c.

The problem is I wasn't able to find anywhere what that specific sequence means. I've checked:

Can anybody help me solve this mystery?

P.S. In case some additional context might help, the sequence is used in the following context:

\x1b[?25l\x1b[?1c\x1b[3;24r\x1b[3;1H\x1b[L


Solution

  • Use the source. Linux kernel handles \x1b[?1c in this chunk:

        case 'c':
            if (vc->vc_ques) {
                if (vc->vc_par[0])
                    vc->vc_cursor_type = vc->vc_par[0] | (vc->vc_par[1] << 8) | (vc->vc_par[2] << 16);
                else
                    vc->vc_cursor_type = cur_default;
                return;
            }
            break;
    

    and from context, you may understand that vc_par is an array of the parameters (which is only 1 in this case). So it is setting vc_cursor_type to 1. According to the documentation for Linux soft cursor, that makes the cursor invisible:

    first Parameter
    
        specifies cursor size:
    
        0=default
        1=invisible
        2=underline,
        ...
        8=full block
        + 16 if you want the software cursor to be applied
        + 32 if you want to always change the background color
        + 64 if you dislike having the background the same as the
             foreground.
    

    In context, vim is doing this right after \x1b[?25l (make the cursor hidden) and before changing the scrolling region \x1b[3;24r (which would move the cursor), and this sequence is just added insurance that there will be no cursor flashing as the sequence is executed on the Linux console.

    Of the links cited in the example, only console_codes(4) is relevant. It does not appear there because the soft cursor feature was added later than the original manual page, and it did not occur to others later when revising the manual page. (Actually no one's done any recent improvements to it, as noted in a recent discussion).