Skip to content

Commit 584511f

Browse files
committed
improved terminal raw mode
do not convert return to lf on input in raw mode
1 parent 5537e06 commit 584511f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

amitools/vamos/lib/dos/terminal.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,27 @@ def close(self):
2121

2222
def set_mode(self, cooked):
2323
# [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]
24+
# 0 1 2 3
2425
if termios:
2526
state = termios.tcgetattr(self.fd)
26-
# control ECHO/ICANON/IEXTEN
27+
28+
# input modes
29+
# ICRNL: do not convert CR to NL on input for raw
30+
flags = termios.ICRNL
31+
if cooked:
32+
state[0] |= flags
33+
else:
34+
state[0] &= ~flags
35+
36+
# local modes: ECHO/ICANON/IEXTEN
37+
# ECHO: no local echo
38+
# ICANON/IEXTEN: no line-wise editing
2739
flags = termios.ECHO | termios.ICANON | termios.IEXTEN
2840
if cooked:
2941
state[3] |= flags
3042
else:
3143
state[3] &= ~flags
44+
3245
termios.tcsetattr(self.fd, termios.TCSAFLUSH, state)
3346
return True
3447
else:

0 commit comments

Comments
 (0)