Skip to content

Commit

Permalink
improved terminal raw mode
Browse files Browse the repository at this point in the history
do not convert return to lf on input in raw mode
  • Loading branch information
cnvogelg committed Jan 23, 2025
1 parent 5537e06 commit 584511f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion amitools/vamos/lib/dos/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,27 @@ def close(self):

def set_mode(self, cooked):
# [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]
# 0 1 2 3
if termios:
state = termios.tcgetattr(self.fd)
# control ECHO/ICANON/IEXTEN

# input modes
# ICRNL: do not convert CR to NL on input for raw
flags = termios.ICRNL
if cooked:
state[0] |= flags
else:
state[0] &= ~flags

# local modes: ECHO/ICANON/IEXTEN
# ECHO: no local echo
# ICANON/IEXTEN: no line-wise editing
flags = termios.ECHO | termios.ICANON | termios.IEXTEN
if cooked:
state[3] |= flags
else:
state[3] &= ~flags

termios.tcsetattr(self.fd, termios.TCSAFLUSH, state)
return True
else:
Expand Down

0 comments on commit 584511f

Please sign in to comment.