1import random 2 3from curtsies import FullscreenWindow, Input, FSArray 4from curtsies.fmtfuncs import red, bold, green, on_blue, yellow 5 6if __name__ == '__main__': 7 print(yellow('this prints normally, not to the alternate screen')) 8 with FullscreenWindow() as window: 9 with Input() as input_generator: 10 msg = red(on_blue(bold('Press escape to exit'))) 11 a = FSArray(window.height, window.width) 12 a[0:1, 0:msg.width] = [msg] 13 window.render_to_terminal(a) 14 for c in input_generator: 15 if c == '<ESC>': 16 break 17 elif c == '<SPACE>': 18 a = FSArray(window.height, window.width) 19 else: 20 s = repr(c) 21 row = random.choice(range(window.height)) 22 column = random.choice(range(window.width-len(s))) 23 color = random.choice([red, green, on_blue, yellow]) 24 a[row, column:column+len(s)] = [color(s)] 25 window.render_to_terminal(a) 26