Skip to content

Commit

Permalink
Final cleanup for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lammel committed Jul 28, 2023
1 parent ec37172 commit 009272c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 77 deletions.
35 changes: 0 additions & 35 deletions _examples/area/demo/main.go

This file was deleted.

28 changes: 18 additions & 10 deletions _examples/area/movement/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,56 @@ import (
)

func main() {
fmt.Println("Multiline cursor area demo")
fmt.Println("Cursor area movement demo")
fmt.Println("--------------------------")

area := cursor.NewArea()
content := `Start content with multiple rows
content := `Start content with some rows
1. Row1
2. Row2
3. Row3
---
`
area.Update(content)

time.Sleep(1 * time.Second)
area.Up(3)
area.Up(2)
area.Move(3, 0)
fmt.Print("Replaced row 2")

time.Sleep(1 * time.Second)
area.StartOfLine()
area.Move(8, -2)
fmt.Print("Appended stuff")
area.Move(8, -1)
fmt.Print("3. Appended row")

time.Sleep(1 * time.Second)
area.Update(content + "(restored content)")
area.Update(content + "(restored content after move)")

time.Sleep(1 * time.Second)
area.Up(6)
fmt.Print("<<< AFTER Up(6)")
time.Sleep(1 * time.Second)
area.Update(content + "(restored content after cursor up out of bounds)")

time.Sleep(1 * time.Second)
area.Down(6)
fmt.Print("<<< AFTER Down(6)")
time.Sleep(1 * time.Second)
area.Update(content + "(restored content after cursor down out of bounds)")

time.Sleep(1 * time.Second)
area.Update("Show only single line now")
area.Top()
fmt.Print("<<< AFTER Top()")
time.Sleep(1 * time.Second)
area.Update(content + "(restored content after cursor top)")

time.Sleep(1 * time.Second)
area.Update(content + "(restored content after single line)")
area.Bottom()
fmt.Print("<<< AFTER Bottom()")
time.Sleep(1 * time.Second)
area.Update(content + "(restored content after cursor bottom)")

time.Sleep(1 * time.Second)
area.Update("")

time.Sleep(1 * time.Second)
area.Update(content + "(restored content after empty line)")

Expand Down
2 changes: 2 additions & 0 deletions _examples/area/multiline/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func main() {
area.Update(content)
}

time.Sleep(1 * time.Second)
area.Update("Test varying area sizes now")
time.Sleep(500 * time.Millisecond)
area.Update(buildContent(1, 2))
time.Sleep(500 * time.Millisecond)
Expand Down
12 changes: 10 additions & 2 deletions _examples/area/singleline/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ func main() {
fmt.Println("Single line cursor area demo")
fmt.Println("----------------------------")

header := "This is a singleline without newline"
area := cursor.NewArea()

header := "This is a singleline without newline"
area.Update(header)
for i := 1; i < 10; i++ {
for i := 1; i < 6; i++ {
time.Sleep(1 * time.Second)
area.Update(fmt.Sprintf("%s: %d", header, i))
}

header = "This is a singleline with newline"
area.Update(header + "\n")
for i := 1; i < 6; i++ {
time.Sleep(1 * time.Second)
area.Update(fmt.Sprintf("%s: %d\n", header, i))
}

time.Sleep(1 * time.Second)
fmt.Println("\n--- DONE")
}
30 changes: 0 additions & 30 deletions _examples/area/singlenewline/main.go

This file was deleted.

0 comments on commit 009272c

Please sign in to comment.