Size
#struct SizeThe size of a terminal window in character cells.
| Name | Type | Description |
|---|---|---|
rows | int = 0 | The number of rows. |
cols | int = 0 | The number of columns. |
import os.process
import os.pty
func main:
mut cmd := process.NewCommand("sh")
cmd.Arg("-c")
cmd.Arg("read line; stty size")
mut term := pty.Open(cmd, 24, 80)
println "start:", pty.GetSize(term).rows, pty.GetSize(term).cols
println "resized:", pty.Resize(term, 40, 120)
println "now:", pty.GetSize(term).rows, pty.GetSize(term).cols
term.Write("go\r")
out := term.ReadUntil("40 120", 2000)
println "child sees the new size:", not out.timed_out
out.Free()
println "exit:", term.Wait(2000).code
term.Close()
cmd.Free()
endstart: 24 80 resized: true now: 40 120 child sees the new size: true exit: 0