def draw_status_row(self, status, index, highlight=False, draw_divider=True): offset = 3 * index height, width = self.pad.getmaxyx() color = Color.GREEN if highlight else Color.WHITE trunc_width = width - 15 acct = fit_text("@" + status['account']['acct'], trunc_width) display_name = fit_text(status['account']['display_name'], trunc_width) if status['account']['display_name']: self.pad.addstr(offset + 1, 14, display_name, color) self.pad.addstr(offset + 2, 14, acct, color) else: self.pad.addstr(offset + 1, 14, acct, color) if status['in_reply_to_id'] is not None: self.pad.addstr(offset + 1, width - 3, '⤶', Color.CYAN) date, time = status['created_at'] self.pad.addstr(offset + 1, 1, " " + date.ljust(12), color) self.pad.addstr(offset + 2, 1, " " + time.ljust(12), color) if status['favourited']: self.pad.addstr(offset + 2, width - 3, '⭐', Color.YELLOW) if draw_divider: draw_horizontal_divider(self.pad, offset + 3) self.refresh()
def draw(self, status): self.window.erase() self.window.box() if not status: return content = self.content_lines(status) footer = self.footer_lines(status) y = draw_lines(self.window, content, 1, 2, Color.WHITE) draw_horizontal_divider(self.window, y) draw_lines(self.window, footer, y + 1, 2, Color.WHITE) self.window.refresh()
def draw_status_row(self, status, index, highlight=False, draw_divider=True): offset = 3 * index height, width = self.pad.getmaxyx() color = Color.GREEN if highlight else Color.WHITE trunc_width = width - 15 acct = trunc("@" + status['account']['acct'], trunc_width).ljust(trunc_width) display_name = trunc(status['account']['display_name'], trunc_width).ljust(trunc_width) if status['account']['display_name']: self.pad.addstr(offset + 1, 14, display_name, color) self.pad.addstr(offset + 2, 14, acct, color) else: self.pad.addstr(offset + 1, 14, acct, color) date, time = status['created_at'] self.pad.addstr(offset + 1, 1, " " + date.ljust(12), color) self.pad.addstr(offset + 2, 1, " " + time.ljust(12), color) # Redraw box borders to mitigate unicode overflow issues self.pad.addch(offset + 1, 0, "│") self.pad.addch(offset + 2, 0, "│") self.pad.addch(offset + 1, width - 1, "│") self.pad.addch(offset + 2, width - 1, "│") if draw_divider: draw_horizontal_divider(self.pad, offset + 3) self.refresh()