| 1113 | except: |
| 1114 | import sys |
| 1115 | class IO_DEVICE: |
| 1116 | def __init__(self): |
| 1117 | try: |
| 1118 | from micropython import kbd_intr |
| 1119 | kbd_intr(-1) |
| 1120 | except ImportError: |
| 1121 | pass |
| 1122 | if hasattr(sys.stdin, "buffer"): |
| 1123 | self.rd_raw_fct = sys.stdin.buffer.read |
| 1124 | else: |
| 1125 | self.rd_raw_fct = sys.stdin.read |
| 1126 | def wr(self, s): |
| 1127 | sys.stdout.write(s) |
| 1128 | def rd(self): |
| 1129 | return sys.stdin.read(1) |
| 1130 | def rd_raw(self): |
| 1131 | return self.rd_raw_fct(1) |
| 1132 | def deinit_tty(self): |
| 1133 | try: |
| 1134 | from micropython import kbd_intr |
| 1135 | kbd_intr(3) |
| 1136 | except ImportError: |
| 1137 | pass |
| 1138 | def get_screen_size(self): |
| 1139 | self.wr('\x1b[999;999H\x1b[6n') |
| 1140 | pos = '' |
| 1141 | char = self.rd() |
| 1142 | while char != 'R': |
| 1143 | pos += char |
| 1144 | char = self.rd() |
| 1145 | return [int(i, 10) for i in pos.lstrip("\n\x1b[").split(';')] |
| 1146 | if "pye_edit" not in globals().keys(): |
| 1147 | from pye import pye_edit |
| 1148 | def pye(*args, tab_size=4, undo=50): |