forked from k0kubun/go-ansi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cursor.go
52 lines (41 loc) · 882 Bytes
/
cursor.go
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
//go:build !windows
package ansi
import (
"fmt"
)
// Move the cursor n cells to up.
func CursorUp(n int) {
fmt.Printf("\x1b[%dA", n)
}
// Move the cursor n cells to down.
func CursorDown(n int) {
fmt.Printf("\x1b[%dB", n)
}
// Move the cursor n cells to right.
func CursorForward(n int) {
fmt.Printf("\x1b[%dC", n)
}
// Move the cursor n cells to left.
func CursorBack(n int) {
fmt.Printf("\x1b[%dD", n)
}
// Move cursor to beginning of the line n lines down.
func CursorNextLine(n int) {
fmt.Printf("\x1b[%dE", n)
}
// Move cursor to beginning of the line n lines up.
func CursorPreviousLine(n int) {
fmt.Printf("\x1b[%dF", n)
}
// Move cursor horizontally to x.
func CursorHorizontalAbsolute(x int) {
fmt.Printf("\x1b[%dG", x)
}
// Show the cursor.
func CursorShow() {
fmt.Print("\x1b[?25h")
}
// Hide the cursor.
func CursorHide() {
fmt.Print("\x1b[?25l")
}