How to use the curtsies.fmtfuncs.red 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 / tests / test_fmtstr.py View on Github external
def test_repr(self):
        self.assertEqual(fmtstr('hello', 'red', bold=False), red('hello'))
        self.assertEqual(fmtstr('hello', 'red', bold=True), bold(red('hello')))
github bpython / curtsies / examples / testcache.py View on Github external
import sys
import os

from curtsies.fmtfuncs import blue, red, bold, on_red

from curtsies.window import FullscreenWindow

import time

if __name__ == '__main__':

    print(blue('hey') + ' ' + red('there') + ' ' + red(bold('you')))
    n = int(sys.argv[1]) if len(sys.argv) > 1 else 100

    with FullscreenWindow() as window:
        rows, columns = window.get_term_hw()
        t0 = time.time()
        for i in range(n):
            a = [blue(on_red('qwertyuiop'[i%10]*columns)) for _ in range(rows)]
            window.render_to_terminal(a)
        t1 = time.time()
        t2 = time.time()
        for i in range(n):
            a = [blue(on_red('q'[i%1]*columns)) for _ in range(rows)]
            window.render_to_terminal(a)
        t3 = time.time()
        t4 = time.time()
        a = [blue(on_red('q'*columns)) for _ in range(rows)]
github bpython / curtsies / tests / test_fmtstr.py View on Github external
def test_diff_testing(self):
        a = fsarray(['abc', 'def'])
        b = fsarray(['abc', 'dqf'])
        self.assertRaises(AssertionError, self.assertFSArraysEqual, a, b)
        a = fsarray([blue('abc'), red('def')])
        b = fsarray([blue('abc'), red('dqf')])
        self.assertRaises(AssertionError, self.assertFSArraysEqual, a, b)
        a = fsarray([blue('abc'), red('def')])
        b = fsarray([blue('abc'), red('d')+blue('e')+red('f')])
        self.assertRaises(AssertionError, self.assertFSArraysEqual, a, b)
        a = fsarray(['abc', 'def'])
        b = fsarray(['abc', 'def'])
        self.assertFSArraysEqual(a, b)
        a = fsarray([blue('abc'), red('def')])
        b = fsarray([blue('abc'), red('def')])
        self.assertFSArraysEqual(a, b)
github bpython / curtsies / tests / test_fmtstr.py View on Github external
def test_change_color(self):
        a = blue(red('hello'))
        self.assertEqual(a, blue('hello'))
github bpython / curtsies / tests / test_fmtstr.py View on Github external
def test_fg(self):
        red('asdf')
        blue('asdf')
        self.assertTrue(True)
github bpython / curtsies / examples / chat.py View on Github external
def main(host, port):
    client = socket.socket()
    client.connect((host, port))
    client.setblocking(False)

    conn = Connection(client)
    keypresses = []

    with FullscreenWindow() as window:
        with Input() as input_generator:
            while True:
                a = FSArray(10, 80)
                in_text = ''.join(keypresses)[:80]
                a[9:10, 0:len(in_text)] = [red(in_text)]
                for i, line in zip(reversed(range(2,7)), reversed(conn.render())):
                    a[i:i+1, 0:len(line)] = [line]
                text = 'connected to %s:%d' % (host if len(host) < 50 else host[:50]+'...', port)
                a[0:1, 0:len(text)] = [blue(text)]

                window.render_to_terminal(a)
                ready_to_read, _, _ = select.select([conn, input_generator], [], [])
                for r in ready_to_read:
                    if r is conn:
                        r.on_read()
                    else:
                        e = input_generator.send(0)
                        if e == '':
                            return
                        elif e == '':
                            keypresses.append('\n')
github ianmiell / autotrace / autotrace / autotrace.py View on Github external
	def __init__(self, command, pexpect_session_manager, session_number, pane_name=None, pane_color=red, encoding='utf-8', logtimestep=False):
		"""

		pexpect_session               - The pexpect object that is held within
		                                this session.
		session_number                - Index of session - 0 is reserved for the
		                                'main' command. This does not change,
		                                unlike the session_pane value which
		                                changes depending on which SessionPane
		                                the session is assigned to in the window.
		command                       - The command tracked in this session
		output_lines                  - The lines of output. Each line is a
		                                PexpectSessionLine object.
		output_lines_end_pane_pointer - Used for scrolling, this tracks which
		                                output_lines index is at the end of the
		                                pane as displayed.
		output_top_visible_line_index - Used for scrolling, this tracks which