-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
up: builtin, helper - update some helper util func
- Loading branch information
Showing
7 changed files
with
25 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package genac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package genac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package genac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,3 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
package helper | ||
|
||
import ( | ||
"syscall" | ||
|
||
"golang.org/x/crypto/ssh/terminal" | ||
) | ||
|
||
// GetTerminalSize for current console terminal. | ||
func GetTerminalSize(refresh ...bool) (w int, h int) { | ||
if terminalWidth > 0 && len(refresh) > 0 && !refresh[0] { | ||
return terminalWidth, terminalHeight | ||
} | ||
|
||
var err error | ||
w, h, err = terminal.GetSize(syscall.Stdin) | ||
if err != nil { | ||
return | ||
} | ||
|
||
// cache result | ||
terminalWidth, terminalHeight = w, h | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1 @@ | ||
package helper | ||
|
||
import ( | ||
"syscall" | ||
|
||
"golang.org/x/crypto/ssh/terminal" | ||
) | ||
|
||
// GetTerminalSize for current console terminal. | ||
func GetTerminalSize(refresh ...bool) (w int, h int) { | ||
if terminalWidth > 0 && len(refresh) > 0 && !refresh[0] { | ||
return terminalWidth, terminalHeight | ||
} | ||
|
||
var err error | ||
w, h, err = terminal.GetSize(int(syscall.Stdin)) | ||
if err != nil { | ||
return | ||
} | ||
|
||
// cache result | ||
terminalWidth, terminalHeight = w, h | ||
return | ||
} |