Skip to content

Commit a19195c

Browse files
committed
update godoc for some functions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent d916581 commit a19195c

3 files changed

Lines changed: 20 additions & 15 deletions

File tree

aec.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,83 +42,83 @@ var (
4242
Report ANSI = newAnsi(esc + "6n")
4343
)
4444

45-
// Up moves up the cursor.
45+
// Up moves the cursor up by n positions (CUU).
4646
func Up(n uint) ANSI {
4747
if n == 0 {
4848
return empty
4949
}
5050
return newAnsi(fmt.Sprintf(esc+"%dA", n))
5151
}
5252

53-
// Down moves down the cursor.
53+
// Down moves the cursor down by n positions (CUD).
5454
func Down(n uint) ANSI {
5555
if n == 0 {
5656
return empty
5757
}
5858
return newAnsi(fmt.Sprintf(esc+"%dB", n))
5959
}
6060

61-
// Right moves right the cursor.
61+
// Right moves the cursor right by n positions (CUF).
6262
func Right(n uint) ANSI {
6363
if n == 0 {
6464
return empty
6565
}
6666
return newAnsi(fmt.Sprintf(esc+"%dC", n))
6767
}
6868

69-
// Left moves left the cursor.
69+
// Left moves the cursor left by n positions (CUB).
7070
func Left(n uint) ANSI {
7171
if n == 0 {
7272
return empty
7373
}
7474
return newAnsi(fmt.Sprintf(esc+"%dD", n))
7575
}
7676

77-
// NextLine moves down the cursor to head of a line.
77+
// NextLine moves the cursor down n lines and to the beginning of the line (CNL).
7878
func NextLine(n uint) ANSI {
7979
if n == 0 {
8080
return empty
8181
}
8282
return newAnsi(fmt.Sprintf(esc+"%dE", n))
8383
}
8484

85-
// PreviousLine moves up the cursor to head of a line.
85+
// PreviousLine moves the cursor up n lines and to the beginning of the line (CPL).
8686
func PreviousLine(n uint) ANSI {
8787
if n == 0 {
8888
return empty
8989
}
9090
return newAnsi(fmt.Sprintf(esc+"%dF", n))
9191
}
9292

93-
// Column set the cursor position to a given column.
93+
// Column sets the cursor position to a given column (CHA).
9494
func Column(col uint) ANSI {
9595
return newAnsi(fmt.Sprintf(esc+"%dG", col))
9696
}
9797

98-
// Position set the cursor position to a given absolute position.
98+
// Position sets the cursor position to a given absolute position (CUP).
9999
func Position(row, col uint) ANSI {
100100
return newAnsi(fmt.Sprintf(esc+"%d;%dH", row, col))
101101
}
102102

103-
// EraseDisplay erases display by given EraseMode.
103+
// EraseDisplay erases the display using the given EraseMode (ED).
104104
func EraseDisplay(m EraseMode) ANSI {
105105
return newAnsi(fmt.Sprintf(esc+"%dJ", m))
106106
}
107107

108-
// EraseLine erases lines by given EraseMode.
108+
// EraseLine erases the line using the given EraseMode (EL).
109109
func EraseLine(m EraseMode) ANSI {
110110
return newAnsi(fmt.Sprintf(esc+"%dK", m))
111111
}
112112

113-
// ScrollUp scrolls up the page.
113+
// ScrollUp scrolls the display up by n lines (SU).
114114
func ScrollUp(n int) ANSI {
115115
if n == 0 {
116116
return empty
117117
}
118118
return newAnsi(fmt.Sprintf(esc+"%dS", n))
119119
}
120120

121-
// ScrollDown scrolls down the page.
121+
// ScrollDown scrolls the display down by n lines (SD).
122122
func ScrollDown(n int) ANSI {
123123
if n == 0 {
124124
return empty

ansi.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
const esc = "\x1b["
99

1010
// Reset resets SGR effect.
11-
const Reset string = "\x1b[0m"
11+
const Reset = "\x1b[0m"
1212

1313
var empty = newAnsi("")
1414

@@ -23,33 +23,38 @@ type ANSI interface {
2323
Apply(string) string
2424
}
2525

26+
// ansiImpl represents an ANSI escape code.
2627
type ansiImpl string
2728

2829
func newAnsi(s string) *ansiImpl {
2930
r := ansiImpl(s)
3031
return &r
3132
}
3233

34+
// With returns a new ANSICode sequence composed of this and the provided ANSI codes.
3335
func (a *ansiImpl) With(ansi ...ANSI) ANSI {
3436
return concat(append([]ANSI{a}, ansi...))
3537
}
3638

39+
// Apply wraps the given string with the ANSI sequence and a reset code.
3740
func (a *ansiImpl) Apply(s string) string {
3841
return a.String() + s + Reset
3942
}
4043

44+
// String returns the ANSICode escape code as a string.
4145
func (a *ansiImpl) String() string {
4246
return string(*a)
4347
}
4448

45-
// Apply wraps given string in ANSIs.
49+
// Apply wraps the given string with all provided ANSI sequences.
4650
func Apply(s string, ansi ...ANSI) string {
4751
if len(ansi) == 0 {
4852
return s
4953
}
5054
return concat(ansi).Apply(s)
5155
}
5256

57+
// concat combines multiple ANSI codes into a single ANSI sequence.
5358
func concat(ansi []ANSI) ANSI {
5459
strs := make([]string, 0, len(ansi))
5560
for _, p := range ansi {

sgr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func FullColorF(r, g, b uint8) ANSI {
4949
return newAnsi(fmt.Sprintf(esc+"38;2;%d;%d;%dm", r, g, b))
5050
}
5151

52-
// FullColorB set the foreground color of text.
52+
// FullColorB set the background color of text.
5353
func FullColorB(r, g, b uint8) ANSI {
5454
return newAnsi(fmt.Sprintf(esc+"48;2;%d;%d;%dm", r, g, b))
5555
}

0 commit comments

Comments
 (0)