How to use the curtsies.fsarray function in curtsies

To help you get started, we’ve selected a few curtsies examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bpython / curtsies / examples / tictactoeexample.py View on Github external
def display(self):
        colored = {' ':' ', 'x':blue(bold('x')), 'o':red(bold('o'))}
        s = ('\n'+green('-')*(len(self.columns)*2-1) + '\n').join([green('|').join(colored[mark] for mark in row) for row in self._rows])
        a = fsarray([bold(green('enter a number, 0-8' if self.whose_turn == 'x' else 'wait for computer...'))] + s.split('\n'))
        return a
github bpython / bpython / bpython / curtsiesfrontend / replpainter.py View on Github external
def paint_statusbar(rows, columns, msg, config):
    func = func_for_letter(config.color_scheme['main'])
    return fsarray([func(msg.ljust(columns))[:columns]])
github bpython / bpython / bpython / curtsiesfrontend / replpainter.py View on Github external
new_line += line.ljust(width)[:width]
        new_line += border_color(' ' + config.right_border)
        return new_line

    border_color = func_for_letter(config.color_scheme['main'])

    top_line = border_color(config.left_top_corner +
                            config.top_border * (width + 2) +
                            config.right_top_corner)
    bottom_line = border_color(config.left_bottom_corner +
                               config.bottom_border * (width + 2) +
                               config.right_bottom_corner)

    output_lines = list(itertools.chain((top_line, ), map(add_border, lines),
                                        (bottom_line, )))
    r = fsarray(output_lines[:min(rows - 1,
                                  len(output_lines) - 1)] + output_lines[-1:])
    return r
github bpython / bpython / bpython / curtsiesfrontend / replpainter.py View on Github external
config.left_top_corner
        + config.top_border * width
        + config.right_top_corner
    )
    for name in reversed(names[max(0, len(names) - (rows - 2)) :]):
        output_lines.append(
            config.left_border
            + name[:width].center(width)
            + config.right_border
        )
    output_lines.append(
        config.left_bottom_corner
        + config.bottom_border * width
        + config.right_bottom_corner
    )
    return fsarray(output_lines)
github bpython / bpython / bpython / curtsiesfrontend / replpainter.py View on Github external
top_line = border_color(
        config.left_top_corner
        + config.top_border * (width + 2)
        + config.right_top_corner
    )
    bottom_line = border_color(
        config.left_bottom_corner
        + config.bottom_border * (width + 2)
        + config.right_bottom_corner
    )

    output_lines = list(
        itertools.chain((top_line,), map(add_border, lines), (bottom_line,))
    )
    r = fsarray(
        output_lines[: min(rows - 1, len(output_lines) - 1)] + output_lines[-1:]
    )
    return r
github bpython / bpython / bpython / curtsiesfrontend / replpainter.py View on Github external
def paint_last_events(rows, columns, names, config):
    if not names:
        return fsarray([])
    width = min(max(len(name) for name in names), columns - 2)
    output_lines = []
    output_lines.append(config.left_top_corner + config.top_border * width +
                        config.right_top_corner)
    for name in reversed(names[max(0, len(names) - (rows - 2)):]):
        output_lines.append(config.left_border + name[:width].center(width) +
                            config.right_border)
    output_lines.append(config.left_bottom_corner +
                        config.bottom_border * width +
                        config.right_bottom_corner)
    return fsarray(output_lines)
github bpython / bpython / bpython / curtsiesfrontend / replpainter.py View on Github external
def paint_statusbar(rows, columns, msg, config):
    func = func_for_letter(config.color_scheme["main"])
    return fsarray([func(msg.ljust(columns))[:columns]])
github bpython / bpython / bpython / curtsiesfrontend / replpainter.py View on Github external
def paint_history(rows, columns, display_lines):
    lines = []
    for r, line in zip(range(rows), display_lines[-rows:]):
        lines.append(fmtstr(line[:columns]))
    r = fsarray(lines, width=columns)
    assert r.shape[0] <= rows, repr(r.shape) + " " + repr(rows)
    assert r.shape[1] <= columns, repr(r.shape) + " " + repr(columns)
    return r
github bpython / bpython / bpython / curtsiesfrontend / replpainter.py View on Github external
def paint_last_events(rows, columns, names, config):
    if not names:
        return fsarray([])
    width = min(max(len(name) for name in names), columns - 2)
    output_lines = []
    output_lines.append(config.left_top_corner + config.top_border * width +
                        config.right_top_corner)
    for name in reversed(names[max(0, len(names) - (rows - 2)):]):
        output_lines.append(config.left_border + name[:width].center(width) +
                            config.right_border)
    output_lines.append(config.left_bottom_corner +
                        config.bottom_border * width +
                        config.right_bottom_corner)
    return fsarray(output_lines)
github bpython / bpython / bpython / curtsiesfrontend / replpainter.py View on Github external
def paint_current_line(rows, columns, current_display_line):
    lines = display_linize(current_display_line, columns, True)
    return fsarray(lines, width=columns)