Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCustomTerminalWidth ¶
func GetCustomTerminalWidth() int
Types ¶
type CTW ¶
type LongCTW ¶
type LongCTW struct {
// contains filtered or unexported fields
}
LongCTW is a specialized column-table-writer for "long" listings. It contains logic to store data rows, compute column widths, and handle colorization for icons and Git status columns.
func NewLongCTW ¶
NewLongCTW creates a new LongCTW that is set up to have `cols` columns.
If cols = 5, for example, internally it will treat it as numCols = 4. This code historically assumes there's a special 'git column' plus an 'icon column'.
func (*LongCTW) AddRow ¶
AddRow appends a new row to the table.
The first parameter, iconColor, is the color that will be used to print the "icon column" for this row. The remaining arguments are the data for each column. The length of args must be exactly numCols+1.
func (*LongCTW) Flush ¶
Flush writes the entire table to the provided buffer.
It will skip columns that end up with zero-width, and it overrides certain columns (like the 'git column' and the 'icon column') to have explicit widths.
func (LongCTW) GetGitColor ¶
type StandardCTW ¶
type StandardCTW struct {
// contains filtered or unexported fields
}
StandardCTW is a specialized column-table-writer for a "standard" listing. Unlike LongCTW, it tries to fit multiple columns of data in the available terminal width, along with optional icons and Git status columns.
Each row has up to 4 sub-columns in the following order:
- size
- icon
- name + extension + indicator
- gitStatus
func NewStandardCTW ¶
func NewStandardCTW(termW int) *StandardCTW
NewStandardCTW creates a new StandardCTW, specifying the terminal width. The internal `numCols` is fixed at 3 (which yields 4 sub-columns: size, icon, name, gitStatus).
func (*StandardCTW) AddRow ¶
func (s *StandardCTW) AddRow(color string, args ...string)
AddRow appends a new row to the table, each row having exactly 4 pieces of data:
size, icon, name, gitStatus
color is the ANSI color code for the icon column.
func (*StandardCTW) Flush ¶
func (s *StandardCTW) Flush(buf *bytes.Buffer)
Flush calculates how to best fit columns into the given terminal width, then prints them all to buf.