dgkf / dgkf/R

Try to detect terminal theme when choosing highlight colors

Open
#25 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
145
Forks
5
PR merge metrics
No merged PRs in 30d

Description

This is totally cosmetic, but I thought it would be nice to try to determine whether a terminal has a light or dark theme before doing any highlighting.

Currently, the theme is really only functional with a dark background as white is used as a foreground color.

Some options:
- [`termbg`](https://crates.io/crates/termbg)
- [`terminal-light`](https://crates.io/crates/terminal-light)
- Just use the ansi reverse style for any uncolored text, then hope that there's enough contrast in the terminal colors on either background to be readable

It seems like any tool that tries to automatically detect the background color has a few limitations
1. it might not be ubiquitous and will only work on specific terminals, meaning we probably want a safer default anyways
2. it is slow (~10ms) as it needs to pass an ansi control sequence to the terminal and then read back the response, meaning that we want to do this sparingly (perhaps only on top-level repl expression evaluation)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.