Browse Source

Rename CliMenuTheme class parameters

The _style is redundant, as the whole theme is a collection of styles.
Headers are not really regarded as headers, more as text. Highlight
makes more sense as highlighted.

This is an API breaking change.
Sebastian Lohff 1 year ago
parent
commit
dc3b03c653
2 changed files with 10 additions and 10 deletions
  1. 9
    9
      clintermission/climenu.py
  2. 1
    1
      examples/basic_usage.py

+ 9
- 9
clintermission/climenu.py View File

@@ -45,10 +45,10 @@ class CliMenuStyle:
45 45
 
46 46
     Allows to select header, option and selected option color
47 47
     """
48
-    def __init__(self, option_style='', highlight_style='', header_style=''):
49
-        self.option_style = option_style
50
-        self.highlight_style = highlight_style
51
-        self.header_style = header_style
48
+    def __init__(self, option='', highlighted='', text=''):
49
+        self.option = option
50
+        self.highlighted = highlighted
51
+        self.text = text
52 52
 
53 53
 
54 54
 class CliSelectionStyle:
@@ -62,12 +62,12 @@ class CliSelectionStyle:
62 62
 
63 63
 class CliMenuTheme:
64 64
     BASIC = CliMenuStyle()
65
-    BASIC_BOLD = CliMenuStyle(header_style='bold', highlight_style='bold')
65
+    BASIC_BOLD = CliMenuStyle(text='bold', highlighted='bold')
66 66
     RED = CliMenuStyle('#aa0000', '#ee0000', '#aa0000')
67 67
     CYAN = CliMenuStyle('cyan', 'lightcyan', 'cyan')
68 68
     BLUE = CliMenuStyle('ansiblue', 'ansired', 'ansiblue')
69 69
     ANSI_CYAN = CliMenuStyle('ansicyan', 'ansibrightcyan', 'ansicyan')
70
-    BOLD_HIGHLIGHT = CliMenuStyle(header_style='bold', highlight_style='bold fg:black bg:white')
70
+    BOLD_HIGHLIGHT = CliMenuStyle(text='bold', highlighted='bold fg:black bg:white')
71 71
 
72 72
 
73 73
 class CliMenu:
@@ -173,14 +173,14 @@ class CliMenu:
173 173
 
174 174
             if ti.lineno == self._pos:
175 175
                 prefix += '{}{}'.format(self._cursor, self._option_prefix)
176
-                style = s.highlight_style
176
+                style = s.highlighted
177 177
             else:
178 178
                 prefix += ' ' * len(self._cursor) + self._option_prefix + ' ' * self._dedent_selection
179
-                style = s.option_style
179
+                style = s.option
180 180
         else:
181 181
             if item.indent:
182 182
                 indent += ' ' * (self._header_indent + len(self._cursor) + 1)
183
-            style = s.header_style
183
+            style = s.text
184 184
 
185 185
         items = [(s if s else style, t) for s, t in ti.fragments]
186 186
         prefix = self._transform_prefix(item, ti.lineno, prefix)

+ 1
- 1
examples/basic_usage.py View File

@@ -23,7 +23,7 @@ print()
23 23
 
24 24
 
25 25
 # --- custom themes ---
26
-style = CliMenuStyle(option_style='blue', highlight_style='cyan', header_style='green')
26
+style = CliMenuStyle(option='blue', highlighted='cyan', text='green')
27 27
 q = ["Foo", "Bar", "Baz"]
28 28
 m = CliMenu(q, "Choose in style:\n", style=style)
29 29
 print("You selected", m.get_selection())

Loading…
Cancel
Save