macvim-dev / macvim

Vim - the text editor - for macOS
https://macvim.org
Vim License
7.5k stars 681 forks source link

Terminal mode buffers do not implement Xterm control sequences to change cursor shape correctly #1215

Open michaelscarpa opened 2 years ago

michaelscarpa commented 2 years ago

Describe the bug According to the VIM documentation in terminal.txt under terminal-cursor-style:

By default the cursor in the terminal window uses a not blinking block. The normal xterm escape sequences can be used to change the blinking state and the shape. Once focus leaves the terminal window Vim will restore the original cursor.

These control sequences are defined as follows (source: XTerm Control Sequences ):

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.

However, trying these in a terminal inside the GUI of MacVim does not work.

To Reproduce Detailed steps to reproduce the behavior:

  1. Run mvim --clean
  2. Type :terminal to create a new terminal emulator buffer
  3. Type any of the following commands and press enter:
    • printf '\e[1 q' should turn the cursor into a blinking block, which works;
    • printf '\e[2 q' should turn the cursor into a steady block, which works;
    • printf '\e[3 q' should turn the cursor into a blinking underline, instead the cursor turns invisible;
    • printf '\e[4 q' should turn the cursor into a steady underline, instead the cursor turns invisible;
    • printf '\e[5 q' should turn the cursor into a blinking bar, instead the cursor turns invisible;
    • printf '\e[6 q' should turn the cursor into a steady bar, instead the cursor turns invisible.

Expected behavior The same steps executed in gvim on Kubuntu 18.04 all work as expected, changing the cursor shapes as prescribed by the definition of the control sequences cited above.

Environment (please complete the following information):