Created
September 20, 2014 22:41
-
-
Save thomasballinger/be2186e67168c87eb41f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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