Skip to content

Commit f712fd7

Browse files
committed
implement a getWinSize and setWinSize
1 parent cc454e9 commit f712fd7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

term_webassembly.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ type terminalState struct{}
1212

1313
// GetWinsize returns the window size based on the specified file descriptor.
1414
func getWinsize(fd uintptr) (*Winsize, error) {
15-
return nil, nil
15+
window := js.Global().Get("window")
16+
width := window.Get("innerWidth").Int()
17+
height := window.Get("innerHeight").Int()
18+
return &Winsize{width: width, Height: height}, nil
1619
}
1720

1821
func isTerminal(fd uintptr) bool {
@@ -46,6 +49,10 @@ func getFdInfo(in interface{}) (uintptr, bool) {
4649
}
4750

4851
func setWinsize(fd uintptr, ws *Winsize) error {
52+
window := js.Global().Get("window")
53+
window.Set("innerWidth", ws.Width)
54+
window.Set("innerHeight", ws.Height)
55+
4956
return nil
5057
}
5158

0 commit comments

Comments
 (0)