forked from charmbracelet/bubbletea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen.go
53 lines (40 loc) · 1.01 KB
/
screen.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
53
package tea
import (
"fmt"
"io"
te "github.com/muesli/termenv"
)
func hideCursor(w io.Writer) {
fmt.Fprintf(w, te.CSI+te.HideCursorSeq)
}
func showCursor(w io.Writer) {
fmt.Fprintf(w, te.CSI+te.ShowCursorSeq)
}
func clearLine(w io.Writer) {
fmt.Fprintf(w, te.CSI+te.EraseLineSeq, 2)
}
func cursorUp(w io.Writer) {
fmt.Fprintf(w, te.CSI+te.CursorUpSeq, 1)
}
func cursorDown(w io.Writer) {
fmt.Fprintf(w, te.CSI+te.CursorDownSeq, 1)
}
func insertLine(w io.Writer, numLines int) {
fmt.Fprintf(w, te.CSI+"%dL", numLines)
}
func moveCursor(w io.Writer, row, col int) {
fmt.Fprintf(w, te.CSI+te.CursorPositionSeq, row, col)
}
func changeScrollingRegion(w io.Writer, top, bottom int) {
fmt.Fprintf(w, te.CSI+te.ChangeScrollingRegionSeq, top, bottom)
}
func cursorBack(w io.Writer, n int) {
fmt.Fprintf(w, te.CSI+te.CursorBackSeq, n)
}
func enterAltScreen(w io.Writer) {
fmt.Fprintf(w, te.CSI+te.AltScreenSeq)
moveCursor(w, 0, 0)
}
func exitAltScreen(w io.Writer) {
fmt.Fprintf(w, te.CSI+te.ExitAltScreenSeq)
}