Compare commits
No commits in common. "b44a1f3543c2f8a304199bd59077c82643369a02" and "1a309d28c05e20d14eb4de9b6864daa952990f0c" have entirely different histories.
b44a1f3543
...
1a309d28c0
|
@ -132,15 +132,11 @@ class CliMenu:
|
||||||
for text in title.split('\n'):
|
for text in title.split('\n'):
|
||||||
self._items.append(_CliMenuHeader(text, indent=indent, style=style))
|
self._items.append(_CliMenuHeader(text, indent=indent, style=style))
|
||||||
|
|
||||||
def add_option(self, text, item=_EmptyParameter, disabled=False, style=None, highlighted_style=None):
|
def add_option(self, text, item=_EmptyParameter, style=None, highlighted_style=None):
|
||||||
if disabled:
|
|
||||||
# this is basically a text option and we just throw the item away
|
|
||||||
self.add_text(title=text, style=style)
|
|
||||||
else:
|
|
||||||
if item == _EmptyParameter:
|
if item == _EmptyParameter:
|
||||||
item = text
|
item = text
|
||||||
opt = _CliMenuOption(text, self._item_num, item=item, style=style, highlighted_style=highlighted_style)
|
self._items.append(_CliMenuOption(text, self._item_num, item=item,
|
||||||
self._items.append(opt)
|
style=style, highlighted_style=highlighted_style))
|
||||||
self._item_num += 1
|
self._item_num += 1
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -276,10 +272,6 @@ class CliMenu:
|
||||||
event.app.exit()
|
event.app.exit()
|
||||||
|
|
||||||
def _run(self):
|
def _run(self):
|
||||||
if self._item_num == 0:
|
|
||||||
self._success = False
|
|
||||||
return
|
|
||||||
|
|
||||||
self._preflight()
|
self._preflight()
|
||||||
|
|
||||||
class MenuColorizer(Processor):
|
class MenuColorizer(Processor):
|
||||||
|
@ -292,7 +284,6 @@ class CliMenu:
|
||||||
@self._kb.add('q', filter=~is_searching)
|
@self._kb.add('q', filter=~is_searching)
|
||||||
@self._kb.add('c-c')
|
@self._kb.add('c-c')
|
||||||
def quit(event):
|
def quit(event):
|
||||||
self._success = False
|
|
||||||
event.app.exit()
|
event.app.exit()
|
||||||
|
|
||||||
@self._kb.add('down', filter=~is_searching)
|
@self._kb.add('down', filter=~is_searching)
|
||||||
|
@ -345,10 +336,7 @@ class CliMenu:
|
||||||
self._searchbar])
|
self._searchbar])
|
||||||
|
|
||||||
# set initial pos
|
# set initial pos
|
||||||
while not self._items[self._pos].focusable:
|
for _ in range(self._initial_pos + 1):
|
||||||
self._pos += 1
|
|
||||||
|
|
||||||
for _ in range(self._initial_pos):
|
|
||||||
self.next_item(1)
|
self.next_item(1)
|
||||||
|
|
||||||
app = Application(layout=Layout(split),
|
app = Application(layout=Layout(split),
|
||||||
|
@ -373,11 +361,9 @@ class CliMultiMenu(CliMenu):
|
||||||
self._selection_icons = selection_icons if selection_icons is not None else self.default_selection_icons
|
self._selection_icons = selection_icons if selection_icons is not None else self.default_selection_icons
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def add_option(self, text, item=_EmptyParameter, selected=False, disabled=False,
|
def add_option(self, text, item=_EmptyParameter, selected=False,
|
||||||
style=None, highlighted_style=None, selected_style=None, selected_highlighted_style=None):
|
style=None, highlighted_style=None, selected_style=None, selected_highlighted_style=None):
|
||||||
super().add_option(text, item, style, highlighted_style=highlighted_style)
|
super().add_option(text, item, style, highlighted_style=highlighted_style)
|
||||||
if disabled:
|
|
||||||
return
|
|
||||||
self._items[-1].selected_style = selected_style
|
self._items[-1].selected_style = selected_style
|
||||||
self._items[-1].selected_highlighted_style = selected_highlighted_style
|
self._items[-1].selected_highlighted_style = selected_highlighted_style
|
||||||
if selected:
|
if selected:
|
||||||
|
|
Loading…
Reference in New Issue