mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 11:17:52 +08:00
7a72b6346a
Non-portable ones are moved into new packages pkg/sys/e{unix windows}. The "e" prefix is needed to avoid conflict with packages under golang.org/x/sys/ and can mean "extra".
24 lines
514 B
Go
24 lines
514 B
Go
package sys
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
// Windows doesn't have SIGCH, so use an impossible value.
|
|
const sigWINCH = syscall.Signal(-1)
|
|
|
|
func winSize(file *os.File) (row, col int) {
|
|
var info windows.ConsoleScreenBufferInfo
|
|
err := windows.GetConsoleScreenBufferInfo(windows.Handle(file.Fd()), &info)
|
|
if err != nil {
|
|
fmt.Printf("error in winSize: %v", err)
|
|
return -1, -1
|
|
}
|
|
window := info.Window
|
|
return int(window.Bottom - window.Top), int(window.Right - window.Left)
|
|
}
|