def autocomplete_streams(self, text: str, prefix_string: str ) -> List[str]: streams_list = self.view.pinned_streams + self.view.unpinned_streams stream_typeahead = [('#**{}**'.format(stream[0]), stream[0]) for stream in streams_list] return match_stream(stream_typeahead, text[1:], self.view.pinned_streams)
def autocomplete_streams(self, text: str) -> List[str]: streams_list = self.view.pinned_streams + self.view.unpinned_streams stream_typeahead = [ '#**{}**'.format(stream[0]) for stream in streams_list if match_stream(stream, text[1:]) ] return stream_typeahead
def update_streams(self, search_box: Any, new_text: str) -> None: if not self.view.controller.is_in_editor_mode(): return # wait for any previously started search to finish to avoid # displaying wrong stream list. with self.search_lock: stream_buttons = [ (stream, stream.stream_name) for stream in self.streams_btn_list.copy() ] streams_display = match_stream(stream_buttons, new_text, self.view.pinned_streams)[0] # Add a divider to separate pinned streams from the rest. pinned_stream_names = [ stream[0] for stream in self.view.pinned_streams ] first_unpinned_index = len(streams_display) for index, stream in enumerate(streams_display): if stream.stream_name not in pinned_stream_names: first_unpinned_index = index break if first_unpinned_index not in [0, len(streams_display)]: # Do not add a divider when it is already present. This can # happen when new_text=''. if not isinstance(streams_display[first_unpinned_index], StreamsViewDivider): streams_display.insert(first_unpinned_index, StreamsViewDivider()) self.log.clear() self.log.extend(streams_display) self.view.controller.update_screen()
def autocomplete_streams(self, text: str, state: int) -> Optional[str]: streams_list = self.view.pinned_streams + self.view.unpinned_streams stream_typeahead = ['#**{}**'.format(stream[0]) for stream in streams_list if match_stream(stream, text[1:])] try: return stream_typeahead[state] except IndexError: return None
def autocomplete_streams( self, text: str, prefix_string: str) -> Tuple[List[str], List[str]]: streams_list = self.view.pinned_streams + self.view.unpinned_streams streams = [stream[0] for stream in streams_list] stream_typeahead = format_string(streams, '#**{}**') stream_data = list(zip(stream_typeahead, streams)) matched_data = match_stream(stream_data, text[1:], self.view.pinned_streams) return matched_data
def update_streams(self, search_box: Any, new_text: str) -> None: if not self.view.controller.is_in_editor_mode(): return # wait for any previously started search to finish to avoid # displaying wrong stream list. with self.search_lock: stream_buttons = [(stream, stream.stream_name) for stream in self.streams_btn_list.copy()] streams_display = match_stream(stream_buttons, new_text, self.view.pinned_streams) self.log.clear() self.log.extend(streams_display) self.view.controller.update_screen()