1- import termios , fcntl , sys , os
1+ import fcntl , os , sys , termios
22import threading
33import time
44
55from contextlib import contextmanager
66from enum import Enum
77from math import ceil
88
9+
910__version__ = "0.1.0"
1011__author__ = "João S. O. Bueno"
1112
@@ -23,11 +24,11 @@ def realtime_keyb():
2324 flags_save = fcntl .fcntl (fd , fcntl .F_GETFL )
2425 attrs_save = termios .tcgetattr (fd )
2526 # make raw - the way to do this comes from the termios(3) man page.
26- attrs = list (attrs_save ) # copy the stored version to update
27+ attrs = list (attrs_save ) # copy the stored version to update
2728 # iflag
2829 attrs [0 ] &= ~ (termios .IGNBRK | termios .BRKINT | termios .PARMRK
2930 | termios .ISTRIP | termios .INLCR | termios . IGNCR
30- | termios .ICRNL | termios .IXON )
31+ | termios .ICRNL | termios .IXON )
3132 # oflag
3233 attrs [1 ] &= ~ termios .OPOST
3334 # cflag
@@ -49,7 +50,7 @@ def realtime_keyb():
4950def inkey (break_ = True ):
5051 keycode = ""
5152 while True :
52- c = sys .stdin .read (1 ) # returns a single character
53+ c = sys .stdin .read (1 ) # returns a single character
5354 if not c :
5455 break
5556 if c == "\x03 " and break_ :
@@ -71,10 +72,10 @@ def testkeys():
7172 time .sleep (0.3 )
7273
7374
74-
7575DEFAULT_BG = 0xfffe
7676DEFAULT_FG = 0xffff
7777
78+
7879class Directions (Enum ):
7980 UP = (0 , - 1 )
8081 RIGHT = (1 , 0 )
@@ -137,6 +138,7 @@ def get_at(cls, pos, data):
137138
138139BlockChars = BlockChars ()
139140
141+
140142class ScreenCommands :
141143
142144 def print (self , * args , sep = '' , end = '' , flush = True ):
@@ -414,6 +416,7 @@ def test_lines(scr):
414416 '%' : (1 , 0.7 , 0 ),
415417}
416418
419+
417420def main ():
418421 with realtime_keyb (), Screen () as scr :
419422 test_lines (scr .high )
@@ -429,7 +432,7 @@ def main():
429432 scr .context .color = DEFAULT_FG
430433 scr .high .draw .blit ((160 , 25 ), shape1 )
431434
432- scr [0 , scr .height - 1 ] = ' '
435+ scr [0 , scr .height - 1 ] = ' '
433436
434437 result = scr .high .get_at ((150 , 5 )), scr .high .get_at ((149 , 5 ))
435438 while True :
0 commit comments