Terminal emu: restoring cursor position after ADB
This commit is contained in:
parent
f1e7622e17
commit
0b355bc704
@ -39,18 +39,22 @@ class TerminalEmulator:
|
|||||||
b = ser.read(1)
|
b = ser.read(1)
|
||||||
if ord(b) > 31 or ord(b) == 10:
|
if ord(b) > 31 or ord(b) == 10:
|
||||||
w.addch(b)
|
w.addch(b)
|
||||||
|
|
||||||
# read key and write to serial port
|
# read key and write to serial port
|
||||||
key = w.getch()
|
key = w.getch()
|
||||||
if key == 10 or (key > 31 and key < 256):
|
if key == 10 or (key > 31 and key < 256):
|
||||||
# Is a character
|
# Is a character
|
||||||
ser.write(bytes([key]))
|
ser.write(bytes([key]))
|
||||||
elif int(key) == 1: # CTRL+A, enter ADB mode
|
elif int(key) == 1: # CTRL+A, enter ADB mode
|
||||||
|
# Save cursor position
|
||||||
|
(xPos, yPos) = w.getyx()
|
||||||
self.adbMode(w, ser)
|
self.adbMode(w, ser)
|
||||||
|
# Restore cursor position
|
||||||
|
w.move(xPos, yPos)
|
||||||
|
|
||||||
|
|
||||||
w.refresh()
|
w.refresh()
|
||||||
|
|
||||||
def adbMode(self, w, ser):
|
def adbMode(self, w, ser):
|
||||||
stdscr.nodelay(False)
|
stdscr.nodelay(False)
|
||||||
curses.echo()
|
curses.echo()
|
||||||
@ -72,11 +76,9 @@ class TerminalEmulator:
|
|||||||
w.clrtoeol()
|
w.clrtoeol()
|
||||||
w.addstr(" {}".format(str(e)), curses.A_REVERSE)
|
w.addstr(" {}".format(str(e)), curses.A_REVERSE)
|
||||||
w.refresh()
|
w.refresh()
|
||||||
|
|
||||||
curses.noecho()
|
curses.noecho()
|
||||||
stdscr.nodelay(True)
|
stdscr.nodelay(True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user