-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature/colormanager #221
base: dev
Are you sure you want to change the base?
feature/colormanager #221
Conversation
e13e238
to
388d101
Compare
95c6c61
to
ddd4e86
Compare
I'm not entirely sure what you mean by this. Are you asking whether colors such as |
Yes that is what I meant. I tend to answer "no" to that question though, as I don't think it is worth the effort to get a solid implementation for the little benefit of using #333333 instead of color252. |
Yeah, I think it's not necessary. Maybe one day but right now we don't need it. |
898eb38
to
64c0c1a
Compare
Apart from defining the default color designs for 8, 88 and 256 colors and squashing into 2 commits this PR should be ready to merge from my POV. Logging on a usual setup should be invisible on loglevel info and above other than for this startup message:
I figured it might be useful for users to always see it, although I can definitely lower it to debug instead. |
Sorry that this PR has been without comment for so long. I think I'm ready to merge this. |
80c8abf
to
a0bd108
Compare
@richrd If you don't want to merge this and the statusbar PR feel free to close them and I keep it somewhere local instead. |
a0bd108
to
a57608c
Compare
Not to merge right away, just a request for comments.The idea of the color manager is to never use raw curses color_pairs outside the manger itself but instead use config defined strings for color pairs.
Those can then be configured differently for 8, 88 or 256 colors.
defaults.json implements a basic set which can be modified individually by the user inside ~/.config/suplemon/suplemon-config.json.
A fallback to color_pair(0) is provided if Suplemon is running on a terminal without any kind of color support (e.g. vt220) or if the amount of color pairs requested is bigger than what the terminal provides.
The default config for 8 colors looks like this:
And the one for 256 colors like this:
The parser supports everything curses.COLOR_* and curses.A_* provides + direct integers in form of colo(u)r212 + the value "default" (terminal configured default values, e.g. semi-transparent or image backgrounds).
One of the open questions is if it is useful to use the hex2term color conversion to also allow hexencoded 24bit colors.I did not implement that right away because it would also need to make sure that every combination has enough contrast, e.g. fg != bg or contrast(fg, bg) > x and I am generally not sure if it is a useful feature to have.
Syntax highlighting (pygments and linelight) creates new color pairs on demand / reuses previously created color pairs by reusing the integer which is currently used for the curses.color_pair as identifier for the color manager.
As this branch requires PRs #216 and #217 I based it on a local dev-next branch but will rebase it once they are merged into dev.My current work for statusbar components is based on this branch because it allows to have a way more flexible color management, e.g. the user is able to define something like
Things to do:
maybe move config loading from ui.py into color_pairs.py (or config.py?)maybe move the whole setup_color() def to color_pairs.pybind to config event, update existing color pairs based on new configconvert basically all info logging to debugcolor_pairs.py: use white for self._invalid if available colors < 8ui.py + defaults.json: add bkgdset() for legend windowui.py: maybe completely remove self.limited_colorsviewer.py: for linelight return default editor fg instead of 0 (black) if nothing matchessolve the last FIXMEs and TODOs