def keypress(self, size: Tuple[int, int], key: str) -> str: if is_command_key('GO_BACK', key): self.header.keypress(size, 'esc') self.footer.keypress(size, 'esc') self.set_focus('body') elif self.focus_position in ['footer', 'header']: return super(MiddleColumnView, self).keypress(size, key) elif is_command_key('SEARCH_MESSAGES', key): self.controller.editor_mode = True self.controller.editor = self.search_box self.set_focus('header') return key elif is_command_key('REPLY_MESSAGE', key): self.body.keypress(size, 'enter') self.set_focus('footer') self.footer.focus_position = 1 return key elif is_command_key('STREAM_MESSAGE', key): self.body.keypress(size, 'c') self.set_focus('footer') self.footer.focus_position = 0 return key elif is_command_key('REPLY_AUTHOR', key): self.body.keypress(size, 'R') self.set_focus('footer') self.footer.focus_position = 1 return key elif is_command_key('NEXT_UNREAD_TOPIC', key): # narrow to next unread topic stream_topic = self.get_next_unread_topic() if stream_topic is None: return key stream, topic = stream_topic self.controller.narrow_to_topic(TopicButton(stream, topic, self.model)) return key elif is_command_key('NEXT_UNREAD_PM', key): # narrow to next unread pm pm = self.get_next_unread_pm() if pm is None: return key email = self.model.user_id_email_dict[pm] self.controller.narrow_to_user(UnreadPMButton(pm, email)) elif is_command_key('PRIVATE_MESSAGE', key): # Create new PM message self.footer.private_box_view() self.set_focus('footer') self.footer.focus_position = 0 return key elif is_command_key('GO_LEFT', key): self.view.show_left_panel(visible=True) elif is_command_key('GO_RIGHT', key): self.view.show_right_panel(visible=True) return super(MiddleColumnView, self).keypress(size, key)
def keypress(self, size: Tuple[int, int], key: str) -> str: if key == 'esc': self.header.keypress(size, 'esc') self.footer.keypress(size, 'esc') self.set_focus('body') elif self.focus_position in ['footer', 'header']: return super(MiddleColumnView, self).keypress(size, key) elif key == '/': self.controller.editor_mode = True self.controller.editor = self.search_box self.set_focus('header') return key elif key == 'r': self.body.keypress(size, 'enter') self.set_focus('footer') self.footer.focus_position = 1 return key elif key == 'c': self.body.keypress(size, 'c') self.set_focus('footer') self.footer.focus_position = 0 return key elif key == 'R': self.body.keypress(size, 'R') self.set_focus('footer') self.footer.focus_position = 1 return key elif key == 'n': # narrow to next unread topic stream_topic = self.get_next_unread_topic() if stream_topic is None: return key stream, topic = stream_topic self.controller.narrow_to_topic( TopicButton(stream, topic, self.model)) return key elif key == 'p': # narrow to next unread pm pm = self.get_next_unread_pm() if pm is None: return key email = self.model.user_id_email_dict[pm] self.controller.narrow_to_user(UnreadPMButton(pm, email)) return super(MiddleColumnView, self).keypress(size, key)
def keypress(self, size: urwid_Size, key: str) -> Optional[str]: if is_command_key('GO_BACK', key): self.header.keypress(size, 'esc') self.footer.keypress(size, 'esc') self.set_focus('body') elif self.focus_position in ['footer', 'header']: return super().keypress(size, key) elif is_command_key('SEARCH_MESSAGES', key): self.controller.editor_mode = True self.controller.editor = self.search_box self.set_focus('header') return key elif is_command_key('REPLY_MESSAGE', key): self.body.keypress(size, 'enter') if self.footer.focus is not None: self.set_focus('footer') self.footer.focus_position = 1 return key elif is_command_key('STREAM_MESSAGE', key): self.body.keypress(size, 'c') # For new streams with no previous conversation. if self.footer.focus is None: stream_id = self.model.stream_id stream_dict = self.model.stream_dict self.footer.stream_box_view( caption=stream_dict[stream_id]['name']) self.set_focus('footer') self.footer.focus_position = 0 return key elif is_command_key('REPLY_AUTHOR', key): self.body.keypress(size, 'R') if self.footer.focus is not None: self.set_focus('footer') self.footer.focus_position = 1 return key elif is_command_key('NEXT_UNREAD_TOPIC', key): # narrow to next unread topic stream_topic = self.get_next_unread_topic() if stream_topic is None: return key stream, topic = stream_topic self.controller.narrow_to_topic( TopicButton(stream, topic, self.controller)) return key elif is_command_key('NEXT_UNREAD_PM', key): # narrow to next unread pm pm = self.get_next_unread_pm() if pm is None: return key email = self.model.user_id_email_dict[pm] self.controller.narrow_to_user(UnreadPMButton(pm, email)) elif is_command_key('PRIVATE_MESSAGE', key): # Create new PM message self.footer.private_box_view() self.set_focus('footer') self.footer.focus_position = 0 return key elif is_command_key('GO_LEFT', key): self.view.show_left_panel(visible=True) elif is_command_key('GO_RIGHT', key): self.view.show_right_panel(visible=True) return super().keypress(size, key)