mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-03 20:14:22 +02:00
Ensure initial PTY size matches Terminal (if any)
If a PTY has a terminal_path set to a valid Terminal, then ensure that the initial cols and rows of PTY match the cols and rows of the Terminal when calling fork() or open(), otherwise PTY will output wrong-sized data for the Terminal until resized. Fixes #56.
This commit is contained in:
parent
00a34a9177
commit
054c7c9ad4
4 changed files with 231 additions and 34 deletions
|
@ -46,12 +46,6 @@ enum Signal {
|
|||
# The process ID.
|
||||
var _pid: int
|
||||
|
||||
# The column size in characters.
|
||||
var cols: int = DEFAULT_COLS setget set_cols
|
||||
|
||||
# The row size in characters.
|
||||
var rows: int = DEFAULT_ROWS setget set_rows
|
||||
|
||||
# Environment to be set for the child program.
|
||||
var env := DEFAULT_ENV
|
||||
|
||||
|
@ -71,14 +65,6 @@ var _fd: int = -1
|
|||
var _exit_cb: FuncRef
|
||||
|
||||
|
||||
func set_cols(value: int):
|
||||
resize(value, rows)
|
||||
|
||||
|
||||
func set_rows(value: int):
|
||||
resize(cols, value)
|
||||
|
||||
|
||||
# Writes data to the socket.
|
||||
# data: The data to write.
|
||||
func write(data) -> void:
|
||||
|
@ -92,13 +78,8 @@ func write(data) -> void:
|
|||
|
||||
|
||||
func resize(cols: int, rows: int) -> void:
|
||||
if cols <= 0 or rows <= 0 or cols == NAN or rows == NAN or cols == INF or rows == INF:
|
||||
push_error("Resizing must be done using positive cols and rows.")
|
||||
|
||||
if _fd < 0:
|
||||
return
|
||||
|
||||
PTYUnix.new().resize(_fd, cols, rows)
|
||||
if _fd >= 0:
|
||||
PTYUnix.new().resize(_fd, cols, rows)
|
||||
|
||||
|
||||
func kill(signum: int = Signal.SIGHUP) -> void:
|
||||
|
@ -135,8 +116,8 @@ func fork(
|
|||
file: String = OS.get_environment("SHELL"),
|
||||
args: PoolStringArray = PoolStringArray(),
|
||||
cwd = LibuvUtils.get_cwd(),
|
||||
p_cols: int = DEFAULT_COLS,
|
||||
p_rows: int = DEFAULT_ROWS,
|
||||
cols: int = DEFAULT_COLS,
|
||||
rows: int = DEFAULT_ROWS,
|
||||
uid: int = -1,
|
||||
gid: int = -1,
|
||||
utf8 = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue