Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Bug when terminal has no space down and a new area is created #10

Merged
merged 2 commits into from
Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func Hide()
```
Hide the cursor. Don't forget to show the cursor at least at the end of your
application with Show. Otherwise the user might have a terminal with a
permanently hidden cursor, until he reopens the terminal.
permanently hidden cursor, until they reopen the terminal.

#### func HorizontalAbsolute

Expand Down Expand Up @@ -173,7 +173,8 @@ position.
```go
func SetTarget(w Writer)
```
SetTarget allows for any arbitrary Writer to be used
SetTarget allows for any arbitrary io.Writer to be used for cursor movement
(will not work on Windows).

#### func Show

Expand All @@ -182,7 +183,7 @@ func Show()
```
Show the cursor if it was hidden previously. Don't forget to show the cursor at
least at the end of your application. Otherwise the user might have a terminal
with a permanently hidden cursor, until he reopens the terminal.
with a permanently hidden cursor, until they reopen the terminal.

#### func StartOfLine

Expand Down
4 changes: 4 additions & 0 deletions area.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func (area *Area) Clear() {
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)
Expand Down