Skip to content
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

Tentative request: Add themeing support to menuconfig #52

Closed
pinkfluid opened this issue Aug 27, 2018 · 12 comments
Closed

Tentative request: Add themeing support to menuconfig #52

pinkfluid opened this issue Aug 27, 2018 · 12 comments

Comments

@pinkfluid
Copy link
Contributor

This is my last request, I promise :)

It would be nice if it was possible to change the color scheme of menuconfig. I'm not exactly sure what would be the best way to do it, but here are a couple options that come to mind:

  • environment variable
  • command line
  • config file
  • comments in the kconfig file

The first 3 are self explanatory. The last option, could be something like Vim modeline that allows settings things like TAB size from the Kconfig file comments, for example:

# $menuconfig: separator=bold_black_on_yellow,standout
# $menuconfig: frame=black_on_yellow,standout;style=black on white;...

config TEST
     bool "A"
...

The above color definition syntax is somewhat loosely resembling python blessings (https://github.com/erikrose/blessings). The definition after "," is the 4th column for _style().

If there's no plans for this whatsoever, please close the issue :)

@pinkfluid
Copy link
Contributor Author

A 5th option would be to do it programmatically from a python script (for example, by allowing to override the _init_styles() function)

@ulfalizer
Copy link
Owner

6th option might be to make the default less ugly. I did my best with it, but I'm not exactly Rembrandt. That yellow color in particular probably isn't the prettiest thing in the world...

If someone comes up with a nicer color scheme (or other UI improvement), I'm happy to take it in. Not sticking to just the predefined colors might help too.

The C menuconfig gets decent looks from using lxdialog, but I don't like how it wastes terminal space, and resizing is super janky (including a segfault if you accidentally make the window too small).

@pinkfluid
Copy link
Contributor Author

I don't think it's ugly, actually it's pretty decent even for Rembrandt standards.

The problem is that when I present this to other people they expect the ctools "kconfig" theme. So I was hoping to customize it with colors that are more in-line with the project so instead of a "uh, huh... why is it yellow?" questions I would get more "Oh, cool" reactions :)

It's not super important, so if you think it's pointless to have, please close the issue.

@ulfalizer
Copy link
Owner

I tried to go for the make menuconfig colors at first, but iirc I ran into color clashes due to the more compact layout.

Could you try tweaking the colors manually in _init_styles() and seeing if you can come up with something more make menuconfig-like that looks nice? Once we know that it's possible, I could try to come up with some theming thing.

@ulfalizer
Copy link
Owner

Search for "predefined" in https://docs.python.org/3/library/curses.html to see the list of predefined colors.

Might be able to use curses.init_color() to get custom colors, though it's terminal-dependent (should check curses.can_change_color() in that case too).

@pinkfluid
Copy link
Contributor Author

I will give it a shot.

I thought init_color() was only for RGB-type colors (some terminals do support that). I might try with the standard 16 colors at first, see how far I get.

@pinkfluid
Copy link
Contributor Author

Ok, this is what I came up with. Frankly, it looks more like Norton Commander than lxdialog :)

As you said, it's really hard to match the lxdialog scheme because of the borders and all that.

Anyway, here's the patch:

diff --git a/menuconfig.py b/menuconfig.py
index 2166787..266578e 100755
--- a/menuconfig.py
+++ b/menuconfig.py
@@ -184,7 +184,7 @@ def _init_styles():
 
     # Separator lines between windows. Also used for the top line in the symbol
     # information dialog.
-    _SEPARATOR_STYLE          = _style(curses.COLOR_BLACK, curses.COLOR_YELLOW, BOLD,            curses.A_STANDOUT)
+    _SEPARATOR_STYLE          = _style(curses.COLOR_WHITE, curses.COLOR_CYAN,   BOLD,            curses.A_STANDOUT)
 
     # Edit boxes
     _INPUT_FIELD_STYLE        = _style(curses.COLOR_WHITE, curses.COLOR_BLUE,   curses.A_NORMAL, curses.A_STANDOUT)
@@ -192,25 +192,25 @@ def _init_styles():
     # List of items, e.g. the main display
     _LIST_STYLE               = _style(curses.COLOR_BLACK, curses.COLOR_WHITE,  curses.A_NORMAL                   )
     # Style for the selected item
-    _LIST_SEL_STYLE           = _style(curses.COLOR_WHITE, curses.COLOR_BLUE,   curses.A_NORMAL, curses.A_STANDOUT)
+    _LIST_SEL_STYLE           = _style(curses.COLOR_WHITE, curses.COLOR_BLUE,   BOLD           , curses.A_STANDOUT)
 
     # Like _LIST_(SEL_)STYLE, for invisible items. Used in show-all mode.
     _LIST_INVISIBLE_STYLE     = _style(curses.COLOR_RED,   curses.COLOR_WHITE,  curses.A_NORMAL, BOLD             )
     _LIST_INVISIBLE_SEL_STYLE = _style(curses.COLOR_RED,   curses.COLOR_BLUE,   curses.A_NORMAL, curses.A_STANDOUT)
 
     # Help text windows at the bottom of various fullscreen dialogs
-    _HELP_STYLE               = _style(curses.COLOR_BLACK, curses.COLOR_WHITE,  BOLD                              )
+    _HELP_STYLE               = _style(curses.COLOR_CYAN, curses.COLOR_BLUE,    BOLD                              )
 
     # Top row in the main display, with the menu path
-    _PATH_STYLE               = _style(curses.COLOR_BLACK, curses.COLOR_WHITE,  BOLD                              )
+    _PATH_STYLE               = _style(curses.COLOR_CYAN, curses.COLOR_BLUE,    BOLD                              )
 
     # Symbol information text
     _INFO_TEXT_STYLE          = _LIST_STYLE
 
     # Frame around dialog boxes
-    _DIALOG_FRAME_STYLE       = _style(curses.COLOR_BLACK, curses.COLOR_YELLOW, BOLD,            curses.A_STANDOUT)
+    _DIALOG_FRAME_STYLE       = _style(curses.COLOR_WHITE, curses.COLOR_CYAN,   BOLD,            curses.A_STANDOUT)
     # Body of dialog boxes
-    _DIALOG_BODY_STYLE        = _style(curses.COLOR_WHITE, curses.COLOR_BLACK,  curses.A_NORMAL                   )
+    _DIALOG_BODY_STYLE        = _style(curses.COLOR_CYAN, curses.COLOR_BLUE,    BOLD                              )
 
 
 #

And a screenshot:
2018-08-27-201431_562x362_scrot

@ulfalizer
Copy link
Owner

Doesn't look all too shabby. Bit more relaxed to compared to the other theme.

Maybe I could add it as an alternate theme, enabled in the environment via MENUCONFIG_THEME=aquatic or the like. I'm a bit scared of adding a fine-grained styling mechanism, in case I later decide to make significant changes to the interface (no such plans at the moment, but you never know).

I like that you bolded the selected item. Might steal that for the other theme as well.

Here's how it comes out on gnome-terminal:

skarmbild fran 2018-08-27 22-25-56

@pinkfluid
Copy link
Contributor Author

Actually looks OK even on gnome terminal.

Regarding fine-grained styling -- I believe it's up to the user to maintain the compatibility with newer versions. If they choose to upgrade kconfiglib, they should be aware that their custom theme may require tweaking. In any case, reverting to the default theme should be straightforward. But again, this is a nice to have feature, but far from being essential.

Truthfully, the only issue with the yellow theme is that people usually associate kconfig with the lxdialog color scheme and think that I purposedly changed it to yellow for some reason :)

@ulfalizer
Copy link
Owner

Added the new theme: 84bd863

I tweaked the colors for dialog boxes and the jump-to dialog to make them a bit more readable. Check if looks alright.

Got lazy and went for a hardcoded version for now. Might add some external styling mechanism later, if more styles show up.

@pinkfluid
Copy link
Contributor Author

Looks great, thank you!

You can close this issue.

@ulfalizer
Copy link
Owner

Alright, closing. Thanks!

Pushed out a new release with the theme too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants