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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
# ansiterm
import "github.com/juju/ansiterm"
Package ansiterm provides a Writer that writes out the ANSI escape
codes for color and styles.
## type Color
``` go
type Color int
```
Color represents one of the standard 16 ANSI colors.
``` go
const (
Default Color
Black
Red
Green
Yellow
Blue
Magenta
Cyan
Gray
DarkGray
BrightRed
BrightGreen
BrightYellow
BrightBlue
BrightMagenta
BrightCyan
White
)
```
### func (Color) String
``` go
func (c Color) String() string
```
String returns the name of the color.
## type Context
``` go
type Context struct {
Foreground Color
Background Color
Styles []Style
}
```
Context provides a way to specify both foreground and background colors
along with other styles and write text to a Writer with those colors and
styles.
### func Background
``` go
func Background(color Color) *Context
```
Background is a convenience function that creates a Context with the
specified color as the background color.
### func Foreground
``` go
func Foreground(color Color) *Context
```
Foreground is a convenience function that creates a Context with the
specified color as the foreground color.
### func Styles
``` go
func Styles(styles ...Style) *Context
```
Styles is a convenience function that creates a Context with the
specified styles set.
### func (\*Context) Fprint
``` go
func (c *Context) Fprint(w sgrWriter, args ...interface{})
```
Fprint will set the sgr values of the writer to the specified foreground,
background and styles, then formats using the default formats for its
operands and writes to w. Spaces are added between operands when neither is
a string. It returns the number of bytes written and any write error
encountered.
### func (\*Context) Fprintf
``` go
func (c *Context) Fprintf(w sgrWriter, format string, args ...interface{})
```
Fprintf will set the sgr values of the writer to the specified
foreground, background and styles, then write the formatted string,
then reset the writer.
### func (\*Context) SetBackground
``` go
func (c *Context) SetBackground(color Color) *Context
```
SetBackground sets the background to the specified color.
### func (\*Context) SetForeground
``` go
func (c *Context) SetForeground(color Color) *Context
```
SetForeground sets the foreground to the specified color.
### func (\*Context) SetStyle
``` go
func (c *Context) SetStyle(styles ...Style) *Context
```
SetStyle replaces the styles with the new values.
## type Style
``` go
type Style int
```
``` go
const (
Bold Style
Faint
Italic
Underline
Blink
Reverse
Strikethrough
Conceal
)
```
### func (Style) String
``` go
func (s Style) String() string
```
## type TabWriter
``` go
type TabWriter struct {
Writer
// contains filtered or unexported fields
}
```
TabWriter is a filter that inserts padding around tab-delimited
columns in its input to align them in the output.
It also setting of colors and styles over and above the standard
tabwriter package.
### func NewTabWriter
``` go
func NewTabWriter(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter
```
NewTabWriter returns a writer that is able to set colors and styels.
The ansi escape codes are stripped for width calculations.
### func (\*TabWriter) Flush
``` go
func (t *TabWriter) Flush() error
```
Flush should be called after the last call to Write to ensure
that any data buffered in the Writer is written to output. Any
incomplete escape sequence at the end is considered
complete for formatting purposes.
### func (\*TabWriter) Init
``` go
func (t *TabWriter) Init(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter
```
A Writer must be initialized with a call to Init. The first parameter (output)
specifies the filter output. The remaining parameters control the formatting:
minwidth minimal cell width including any padding
tabwidth width of tab characters (equivalent number of spaces)
padding padding added to a cell before computing its width
padchar ASCII char used for padding
if padchar == '\t', the Writer will assume that the
width of a '\t' in the formatted output is tabwidth,
and cells are left-aligned independent of align_left
(for correct-looking results, tabwidth must correspond
to the tab width in the viewer displaying the result)
flags formatting control
## type Writer
``` go
type Writer struct {
io.Writer
// contains filtered or unexported fields
}
```
Writer allows colors and styles to be specified. If the io.Writer
is not a terminal capable of color, all attempts to set colors or
styles are no-ops.
### func NewWriter
``` go
func NewWriter(w io.Writer) *Writer
```
NewWriter returns a Writer that allows the caller to specify colors and
styles. If the io.Writer is not a terminal capable of color, all attempts
to set colors or styles are no-ops.
### func (\*Writer) ClearStyle
``` go
func (w *Writer) ClearStyle(s Style)
```
ClearStyle clears the text style.
### func (\*Writer) Reset
``` go
func (w *Writer) Reset()
```
Reset returns the default foreground and background colors with no styles.
### func (\*Writer) SetBackground
``` go
func (w *Writer) SetBackground(c Color)
```
SetBackground sets the background color.
### func (\*Writer) SetForeground
``` go
func (w *Writer) SetForeground(c Color)
```
SetForeground sets the foreground color.
### func (\*Writer) SetStyle
``` go
func (w *Writer) SetStyle(s Style)
```
SetStyle sets the text style.
- - -
Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)
|