Exemple #1
0
def render(state, line):
    maxy, maxx = g.stdscr.getmaxyx()

    if 'line1' in state and state['line1']:
        g.stdscr.addstr(
            line,
            util.centerallignindex(len(state['line1']), maxx) if
            state['is_centered'] else util.leftallignindex(), state['line1'])
        line += 1
    if 'line2' in state and state['line2']:
        g.stdscr.addstr(
            line,
            util.centerallignindex(len(state['line2']), maxx) if
            state['is_centered'] else util.leftallignindex(), state['line2'])
        line += 1

    sattempts = ""
    if state['finished_runs'] and state['attempts']:
        sattempts = str(state['finished_runs']) + "/" + str(state['attempts'])
    else:
        if state['finished_runs']:
            sattempts = str(state['finished_runs'])
        if state['attempts']:
            sattempts = str(state['attempts'])
    g.stdscr.addstr(1, util.rightallignindex(len(sattempts), maxx), sattempts)

    return line
Exemple #2
0
def render(state, line):
    if 'timer' not in state:
        return line

    usedlines = 0
    # delegate timer render
    usedlines += timer.render(state['timer'], line) - line

    # delegate segment timer render
    if 'segment_timer' in state:
        tmp = line + usedlines
        usedlines += timer.render(state['segment_timer'], tmp - min(usedlines, 1)) - tmp

    line += usedlines

    if 'segment_name' in state and state['segment_name']:
        g.stdscr.addstr(line - min(5, usedlines), util.leftallignindex(minx=1), state['segment_name'])
    if 'comparison1' in state and state['comparison1']:
        s = state['comparison1']['name'] + ": " + state['comparison1']['time']
        g.stdscr.addstr(line - min(3, usedlines), util.leftallignindex(minx=1), s)
    if 'comparison2' in state and state['comparison2']:
        s = state['comparison2']['name'] + ": " + state['comparison2']['time']
        g.stdscr.addstr(line - min(2, usedlines), util.leftallignindex(minx=1), s)

    return line
Exemple #3
0
def render_messages():
    global static_messages
    global timed_messages
    try:
        i = 0
        maxlen = 0
        g.stdscr.attron(curses.color_pair(3))
        lock.acquire()
        # determine max length for box outline
        for messages in [timed_messages, static_messages]:
            for m in messages:
                if len(m) > maxlen:
                    maxlen = len(m)
        for tm in timed_messages:
            i = i + 1
            g.stdscr.addstr(g.stdscr.getmaxyx()[0] - i, util.leftallignindex(),
                            tm.ljust(maxlen, ' '))
        lock.release()
        for sm in static_messages:
            i = i + 1
            g.stdscr.addstr(g.stdscr.getmaxyx()[0] - i, util.leftallignindex(),
                            sm.ljust(maxlen, ' '))
        if i > 0:
            g.stdscr.addstr(g.stdscr.getmaxyx()[0] - i - 1,
                            util.leftallignindex(), "-" * (maxlen + 1) + "+")
            for j in range(1, i + 1):
                g.stdscr.addch(g.stdscr.getmaxyx()[0] - j, maxlen + 1, '|')
        g.stdscr.attroff(curses.color_pair(3))
    except curses.error:
        pass

    static_messages.clear()
Exemple #4
0
def render(state, line):
    maxy, maxx = g.stdscr.getmaxyx()

    labels = None
    if 'column_labels' in state:
        labels = state['column_labels']
    if labels:
        for i in range(0, len(labels)):
            s = labels[i].rjust(g.settings['defaults']['splitscolumnwidth'],
                                " ")
            index = util.rightallignindex(
                len(s), maxx - i * g.settings['defaults']['splitscolumnwidth'],
                maxx // 2)
            g.stdscr.addstr(line, index, s)
        line += 1

    if 'splits' in state:
        for split in state['splits']:
            s = split['name']
            if split['is_current_split']:
                s = "-> " + s
            g.stdscr.addstr(line, util.leftallignindex(), s)

            if state['display_two_rows']:
                line += 1

            columns = []
            columncolors = []
            for c in split['columns']:
                s = c['value']
                if s and not s.isspace():
                    columns.append(s)
                    columncolors.append(c['semantic_color'])

            n = len(columns)
            for i in range(0, n):
                if i < n - 1:
                    s = columns[i].rjust(
                        g.settings['defaults']['splitscolumnwidth'], " ")
                else:
                    s = " " + columns[i]
                index = util.rightallignindex(
                    len(s),
                    maxx - i * g.settings['defaults']['splitscolumnwidth'],
                    maxx // 2)
                g.stdscr.attron(timing.get_color(columncolors[i]))
                g.stdscr.addstr(line, index, s)
                g.stdscr.attroff(timing.get_color(columncolors[i]))

            line += 1

    return line
Exemple #5
0
def render(state, line):
    maxy, maxx = g.stdscr.getmaxyx()

    if 'text' in state and 'comparison' in state:
        g.stdscr.addstr(line, util.leftallignindex(), state['text'])

        if state['display_two_rows']:
            line += 1

        g.stdscr.addstr(line,
                        util.rightallignindex(len(state['comparison']), maxx),
                        state['comparison'])
        line += 1

    return line
Exemple #6
0
def render(state, line):
    maxy, maxx = g.stdscr.getmaxyx()

    if 'text' in state and 'time' in state:
        g.stdscr.addstr(line, util.leftallignindex(), state['text'])

        if state['display_two_rows']:
            line += 1

        g.stdscr.attron(timing.get_color(state['semantic_color']))
        g.stdscr.addstr(line, util.rightallignindex(len(state['time']), maxx),
                        state['time'])
        g.stdscr.attroff(timing.get_color(state['semantic_color']))
        line += 1

    return line
Exemple #7
0
def render(state, line):
    if 'text' not in state:
        return line

    maxy, maxx = g.stdscr.getmaxyx()
    text = state['text']

    if 'Center' in text:
        g.stdscr.addstr(line, util.centerallignindex(len(text['Center']),
                                                     maxx), text['Center'])
        line += 1

    if 'Split' in text:
        g.stdscr.addstr(line, util.leftallignindex(), text['Split'][0])

        if state['display_two_rows']:
            line += 1

        g.stdscr.addstr(line, util.rightallignindex(len(text['Split'][1]),
                                                    maxx), text['Split'][1])
        line += 1

    return line
Exemple #8
0
def render(state, line):
    maxy, maxx = g.stdscr.getmaxyx()
    g.stdscr.addstr(line, util.leftallignindex(), '-' * maxx)
    return line + 1