Expose original colour metadata/palette indices to users
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libvterm |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
This patch essentially implements this blueprint:
https:/
Note that my design decision was to not change the size of the VTermColor struct, which before (including alignment) was four bytes. Correspondingly, as of this patch, VTermColor has become a union and either contains a palette index or an RGB colour. All colours can always be converted to RGB colours by either calling
void vterm_state_
or
void vterm_screen_
depending on the interface that is being used. If this function is called before any VTermColor
is accessed, the behaviour of libvterm should not change.
Note that VTermColor also exposes metadata regarding whether the given colour is the default foreground/
[PATCH] Expose original colour indices through `VTermColor`
https:/
Changed in libvterm: | |
status: | Fix Committed → Fix Released |
Overall this is looking very nice - I like that you've nicely documented the new functions in comments, and updated the tests.
A couple of small points on API naming though:
* I dislike the name `get` in `vterm_ state_get_ rgb_color( )` (and its `screen` variant). A `get` function really ought to have no mutation side-effect, other than perhaps on a pointer argument that the caller didn't first need to initialise. I think a better name for this would probably draw attention to its conversion nature, maybe one of
void vterm_state_ color_to_ rgb(); convert_ color_rgb( ); convert_ color_to_ rgb();
void vterm_state_
void vterm_state_
Either that, or change its behaviour so it takes a `const VTermColor` and returns its result by side-effecting another `VTermColor` which might just be a copy. That feels inefficient though.
* Since it's now an API-exposed function, `vterm_ color_equal( )` should have a verb in its name to be properly named; I'd suggest
bool vterm_color_ is_equal( ...);
One other point - I expect that now you should be able to delete the `fg_index` and `bg_index` members of VTermState and associated management code, without breaking anything.