Add terminal size lookup
This commit is contained in:
parent
e8ba6825aa
commit
835f550bbb
@ -8,6 +8,11 @@ import (
|
||||
"timshome.page/gilo/internal/terminal"
|
||||
)
|
||||
|
||||
type Editor struct {
|
||||
rows int
|
||||
cols int
|
||||
}
|
||||
|
||||
var reader = bufio.NewReader(os.Stdin)
|
||||
|
||||
func readKey() (rune, int) {
|
||||
|
@ -41,6 +41,16 @@ func ANSICode (code string) {
|
||||
fmt.Printf("\x1b[%s", code)
|
||||
}
|
||||
|
||||
func Size () (width int, height int) {
|
||||
width, height, err := term.GetSize(int(os.Stdin.Fd()))
|
||||
if err != nil {
|
||||
width = 80
|
||||
height = 24
|
||||
}
|
||||
|
||||
return width, height
|
||||
}
|
||||
|
||||
// Print a formatted string to stdout, with CRLF line endings for proper terminal formatting
|
||||
func OutLn(format string, a ...interface{}) {
|
||||
formatted := fmt.Sprintf(format, a...)
|
||||
|
Loading…
Reference in New Issue
Block a user