-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Open
Description
Vim's automatic background color detection works in GUI mode, but not in a terminal.
On any xterm-compatible terminal, vim could detect the background color via terminal escapes (documented in http://invisible-island.net/xterm/ctlseqs/ctlseqs.html) and use that to automatically detect whether to use bg=dark
or bg=light
(by default or with :set bg&
).
To detect the background color:
- Include `\e]11;?\a' during terminal initialization.
- Asynchronously, when processing input, watch for the escape sequence
\e]11;COLOR\a
(or equivalent using OSC instead of\e]
for the escape, and ST or\e\\
instead of\a
for the terminator). If the COLOR portion matchesrgb:RRRR/GGGG/BBBB
where R, G, and B are hex digits, then compute the luminance of the RGB color and classify it as light/dark accordingly.
mgedmin, mjk, JohnStarich, adrian-martinez-dev, kevinlawler and 11 more
Metadata
Metadata
Assignees
Labels
No labels