paradoxxxzero_butterfly/butterfly/escapes.py
2015-10-05 17:03:26 +02:00

42 lines
724 B
Python

from contextlib import contextmanager
import sys
@contextmanager
def html():
sys.stdout.write('\x1bP;HTML|')
yield
sys.stdout.write('\x1bP')
sys.stdout.flush()
@contextmanager
def image(mime='image'):
sys.stdout.write('\x1bP;IMAGE|%s;' % mime)
yield
sys.stdout.write('\x1bP\n')
sys.stdout.flush()
@contextmanager
def prompt():
sys.stdout.write('\x1bP;PROMPT|')
yield
sys.stdout.write('\x1bP')
sys.stdout.flush()
@contextmanager
def text():
sys.stdout.write('\x1bP;TEXT|')
yield
sys.stdout.write('\x1bP')
sys.stdout.flush()
@contextmanager
def sass():
sys.stdout.write('\x1bP;SASS|')
yield
sys.stdout.write('\x1bP')
sys.stdout.flush()