Skip to content

Instantly share code, notes, and snippets.

@thomasballinger
Created September 20, 2014 22:41
Show Gist options
  • Save thomasballinger/be2186e67168c87eb41f to your computer and use it in GitHub Desktop.
Save thomasballinger/be2186e67168c87eb41f to your computer and use it in GitHub Desktop.
def parse_term_state(s):
"""Returns TerminalState tuple given a terminal state diagram
>>> parse_term_state('''
... label
... +-----+
... |ABC |
... +-----+
... |BC |
... |abc@ |
... | |
... +-----+
... ''')
('label', TerminalState(history=['abc'], rendered=['abc'], top_usable_row=1, scrolled=0, cursor=[1, 3], display=['bc', 'abc'], rows=3, columns=5))
"""
(ugly parsing code)
#for things like
decrease_terminal_width = """
reflow
xterm +--------+
+---------+ +--------+ |georgian+
|georgiann+ |georgian| |na |
|a ! |a | | |
| ! | | |hello |
+---------+ --> +--------+ +--------+
|hello | |hello | |bpython |
|bpython | |bpython | |********|
|*********| |********| |* |
|* | |* | |****@ |
|****@ | |****@ | | |
| | | | | |
+---------+ +--------+ +--------+
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment