fibonaccios/lib/console.py

18 lines
416 B
Python
Raw Normal View History

2022-11-30 14:27:12 -08:00
def read(console, buffer):
char = console.read(1)
if char == b'\x08':
if buffer:
console.write(b'\x08 \x08')
buffer.pop()
return
elif char == b'\n':
console.write(b'\n')
data = b''.join(buffer)
buffer.clear()
return data
elif len(char) == 1:
console.write(char)
buffer.append(char)
else:
return None