Documentation
¶
Overview ¶
Example (TabPrint) ¶
tp := NewTabPrinter(8)
for i := range 33 {
tp.Print(i)
}
tp.Println()
for _, v := range []string{"one", "two", "three", "four", "five", "six"} {
tp.Print(v)
}
tp.Println()
Output: 0 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 one two three four five six
Example (TabPrintTwoFullLines) ¶
tp := NewTabPrinter(4)
for _, v := range []string{"one", "two", "three", "four", "five", "six", "seven", "eight"} {
tp.Print(v)
}
tp.Println()
Output: one two three four five six seven eight
Example (TabPrintWider) ¶
tp := NewTabPrinter(2)
tp.TabWidth(10)
for _, v := range []string{"one", "two", "three", "four", "five", "six", "seven", "eight", "larger", "largest", "even more", "enough"} {
tp.Print(v)
}
tp.Println()
Output: one two three four five six seven eight larger largest even more enough
Index ¶
Examples ¶
Constants ¶
View Source
const ( DEFAULT_INDENT = " " DEFAULT_NIL = "nil" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Pretty ¶
type TabPrinter ¶
type TabPrinter struct {
// contains filtered or unexported fields
}
A TabPrinter is an object that allows printing tab-aligned words on multiple lines, up to a maximum number per line
func NewTabPrinter ¶
func NewTabPrinter(max int) *TabPrinter
create a TabPrinter max specifies the maximum number of 'words' per line
func (*TabPrinter) Print ¶
func (tp *TabPrinter) Print(arg any)
print a 'word' when the maximum number of words per lines is reached, this will print the formatted line
func (*TabPrinter) Println ¶
func (tp *TabPrinter) Println()
print current line terminate current line and print - call this after all words have been printed
func (*TabPrinter) TabWidth ¶
func (tp *TabPrinter) TabWidth(n int)
update tab width (minimal space between words)
Click to show internal directories.
Click to hide internal directories.