Update terminalManagement

This commit is contained in:
chrys87 2017-08-24 11:25:59 +02:00 committed by GitHub
parent 640bffa05b
commit 9d98976fdb

View File

@ -32,14 +32,13 @@ class Terminal:
return {"c": (cursor.x, cursor.y), "lines": lines} return {"c": (cursor.x, cursor.y), "lines": lines}
def open_terminal(command="bash", columns=80, lines=25): def open_terminal(command="bash", columns=80, lines=24):
p_pid, master_fd = pty.fork() p_pid, master_fd = pty.fork()
print('PID',p_pid) print('PID',p_pid)
if p_pid == 0: # Child. if p_pid == 0: # Child.
argv = shlex.split(command) argv = shlex.split(command)
env = dict(TERM="linux", LC_ALL=sys.stdout.encoding, env = os.environ.copy()
COLUMNS=str(columns), LINES=str(lines)) env["TERM"] = 'vt100'
#env = os.environ.copy()
os.execvpe(argv[0], argv, env) os.execvpe(argv[0], argv, env)
# File-like object for I/O with the child process aka command. # File-like object for I/O with the child process aka command.
p_out = os.fdopen(master_fd, "w+b", 0) p_out = os.fdopen(master_fd, "w+b", 0)
@ -116,11 +115,11 @@ def resize_terminal(fd):
return rows, cols return rows, cols
def read_all(fd): def read_all(fd):
bytes = os.read(fd, 4096) bytes = os.read(fd, 65536)
if bytes == b'': if bytes == b'':
raise EOFError raise EOFError
while has_more(fd): while has_more(fd):
data = os.read(fd, 4096) data = os.read(fd, 65536)
if data == b'': if data == b'':
raise EOFError raise EOFError
bytes += data bytes += data