Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
def draw_lines(window, lines, start_y, padding, default_color):
    height, width = window.getmaxyx()
    text_width = width - 2 * padding

    for dy, (line, color) in enumerate_lines(lines, text_width, default_color):
        y = start_y + dy
        if y < height - 1:
            window.addstr(y, padding, fit_text(line, text_width), color)
            highlight_hashtags(window, y, padding, line)

    return y + 1
Ejemplo n.º 3
0
 def draw_message(self, text, color):
     text = fit_text(text, self.width - 1)
     self.window.addstr(1, 0, text, color)
     self.window.refresh()
Ejemplo n.º 4
0
 def draw_status(self, selected, count):
     text = "Showing toot {} of {}".format(selected + 1, count)
     text = fit_text(text, self.width)
     self.window.addstr(0, 0, text, Color.WHITE_ON_BLUE | curses.A_BOLD)
     self.window.refresh()
Ejemplo n.º 5
0
def test_fit_text():
    text = 'Frank Zappa 🎸'

    assert fit_text(text, 1) == '…'
    assert fit_text(text, 2) == 'F…'
    assert fit_text(text, 3) == 'Fr…'
    assert fit_text(text, 4) == 'Fra…'
    assert fit_text(text, 5) == 'Fran…'
    assert fit_text(text, 6) == 'Frank…'
    assert fit_text(text, 7) == 'Frank…'
    assert fit_text(text, 8) == 'Frank Z…'
    assert fit_text(text, 9) == 'Frank Za…'
    assert fit_text(text, 10) == 'Frank Zap…'
    assert fit_text(text, 11) == 'Frank Zapp…'
    assert fit_text(text, 12) == 'Frank Zappa…'
    assert fit_text(text, 13) == 'Frank Zappa…'
    assert fit_text(text, 14) == 'Frank Zappa 🎸'
    assert fit_text(text, 15) == 'Frank Zappa 🎸 '
    assert fit_text(text, 16) == 'Frank Zappa 🎸  '
    assert fit_text(text, 17) == 'Frank Zappa 🎸   '
    assert fit_text(text, 18) == 'Frank Zappa 🎸    '
    assert fit_text(text, 19) == 'Frank Zappa 🎸     '
    assert fit_text(text, 20) == 'Frank Zappa 🎸      '