[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Advice for supporting custom colors
From: |
Timothy Allen |
Subject: |
Re: Advice for supporting custom colors |
Date: |
Thu, 10 Jan 2019 13:11:18 +1100 |
User-agent: |
Evolution 3.30.3-1 |
On Wed, 2019-01-09 at 13:26 -0600, Bryan Christ wrote:
> The challenge with supporting larger colors is that the native output
> for libvterm is a ncurses WINDOW.
I guess this is not really the advice you wanted to hear, but:
- the curses API, when it supports colour, supports 8 colours
guaranteed plus maybe more depending on runtime checks
- the terminfo database fundamentally assumes a terminal supports a
fixed number of colours, with no runtime checks
Therefore, the most straight-forward solution is "only support 8
colours". It's simple, straight-forward, and you've already written the
code, so there's no additional effort.
If you want to do something a bit more dynamic, maybe you can choose a
$TERM based on the capabilities ncurses advertises, so if `COLORS ==
256` then you use `TERM=libvterm-256color` instead of `TERM=libvterm`.
Maybe you do this already when libvterm is used inside a terminal that
doesn't support colour at all, like vt100.
If you want to use one rich data model everywhere, and do best-effort
rendering depending on the capabilities of the outer terminal (like
tmux does), then you're going to need to use something other than an
ncurses WINDOW.