Support for 24 bit colors

17 views
Skip to first unread message

Ludovico Gerardi

unread,
Oct 4, 2024, 11:41:06 AM10/4/24
to Newsboat project
Hello,

I was wondering if there are any plans to support 24 bit colors (truecolor/
direct color, whatever it's called) in the configuration. I quickly went through
the GitHub issues and the mailing list but I couldn't find any reference to
this.

I'm not very familiar with the codebase but I think that the necessary steps to
take would be to change the is_valid_color function in utils.rs to allow for
specifying the hex code or the three RGB values, and also to change the stfl_style
function in style.c of the stfl library (I'm excluding tests, documentation
etc.)

I'd be interested in giving this feature a shot, but I wanted to ask if it's
perhaps better to focus on transitioning to Rust before starting to work on it.

Also another question, related to the feature itself: should Newsboat check
whether the used terminal has support for the full RGB spectrum of colors or let
ncurses (or its Rust replacement) handle that?
--
Regards,
Ludovico Gerardi

Alexander Batischev

unread,
Oct 4, 2024, 1:07:11 PM10/4/24
to Ludovico Gerardi, Newsboat project
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,

On Fri, Oct 04, 2024 at 03:41:19PM +0000, Ludovico Gerardi wrote:
>I was wondering if there are any plans to support 24 bit colors
>(truecolor/ direct color, whatever it's called) in the configuration.

I think there were some questions here and there. I'm ok with adding it.

>I'm not very familiar with the codebase but I think that the necessary
>steps to take would be to change the is_valid_color function in
>utils.rs to allow for specifying the hex code or the three RGB values,
>and also to change the stfl_style function in style.c of the stfl
>library (I'm excluding tests, documentation etc.)

Yeah, I think that's right.

>I'd be interested in giving this feature a shot, but I wanted to ask if
>it's perhaps better to focus on transitioning to Rust before starting
>to work on it.

Well, it depends on how much you want this feature :)

On the one hand, STFL is in limbo: almost nobody picked our fork.
Homebrew (the unofficial package manager for macOS) actually removed
STFL instead. It looks like any changes to STFL are unlikely to reach
users, so it might be a waste of time to improve it any further. (Hope
this doesn't reek of FUD; it's only my opinion.)

On the other hand, we're nowhere near to porting our TUI to Rust.
Actually, my plan was to migrate all the other code, and then
straight-up rewrite the TUI in some other library. The rewrite is
necessary because TUI drives the entire application. New library will
probably bring some changes to how the event loop works and how events
are handled, so when that happens, I want to be in a position where
I can safely refactor the rest of the app to suit the new library. Thus,
the other code should be ported first.

The "rewrite" might be a scary word, but I actually implemented a TUI
mockup a while ago[1] using tui-rs, and Dennis did too[2] with ratatui
(the successor to tui-rs). Judging by my notes, tui-rs wasn't quite
feature-complete for our needs; I'm not sure about ratatui. If we end up
using ratatui, then your feature requires will probably be fulfilled
without any coding, because ratatui already supports RGB colors[3].
We'll just have to pick an appropriate backend.

1. https://github.com/Minoru/newsboat-tui-rs/
2. https://github.com/dennisschagt/ratatui-newsboat-mockup
3. https://docs.rs/ratatui/latest/ratatui/style/enum.Color.html#variant.Rgb

>Also another question, related to the feature itself: should Newsboat check
>whether the used terminal has support for the full RGB spectrum of colors or let
>ncurses (or its Rust replacement) handle that?

In case of ncruses (which underlies STFL), it's probably us who should
do the check; at least I couldn't find the function that will do it for
us. There's `has_colors()`, but it doesn't distinguish between the
default 16-color mode and the truecolor modes. Perhaps we have to work
with terminfo directly?

In case of Rust crates, it depends. With tui-rs (and probably ratatui),
it depends on the backend that's used to actually draw on the screen.
One such backend is ncurses, which brings us back to square 1. Other
backends (like wezterm or termion) probably handle it by themselves (but
I didn't check).


Apropos to all this, I have to say I didn't enjoy the experience of
shuffling review comments between here and GitHub. I want GitHub to be
a single source of truth about decisions made during reviews, because
I sometimes re-read those discussions to recall the history. Given my
experience "moving" from akrennmair/newsbeuter to newsboat/newsboat, my
tolerance for moves is very low. Currently I'm waiting for ForgeFed to
become functional before making the next jump. I know other projects
work over email, and I know about SourceHut, but this is how Newsboat
works right now. What I'm trying to say is: "perfect" changes are okay,
but anything that requires review back-and-forth probably won't get any
engagement from me.

- --
Regards,
Alexander Batischev

PGP key 356961A20C8BFD03
Fingerprint: CE6C 4307 9348 58E3 FD94 A00F 3569 61A2 0C8B FD03

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEzmxDB5NIWOP9lKAPNWlhogyL/QMFAmcAILUACgkQNWlhogyL
/QONzw//bGOS8Q8k2vct1uYdvITNGxl8YxgvQYOh9ADel9vCVgt6NY8GapIuDYPX
iD6yM0GzXyS0CLwJWBE0AhkLBCeIBetdgEEwy4MN6CKAqZ/1FqXILd9VyGILUxVx
pDG3mayg+geAs08w8wr/5sFeOnDfC5UsIGySpqXT5ff+Arf1qVlMzx9fDMA98gu5
O9hAV2rzZwFgWQpNYVSxUPf+8TTCEzXZvUKZXz5AhLNXfgOhrBWY4Av8D7/lRl1+
MsyMuiEqO2msl9WeKIhdl8RCrZnm9ei4GbmmDzpZIKDxxqWgcrII5uRU9KcgA801
/7ms0Bvm5pJWX1tSco1Gze4woCveaUuIXMt19EIgo78TS1o5EHxSw87AJ3+Aktz+
AGvaTkuWNGnA6SFpZzRKxA6WIjtJJb0xqbW03F+QDSR0o0lljncf2QsYtzqLiw5r
j3jAaFwQmlqi/Xh1vGLJLuy6+cChHFnZWAvdXlOT0d0vaW1l/Cbk+9Jp/73HIaZv
gvrSdZv8w0NNxoeP3iE4vHquKPNPYGwY8FK+t5Fo0hRLXc5bL69O6hONNRsgOOXq
1olnnNXRn5NORCuqhhecvYIyFpq6k0tohLG5CtWDKI3kd/vx9xx/wpMkDhYql9Bx
+zDaa6PkHt3niAqkKJAxs1c6kqz0SOt27AGujTUOY0jx3D4NZQQ=
=uuUE
-----END PGP SIGNATURE-----
Reply all
Reply to author
Forward
0 new messages