def __init__(self, body, keymap={}): self.scroll = utility.scroll(range(len(body))) \ if len(body) != 0 else utility.scroll([0]) self.keymap = dict(keymap) self.search_anchor = None self._searcher = search self._builder = shift_iterable super(MappedList, self).__init__(body)
def set(self, contents): self.body[:] = contents currentIndex = self.scroll() focusIndex = len(contents) - 1 \ if len(contents) < currentIndex \ else currentIndex self.scroll = utility.scroll(range(len(contents)), focusIndex)
def set_focus(self, position): self.focus_position = position self.set_focus_valign('middle') self.body[:] = self.body[:] self.scroll = utility.scroll(range(len(self.body[:])), position) urwid.emit_signal(self, 'shift')