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

Method get_screensize

lib/pydos_ui.py:50–88  ·  view source on GitHub ↗
(self,disp=None)

Source from the content-addressed store, hash-verified

48 return stdin.read(num)
49
50 def get_screensize(self,disp=None):
51 try:
52 if disp is not None:
53 dhigh = disp.height
54 dwide = disp.width
55 else:
56 dhigh = self.display.height
57 dwide = self.display.width
58
59 height = round(dhigh/(FONT.bitmap.height*TERM.scale))-1
60 width = round(dwide/((FONT.bitmap.width/95)*TERM.scale))-2
61 except:
62 print("Screen set to 24 rows, 80 col. Press any key to continue...",end="")
63 stdout.write('\x1b[2K')
64 stdout.write('\x1b[999;999H\x1b[6n')
65 pos = ''
66 char = ''
67 if self.serial_bytes_available(100):
68 try:
69 char = stdin.read(1) ## expect ESC[yyy;xxxR
70 except:
71 return(24,80)
72 if char != '\x1b':
73 return(24,80)
74
75 while char != 'R':
76 pos += char
77 char = stdin.read(1)
78 print()
79
80 width = int(pos.lstrip("\n\x1b[").split(';')[1],10)
81 height = int(pos.lstrip("\n\x1b[").split(';')[0],10)
82
83 if width < 1:
84 width = 80
85 if height < 1:
86 height = 24
87
88 return(height,width)
89
90Pydos_ui = PyDOS_UI()

Callers 3

get_screen_sizeMethod · 0.45
PyDOSFunction · 0.45
viewFileFunction · 0.45

Calls 2

writeMethod · 0.45

Tested by

no test coverage detected