Compare commits

..

No commits in common. "e0177d0e101b2bbed7d4fb43ffdef0dc6b847855" and "6655fd097af828ebe6506fe820d14283ae95f59a" have entirely different histories.

1 changed files with 7 additions and 16 deletions

View File

@ -19,10 +19,9 @@ class CliMenuHeader:
class CliMenuOption:
"""Hold a menu option"""
def __init__(self, text, num, item=None):
def __init__(self, text, num):
self.text = text
self.num = num
self.item = item
self.focusable = True
@ -97,27 +96,19 @@ class CliMenu:
for option in options:
self.add_option(option)
def add_header(self, title, indent=True):
def add_header(self, title, indent=False):
for text in title.split('\n'):
self._items.append(CliMenuHeader(text, indent=indent))
self._items.append(CliMenuHeader(text))
def add_option(self, text, item=None):
self._items.append(CliMenuOption(text, self._item_num, item=item))
def add_option(self, text):
self._items.append(CliMenuOption(text, self._item_num))
self._item_num += 1
def get_selection(self):
if not self._ran:
self._run()
item = self._items[self._pos]
return (item.num, item.item)
def get_selection_num(self):
return self.get_selection()[0]
def get_selection_item(self):
return self.get_selection()[1]
return self._items[self._pos].num
def cursor(self):
return '{} '.format(self._cursor)
@ -146,7 +137,7 @@ class CliMenu:
style = s.option_style
else:
if item.indent:
indent += ' ' * (self._header_indent + len(self._cursor) + 1)
indent += ' ' * self._header_indent
style = s.header_style
return Transformation([('', indent), (style, prefix + text)])