From e98d0ad1dc51050eb17120f835847d55950c2a0b Mon Sep 17 00:00:00 2001 From: bptato Date: Sat, 17 Feb 2024 19:28:40 +0100 Subject: 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.) --- res/config.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'res') 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:' -- cgit 1.4.1-2-gfad0