Documentation
¶
Overview ¶
Package columnswriter imlements a write filter that prints evenly distributed columns fitted to current terminal window size.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
A Writer is a filter that prints evenly distributed columns
func (*Writer) Flush ¶
func (w *Writer) Flush()
Does the actual printing, always call this after everthing you want to print has been printed.
Example ¶
Example of how to call flush after you have written everything
// Print to stdout, input separated by spaces, no min widht, 2 spaces padding w := New(os.Stdout, ' ', 0, 2) w.nrTerminalColumns = 80 //for testing purposes, not necessary in real world fmt.Fprintln(w, `This is a test that has a lot of words and treats every `) fmt.Fprintln(w, `word as a column.`) fmt.Fprintln(w, `It should print nicely formatted columns similar to ls `) fmt.Fprintln(w, `directory lisings on nix systems.`) w.Flush()
Output: This is a test that has a lot of words and treats every word as a column. It should print nicely formatted columns similar to ls directory lisings on nix systems.
func (*Writer) Init ¶
A Writer must be initialized with a call to Init. The first pararmater (output) specifies the filter output. The inputSep is the character by wich each field is seperated in the input later on.
minWidth: Is the minimum widht of a column padding: The number of spaces between columns
Click to show internal directories.
Click to hide internal directories.