diff --git a/README.md b/README.md index b436754..70d24d4 100644 --- a/README.md +++ b/README.md @@ -253,7 +253,7 @@ func UpAndClear(n int) UpAndClear moves the cursor up by n lines, then clears the line. -## type [Area]() +## type [Area]() Area displays content which can be updated on the fly. You can use this to create live output, charts, dropdowns, etc. @@ -263,7 +263,7 @@ type Area struct { } ``` -### func [NewArea]() +### func [NewArea]() ```go func NewArea() Area @@ -271,7 +271,7 @@ func NewArea() Area NewArea returns a new Area. -### func \(\*Area\) [Clear]() +### func \(\*Area\) [Clear]() ```go func (area *Area) Clear() @@ -279,7 +279,7 @@ func (area *Area) Clear() Clear clears the content of the Area. -### func \(\*Area\) [Update]() +### func \(\*Area\) [Update]() ```go func (area *Area) Update(content string) diff --git a/area.go b/area.go index e8cd72d..91909ba 100644 --- a/area.go +++ b/area.go @@ -2,7 +2,6 @@ package cursor import ( "fmt" - "runtime" "strings" ) @@ -28,22 +27,8 @@ func (area *Area) Clear() { // Update overwrites the content of the Area. func (area *Area) Update(content string) { area.Clear() - lines := strings.Split(content, "\n") - - fmt.Println(strings.Repeat("\n", len(lines)-1)) // This appends space if the terminal is at the bottom - Up(len(lines)) - - if runtime.GOOS == "windows" { - for _, line := range lines { - fmt.Print(line) - StartOfLineDown(1) - } - } else { - for _, line := range lines { - fmt.Println(line) - } - } + fmt.Println(content) height = 0 - area.height = len(lines) + area.height = len(strings.Split(content, "\n")) } diff --git a/cursor_windows.go b/cursor_windows.go index 0a3be0a..9a6173b 100644 --- a/cursor_windows.go +++ b/cursor_windows.go @@ -97,7 +97,7 @@ func Hide() { _, _, _ = procSetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&cci))) } -// ClearLine clears the current line and moves the cursor to it's start position. +// ClearLine clears the current line and moves the cursor to its start position. func ClearLine() { handle := syscall.Handle(target.Fd())