diff --git a/internal/editor/editor.go b/internal/editor/editor.go index 6c5f9cd..8142232 100644 --- a/internal/editor/editor.go +++ b/internal/editor/editor.go @@ -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) { diff --git a/internal/terminal/terminal.go b/internal/terminal/terminal.go index fa9f735..4d48483 100644 --- a/internal/terminal/terminal.go +++ b/internal/terminal/terminal.go @@ -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...)