mirror of
https://github.com/kanaka/mal.git
synced 2024-11-23 12:14:45 +03:00
runtest: respond to cursor query escape sequence
If the program uses ncurses it may send a cursor query escape sequence and wait/hang until a response is received. Detect this and respond with a cursor position (1,1) escape code.
This commit is contained in:
parent
0da3a26353
commit
d5e2e321c8
11
runtest.py
11
runtest.py
@ -123,10 +123,15 @@ class Runner():
|
||||
if self.stdout in outs:
|
||||
new_data = self.stdout.read(1)
|
||||
new_data = new_data.decode("latin1") if IS_PY_3 else new_data
|
||||
#print("new_data: '%s'" % new_data)
|
||||
#print("new_data: %s" % repr(new_data))
|
||||
debug(new_data)
|
||||
# Perform newline cleanup
|
||||
self.buf += new_data.replace("\r", "")
|
||||
if self.buf.endswith('\x1b[6n'):
|
||||
log("Handling cursor query")
|
||||
self.stdin.write(b"\x1b[1;1R")
|
||||
self.buf = ""
|
||||
continue
|
||||
for prompt in prompts:
|
||||
regexp = re.compile(prompt)
|
||||
match = regexp.search(self.buf)
|
||||
@ -142,7 +147,9 @@ class Runner():
|
||||
def _to_bytes(s):
|
||||
return bytes(s, "latin1") if IS_PY_3 else s
|
||||
|
||||
self.stdin.write(_to_bytes(str.replace('\r', '\x16\r') + self.line_break))
|
||||
data = _to_bytes(str.replace('\r', '\x16\r') + self.line_break)
|
||||
#print("write: %s" % repr(data))
|
||||
self.stdin.write(data)
|
||||
|
||||
def cleanup(self):
|
||||
#print "cleaning up"
|
||||
|
Loading…
Reference in New Issue
Block a user