зеркало из https://github.com/golang/term.git
ssh/terminal: fix GetSize on Windows
Return window size instead of buffer size. Fixes golang/go#27743 Change-Id: Ib1cd249f5680d86d505032e51d9102c2718ddf6f Reviewed-on: https://go-review.googlesource.com/c/163538 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Родитель
1fb3bd0768
Коммит
3fba1d1f88
|
@ -64,13 +64,15 @@ func Restore(fd int, state *State) error {
|
||||||
return windows.SetConsoleMode(windows.Handle(fd), state.mode)
|
return windows.SetConsoleMode(windows.Handle(fd), state.mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSize returns the dimensions of the given terminal.
|
// GetSize returns the visible dimensions of the given terminal.
|
||||||
|
//
|
||||||
|
// These dimensions don't include any scrollback buffer height.
|
||||||
func GetSize(fd int) (width, height int, err error) {
|
func GetSize(fd int) (width, height int, err error) {
|
||||||
var info windows.ConsoleScreenBufferInfo
|
var info windows.ConsoleScreenBufferInfo
|
||||||
if err := windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info); err != nil {
|
if err := windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info); err != nil {
|
||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
}
|
}
|
||||||
return int(info.Size.X), int(info.Size.Y), nil
|
return int(info.Window.Right - info.Window.Left + 1), int(info.Window.Bottom - info.Window.Top + 1), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadPassword reads a line of input from a terminal without local echo. This
|
// ReadPassword reads a line of input from a terminal without local echo. This
|
||||||
|
|
Загрузка…
Ссылка в новой задаче