diff options
author | Michael Muré <batolettre@gmail.com> | 2019-11-10 13:14:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-10 13:14:42 +0100 |
commit | eaf963164cad17f87999f8a781ff9b688729b31c (patch) | |
tree | 68ecd87689ee16ad3de5a0e77dc13ad618fb6962 /vendor/github.com/awesome-gocui/gocui/gui_windows.go | |
parent | 318039df31b0846de85e6469d75c3fd5fe5a00a1 (diff) | |
parent | 965102f73c5a935bd35dde4ae27a187cdc5ad0ea (diff) | |
download | git-bug-eaf963164cad17f87999f8a781ff9b688729b31c.tar.gz |
Merge pull request #242 from MichaelMure/gocui
termui: migrate to awesome-gocui instead of the old fork I had
Diffstat (limited to 'vendor/github.com/awesome-gocui/gocui/gui_windows.go')
-rw-r--r-- | vendor/github.com/awesome-gocui/gocui/gui_windows.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/github.com/awesome-gocui/gocui/gui_windows.go b/vendor/github.com/awesome-gocui/gocui/gui_windows.go new file mode 100644 index 00000000..db1faab7 --- /dev/null +++ b/vendor/github.com/awesome-gocui/gocui/gui_windows.go @@ -0,0 +1,53 @@ +// Copyright 2014 The gocui Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package gocui + +import ( + "os" + "syscall" + "unsafe" +) + +type wchar uint16 +type short int16 +type dword uint32 +type word uint16 + +type coord struct { + x short + y short +} + +type smallRect struct { + left short + top short + right short + bottom short +} + +type consoleScreenBufferInfo struct { + size coord + cursorPosition coord + attributes word + window smallRect + maximumWindowSize coord +} + +var ( + kernel32 = syscall.NewLazyDLL("kernel32.dll") + procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") +) + +// getTermWindowSize is get terminal window size on windows. +func (g *Gui) getTermWindowSize() (int, int, error) { + var csbi consoleScreenBufferInfo + r1, _, err := procGetConsoleScreenBufferInfo.Call(os.Stdout.Fd(), uintptr(unsafe.Pointer(&csbi))) + if r1 == 0 { + return 0, 0, err + } + return int(csbi.window.right - csbi.window.left + 1), int(csbi.window.bottom - csbi.window.top + 1), nil +} |