From bf407654df1081e7fbc3f876288cc275092cf549 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 14 Mar 2019 15:26:24 +0100 Subject: menuconfig: Put two blank lines between top-level functions Be consistent with the other utilities. --- menuconfig.py | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 3 deletions(-) (limited to 'menuconfig.py') diff --git a/menuconfig.py b/menuconfig.py index d7661b4..b978e08 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -331,6 +331,7 @@ _STYLE_STD_COLORS = { "brightpurple": curses.COLOR_MAGENTA + 8, } + def _rgb_to_6cube(rgb): # Converts an 888 RGB color to a 3-tuple (nice in that it's hashable) # representing the closests xterm 256-color 6x6x6 color cube color. @@ -346,11 +347,13 @@ def _rgb_to_6cube(rgb): # 48 is the middle ground between 0 and 95. return tuple(0 if x < 48 else int(round(max(1, (x - 55)/40))) for x in rgb) + def _6cube_to_rgb(r6g6b6): # Returns the 888 RGB color for a 666 xterm color cube index return tuple(0 if x == 0 else 40*x + 55 for x in r6g6b6) + def _rgb_to_gray(rgb): # Converts an 888 RGB color to the index of an xterm 256-color grayscale # color with approx. the same perceived brightness @@ -368,11 +371,13 @@ def _rgb_to_gray(rgb): # Clamp the index to 0-23, corresponding to 232-255 return max(0, min(index, 23)) + def _gray_to_rgb(index): # Convert a grayscale index to its closet single RGB component return 3*(10*index + 8,) # Returns a 3-tuple + # Obscure Python: We never pass a value for rgb2index, and it keeps pointing to # the same dict. This avoids a global. def _alloc_rgb(rgb, rgb2index={}): @@ -406,6 +411,7 @@ def _alloc_rgb(rgb, rgb2index={}): return color_index + def _color_from_num(num): # Returns the index of a color that looks like color 'num' in the xterm # 256-color palette (but that might not be 'num', if we're redefining @@ -431,6 +437,7 @@ def _color_from_num(num): return _alloc_rgb(_gray_to_rgb(num - 232)) + def _color_from_rgb(rgb): # Returns the index of a color matching the 888 RGB color 'rgb'. The # returned color might be an ~exact match or an approximation, depending on @@ -477,9 +484,6 @@ def _color_from_rgb(rgb): return best -# Dictionary mapping element types to the curses attributes used to display -# them -_style = {} def _parse_style(style_str, parsing_default): # Parses a string with '=