about summary refs log tree commit diff stats
path: root/res
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-02-17 19:28:40 +0100
committerbptato <nincsnevem662@gmail.com>2024-02-17 19:28:40 +0100
commite98d0ad1dc51050eb17120f835847d55950c2a0b (patch)
treedfe6848c19bffbad3f24159aa6fe0af0355c6048 /res
parent89d1bdc04343dac1d09282424f4b8538f1db5ad3 (diff)
downloadchawan-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 'res')
-rw-r--r--res/config.toml5
1 files changed, 3 insertions, 2 deletions
diff --git a/res/config.toml b/res/config.toml
index 307e974b..54f74729 100644
--- a/res/config.toml
+++ b/res/config.toml
@@ -63,8 +63,9 @@ double-width-ambiguous = false
 minimum-contrast = 100
 force-clear = false
 set-title = true
-default-background-color = "#000000"
-default-foreground-color = "#FFFFFF"
+default-background-color = "auto"
+default-foreground-color = "auto"
+query-da1 = true
 
 [[omnirule]]
 match = '^ddg:'