mirror of
https://github.com/go-delve/delve.git
synced 2025-10-28 04:35:19 +08:00
terminal: use exact window size for pager (#3249)
Instead of using a fixed 100x30 window size query the operating system for the exact size, also fixes a bug where the last line before calling the pager is repeated twice.
This commit is contained in:
committed by
GitHub
parent
58fc3931e8
commit
2be9cf1fab
25
pkg/terminal/out_unix.go
Normal file
25
pkg/terminal/out_unix.go
Normal file
@ -0,0 +1,25 @@
|
||||
//go:build linux || darwin || freebsd
|
||||
// +build linux darwin freebsd
|
||||
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type winSize struct {
|
||||
row, col uint16
|
||||
xpixel, ypixel uint16
|
||||
}
|
||||
|
||||
func (w *pagingWriter) getWindowSize() {
|
||||
var ws winSize
|
||||
ok, _, _ := syscall.Syscall(syscall.SYS_IOCTL, uintptr(syscall.Stdout), syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&ws)))
|
||||
if int(ok) < 0 {
|
||||
w.mode = pagingWriterNormal
|
||||
return
|
||||
}
|
||||
w.lines = int(ws.row)
|
||||
w.columns = int(ws.col)
|
||||
}
|
||||
Reference in New Issue
Block a user