MCPcopy Create free account
hub / github.com/RetiredWizard/PyDOS / IO_DEVICE

Class IO_DEVICE

pye_pydos.py:14–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12 Pydos_ui = False
13
14class IO_DEVICE:
15 def __init__(self):
16 try:
17 from micropython import kbd_intr
18 kbd_intr(-1)
19 except ImportError:
20 pass
21 if hasattr(sys.stdin, "buffer"):
22 self.rd_raw_fct = sys.stdin.buffer.read
23 else:
24 self.rd_raw_fct = sys.stdin.read
25
26 def wr(self, s):
27 sys.stdout.write(s)
28
29 def rd(self):
30 if Pydos_ui:
31 return Pydos_ui.read_keyboard(1)
32 else:
33 return sys.stdin.read(1)
34
35 def rd_raw(self):
36 return self.rd(1)
37
38 def deinit_tty(self):
39 try:
40 from micropython import kbd_intr
41 kbd_intr(3)
42 except ImportError:
43 pass
44
45 def get_screen_size(self):
46 if Pydos_ui:
47 return [i for i in Pydos_ui.get_screensize()]
48 else:
49 self.wr('\x1b[999;999H\x1b[6n')
50 pos = ''
51 char = self.rd() ## expect ESC[yyy;xxxR
52 while char != 'R':
53 pos += char
54 char = self.rd()
55 return [int(i, 10) for i in pos.lstrip("\n\x1b[").split(';')]
56
57## test, if the Editor class is already present
58if "pye_edit" not in globals().keys():

Callers 1

pyeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected