Source File
tabwriter.go
Belonging Package
text/tabwriter
package tabwriter
import (
)
buf []byte // collected text excluding tabs or line breaks
pos int // buffer position up to which cell.width of incomplete cell has been computed
cell cell // current incomplete cell; cell.width is up to buf[pos] excluding ignored sections
endChar byte // terminating char of escaped sequence (Escape for escapes, '>', ';' for HTML tags/entities, or 0)
lines [][]cell // list of lines; each line is a list of cells
widths []int // list of column widths in runes - re-used during formatting
}
FilterHTML uint = 1 << iota
Debug
)
&^= AlignRight
}
.flags =
.reset()
return
}
type osError struct {
err error
}
func ( *Writer) ( []byte) {
, := .output.Write()
if != len() && == nil {
= io.ErrShortWrite
}
if != nil {
panic(osError{})
}
}
func ( *Writer) ( []byte, int) {
for > len() {
.write0()
-= len()
}
.write0([0:])
}
var (
newline = []byte{'\n'}
tabs = []byte("\t\t\t\t\t\t\t\t")
)
func ( *Writer) (, int, bool) {
if .tabwidth == 0 {
return // tabs have no width - can't do any padding
if < len(.widths) {
.writePadding(.width, .widths[], )
}
= .writeLines(, , )
=
if && .flags&DiscardEmptyColumns != 0 {
= 0
}
return .writeLines(, , )
}
const Escape = '\xff'
func ( *Writer) () ( error) {
defer .handlePanic(&, "Flush")
.flushNoDefers()
return nil
}
.endEscape()
}
.terminateCell(false)
}
func ( *Writer) ( []byte) ( int, error) {
defer .handlePanic(&, "Write")
= 0
for , := range {
switch {
.append([:])
.updateWidth()
= + 1 // ch consumed
:= .terminateCell( == '\t')
.addLine( == '\f')
.append([:])
.updateWidth()
=
if .flags&StripEscape != 0 {
++ // strip Escape
}
.startEscape(Escape)
.append([:])
.updateWidth()
=
.startEscape()
}
}
:= + 1
if == Escape && .flags&StripEscape != 0 {
= // strip Escape
}
.append([:])
= + 1 // ch consumed
.endEscape()
}
}
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |