From c814ccae9ad2f140dd0aa7ae11a17707e404094e Mon Sep 17 00:00:00 2001 From: Cheney Date: Mon, 28 Sep 2015 09:46:33 +0800 Subject: [PATCH] fix build in windows --- utils.go | 5 +++++ utils_unix.go | 4 ---- utils_windows.go | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/utils.go b/utils.go index 199ec5c..c880be3 100644 --- a/utils.go +++ b/utils.go @@ -1,11 +1,16 @@ package readline import ( + "syscall" "unicode" "golang.org/x/crypto/ssh/terminal" ) +var ( + StdinFd = int(uintptr(syscall.Stdin)) +) + // IsTerminal returns true if the given file descriptor is a terminal. func IsTerminal(fd int) bool { return terminal.IsTerminal(fd) diff --git a/utils_unix.go b/utils_unix.go index d022da8..0937b28 100644 --- a/utils_unix.go +++ b/utils_unix.go @@ -7,10 +7,6 @@ import ( "unsafe" ) -var ( - StdinFd = syscall.Stdin -) - type winsize struct { Row uint16 Col uint16 diff --git a/utils_windows.go b/utils_windows.go index 3905492..859908c 100644 --- a/utils_windows.go +++ b/utils_windows.go @@ -33,7 +33,6 @@ type ( ) var ( - StdinFd = 0 kernel32 = syscall.NewLazyDLL("kernel32.dll") tmp_info console_screen_buffer_info @@ -63,5 +62,5 @@ func get_term_size(out syscall.Handle) coord { // get width of the terminal func getWidth() int { - return int(get_term_size(syscall.Stdin).x) + return int(get_term_size(syscall.Stdout).x) }