Add interactive search to story view
This allows looking for keywords in the task list while viewing a story. It does not implement search for every piece however. Change-Id: I584571fc901a5fe207a45cb5cb2fcfa2c26d6ecb
This commit is contained in:
parent
8aa8e7e89f
commit
5f78c22ca6
@ -44,9 +44,14 @@ class TextButton(urwid.Button):
|
|||||||
|
|
||||||
def __init__(self, text, on_press=None, user_data=None):
|
def __init__(self, text, on_press=None, user_data=None):
|
||||||
super(TextButton, self).__init__('', on_press=on_press, user_data=user_data)
|
super(TextButton, self).__init__('', on_press=on_press, user_data=user_data)
|
||||||
self.text = urwid.Text(text)
|
self.text = SearchableText(text)
|
||||||
self._w = urwid.AttrMap(self.text, None, focus_map='focused')
|
self._w = urwid.AttrMap(self.text, None, focus_map='focused')
|
||||||
|
|
||||||
|
def search(self, search, attribute):
|
||||||
|
if self.text.search(search, attribute):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
class FixedButton(urwid.Button):
|
class FixedButton(urwid.Button):
|
||||||
def sizing(self):
|
def sizing(self):
|
||||||
return frozenset([urwid.FIXED])
|
return frozenset([urwid.FIXED])
|
||||||
|
@ -314,6 +314,11 @@ class TaskRow(urwid.WidgetWrap):
|
|||||||
self.app.backScreen()
|
self.app.backScreen()
|
||||||
self.story_view.refresh()
|
self.story_view.refresh()
|
||||||
|
|
||||||
|
def search(self, search, attribute):
|
||||||
|
if self.title.search(search, attribute):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
class StoryButton(urwid.Button):
|
class StoryButton(urwid.Button):
|
||||||
button_left = urwid.Text(u' ')
|
button_left = urwid.Text(u' ')
|
||||||
button_right = urwid.Text(u' ')
|
button_right = urwid.Text(u' ')
|
||||||
@ -442,7 +447,7 @@ class DescriptionBox(mywid.HyperText):
|
|||||||
super(DescriptionBox, self).set_text(text)
|
super(DescriptionBox, self).set_text(text)
|
||||||
|
|
||||||
@mouse_scroll_decorator.ScrollByWheel
|
@mouse_scroll_decorator.ScrollByWheel
|
||||||
class StoryView(urwid.WidgetWrap):
|
class StoryView(urwid.WidgetWrap, mywid.Searchable):
|
||||||
def getCommands(self):
|
def getCommands(self):
|
||||||
return [
|
return [
|
||||||
(keymap.TOGGLE_HIDDEN,
|
(keymap.TOGGLE_HIDDEN,
|
||||||
@ -469,6 +474,8 @@ class StoryView(urwid.WidgetWrap):
|
|||||||
"Refresh this story"),
|
"Refresh this story"),
|
||||||
(keymap.EDIT_TITLE,
|
(keymap.EDIT_TITLE,
|
||||||
"Edit the title of this story"),
|
"Edit the title of this story"),
|
||||||
|
(keymap.INTERACTIVE_SEARCH,
|
||||||
|
"Interactive search"),
|
||||||
]
|
]
|
||||||
|
|
||||||
def help(self):
|
def help(self):
|
||||||
@ -483,6 +490,7 @@ class StoryView(urwid.WidgetWrap):
|
|||||||
def __init__(self, app, story_key):
|
def __init__(self, app, story_key):
|
||||||
super(StoryView, self).__init__(urwid.Pile([]))
|
super(StoryView, self).__init__(urwid.Pile([]))
|
||||||
self.log = logging.getLogger('boartty.view.story')
|
self.log = logging.getLogger('boartty.view.story')
|
||||||
|
self.searchInit()
|
||||||
self.app = app
|
self.app = app
|
||||||
self.story_key = story_key
|
self.story_key = story_key
|
||||||
self.task_rows = {}
|
self.task_rows = {}
|
||||||
@ -655,6 +663,8 @@ class StoryView(urwid.WidgetWrap):
|
|||||||
return self.app.toggleHeldStory(self.story_key)
|
return self.app.toggleHeldStory(self.story_key)
|
||||||
|
|
||||||
def keypress(self, size, key):
|
def keypress(self, size, key):
|
||||||
|
if self.searchKeypress(size, key):
|
||||||
|
return None
|
||||||
if not self.app.input_buffer:
|
if not self.app.input_buffer:
|
||||||
key = super(StoryView, self).keypress(size, key)
|
key = super(StoryView, self).keypress(size, key)
|
||||||
keys = self.app.input_buffer + [key]
|
keys = self.app.input_buffer + [key]
|
||||||
@ -712,6 +722,11 @@ class StoryView(urwid.WidgetWrap):
|
|||||||
if keymap.EDIT_TITLE in commands:
|
if keymap.EDIT_TITLE in commands:
|
||||||
self.editTitle()
|
self.editTitle()
|
||||||
return None
|
return None
|
||||||
|
if keymap.INTERACTIVE_SEARCH in commands:
|
||||||
|
self.searchStart()
|
||||||
|
if keymap.FURTHER_INPUT not in commands:
|
||||||
|
self.app.clearInputBuffer()
|
||||||
|
return None
|
||||||
return key
|
return key
|
||||||
|
|
||||||
def editDescription(self):
|
def editDescription(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user