fibonaccios/lib/console.py

18 lines
416 B
Python

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