diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-17 19:28:40 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-17 19:28:40 +0100 |
commit | e98d0ad1dc51050eb17120f835847d55950c2a0b (patch) | |
tree | dfe6848c19bffbad3f24159aa6fe0af0355c6048 /src/config | |
parent | 89d1bdc04343dac1d09282424f4b8538f1db5ad3 (diff) | |
download | chawan-e98d0ad1dc51050eb17120f835847d55950c2a0b.tar.gz |
term: fix coloring mess
Until now, the config file required manual adjustment for the output to look bearable on terminals colored differently than {bgcolor: black, fgcolor: white}. Also, it only detected RGB when COLORTERM was set, but this is not done by most (any?) terminal emulators (sad). To improve upon the situation, we now query the terminal for some attributes on startup: * OSC(10/11, ?) -> get the terminal's bg/fgcolor * DCS(+, q, 524742) -> XTGETTCAP for the "RGB" capability (only supported by a few terminals, but better than nothing) * Primary device attributes -> check if ANSI colors are supported, also make sure we don't block indefinitely even if the previous queries fail If primary device attributes does not return anything, we hang until the user types something, then notify the user that something went wrong, and tell them how to fix it. Seems like an OK fallback. (The DA1 idea comes from notcurses; since this is implemented by pretty much every terminal emulator, we don't have to rely on slow timing hacks to skip non-supported queries.)
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/config.nim | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/config/config.nim b/src/config/config.nim index c66e7883..678f7f7b 100644 --- a/src/config/config.nim +++ b/src/config/config.nim @@ -117,8 +117,9 @@ type minimum_contrast* {.jsgetset.}: int32 force_clear* {.jsgetset.}: bool set_title* {.jsgetset.}: bool - default_background_color* {.jsgetset.}: RGBColor - default_foreground_color* {.jsgetset.}: RGBColor + default_background_color* {.jsgetset.}: Opt[RGBColor] + default_foreground_color* {.jsgetset.}: Opt[RGBColor] + query_da1* {.jsgetset.}: bool Config* = ref ConfigObj ConfigObj* = object |