File: main.go

package info (click to toggle)
golang-github-atomicgo-cursor 0.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 184 kB
  • sloc: makefile: 2
file content (66 lines) | stat: -rw-r--r-- 1,443 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main

import (
	"fmt"
	"time"

	"atomicgo.dev/cursor"
)

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

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

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

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

	time.Sleep(1 * time.Second)
	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.Top()
	fmt.Print("<<< AFTER Top()")
	time.Sleep(1 * time.Second)
	area.Update(content + "(restored content after cursor top)")

	time.Sleep(1 * time.Second)
	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)")

	time.Sleep(1 * time.Second)
	fmt.Println("\n--- DONE")
}