def update_user_list(self, search_box: Any = None, new_text: str = "", user_list: Any = None) -> None: assert ((user_list is None and search_box is not None) or (user_list is not None and search_box is None and new_text == "")) if not self.view.controller.editor_mode and not user_list: return if not self.allow_update_user_list and new_text == "": return # wait for any previously started search to finish to avoid # displaying wrong user list. with self.search_lock: if user_list: self.view.users = user_list users = self.view.users.copy() if new_text: users_display = [ user for user in users if match_user(user, new_text) ] else: users_display = users self.body = self.users_view(users_display) self.set_body(self.body) self.view.controller.update_screen()
def autocomplete_mentions(self, text: str, prefix_string: str ) -> List[str]: # Handles user mentions (@ mentions and silent mentions) # and group mentions. group_typeahead = ['@*{}*'.format(group_name) for group_name in self.model.user_group_names if match_group(group_name, text[1:])] users_list = self.view.users user_typeahead = [prefix_string+'**{}**'.format(user['full_name']) for user in users_list if match_user(user, text[len(prefix_string):])] combined_typeahead = group_typeahead + user_typeahead return combined_typeahead
def update_user_list(self, search_box: Any, new_text: str) -> None: if not self.view.controller.editor_mode: return # wait for any previously started search to finish to avoid # displaying wrong user list. self.search_lock.acquire() users = self.view.users.copy() users_display = users.copy() for user in users: if not match_user(user, new_text): users_display.remove(user) self.body = self.users_view(users_display) self.set_body(self.body) self.view.controller.update_screen() self.search_lock.release()
def autocomplete_mentions(self, text: str, state: int, prefix_string: str) -> Optional[str]: # Handles user mentions (@ mentions and silent mentions) # and group mentions. group_typeahead = ['@*{}*'.format(group_name) for group_name in self.model.user_group_names if match_groups(group_name, text[1:])] users_list = self.view.users user_typeahead = [prefix_string+'**{}**'.format(user['full_name']) for user in users_list if match_user(user, text[len(prefix_string):])] combined_typeahead = group_typeahead + user_typeahead try: return combined_typeahead[state] except IndexError: return None
def autocomplete_mentions( self, text: str, prefix_string: str) -> Tuple[List[str], List[str]]: # Handles user mentions (@ mentions and silent mentions) # and group mentions. groups = [ group_name for group_name in self.model.user_group_names if match_group(group_name, text[1:]) ] group_typeahead = format_string(groups, '@*{}*') users_list = self.view.users users = [ user['full_name'] for user in users_list if match_user(user, text[len(prefix_string):]) ] user_typeahead = format_string(users, prefix_string + '**{}**') combined_typeahead = group_typeahead + user_typeahead combined_names = groups + users return combined_typeahead, combined_names