Reputation: 550
vim appears to send several strange (i.e. undocumented) escape sequences to the underlying terminal when using the inkpot scheme. I have been unable to match them to any VT-100 or ANSI escape codes; does anyone know what these sequences are?
^[[3231m
^[[4232m
^[[3130m
These sequences show up as invalid tokens in a terminal emulator I am responsible for, and I would like to add support for these sequences if I can find proper documentation for them.
The following terminal-related environment variables are set on the affected systems:
TERM=xterm
COLORTERM=
I have not tried any other settings for those two variables.
vim is version 7.2, but I have tried newer versions with same effect.
Thanks!
Upvotes: 1
Views: 715
Reputation: 224591
Does your terminal support 88- or 256-color mode? If so, you should probably use a TERM value like xterm-88color
or xterm-256color
instead of plain xterm
.
inkpot specifically disclaims support for terminals that only support 8/16 colors. From the top of the inkpot source:
" This should work in the GUI, rxvt-unicode (88 colour mode) and xterm (256 " colour mode). It won't work in 8/16 colour terminals.
The code that sets up the syntax coloring assumes that if the terminal does not support 88 colors, then it must support 256 colors. It does not try to provide fallback values for the case of 8 colors (e.g. when TERM=xterm
). Maybe it would be nice if inkpot issued an error message (and did not modify the color settings) if the terminal did not appear to have appropriate color support.
The control sequences you are seeing result from trying to generate an 8-color terminal color control sequence for a color number that is outside the 0–7 range of acceptable inputs for that type of terminal. So, these sequences are probably not valid, but they are not entirely intentional either (arising because inkpot assumes 256-color support, but the xterm
terminfo entry only knows how to handle basic 8-color support).
For example, inkpot sets the Normal
syntax foreground color to 79 on 88-color terminals; this is translated to 231 for non-88-color terminals (i.e. for 256-color terminals, but also for your 8-color xterm
).
When you try to format this out-of-range color number with TERM=xterm
, you get the result ^[[3231m
that you found:
% tput -T xterm setaf 231 | od -a
0000000 esc [ 3 2 3 1 m
0000007
(i.e. inserting 231
between ^[[3
and m
)
If you use xterm-256color
, you get a more normal looking result:
% tput -T xterm-256color setaf 231 | od -a
0000000 esc [ 3 8 ; 5 ; 2 3 1 m
0000013
(i.e. inserting 231
between ^[[38;5;
and m
)
Similarly, the Normal
syntax 88-color background color of 80 is translated to a 256-color value of 232 and produces the errant ^[[4232m
sequence for xterm
(but would produce the more reasonable ^[[48;5;232m
under xterm-256color
).
Upvotes: 4
Reputation: 196476
^[[3231m
looks a lot like a color definition done/gone wrong:
^[[32;31m
which wouldn't make much sense anyway.
Does it happen with a specific value for $TERM
or for any value? What Vim version? What terminal emulator are we talking about?
Upvotes: 0