Documentation
¶
Index ¶
- Constants
- Variables
- type Flags
- func (f Flags) AlignmentString() string
- func (f Flags) CmpSign() int
- func (f *Flags) DisableSort()
- func (f *Flags) EnableSort()
- func (f Flags) HasPriority() bool
- func (f Flags) IsAlignedCenter() bool
- func (f Flags) IsAlignedDefault() bool
- func (f Flags) IsAlignedLeft() bool
- func (f Flags) IsAlignedNumber() bool
- func (f Flags) IsAlignedPivot() bool
- func (f Flags) IsAlignedRight() bool
- func (f Flags) IsAlignedVersion() bool
- func (f Flags) IsAlignment() bool
- func (f Flags) IsAscendingOrder() bool
- func (f Flags) IsConfigured() bool
- func (f Flags) IsDescendingOrder() bool
- func (f Flags) IsSorted() bool
- func (f *Flags) ResetSort()
- func (f *Flags) ReverseSort()
- func (f *Flags) SetAlignment(flags Flags)
- func (f *Flags) SetSort(s Flags)
- func (f *Flags) SetSortPriority(prio int)
- func (f Flags) SortPriority() int
- func (f Flags) String() string
- type Index
- func (i *Index) At(pos int) *Info
- func (i Index) Clone() Index
- func (i *Index) Column(name string) *Info
- func (i *Index) ColumnNames() []string
- func (i *Index) FindLocation(loc Locator) int
- func (i *Index) FindName(want string) (position int, strategy string)
- func (i *Index) GrowTo(targetSize int)
- func (i *Index) HasPostion(pos int) bool
- func (i *Index) InitFlags(flags []Flags)
- func (i *Index) InitNames(names []string)
- func (i *Index) Len() int
- func (i *Index) Position(name string) int
- func (i *Index) ResetPositions()
- func (i *Index) SetNames(names []string)
- func (i *Index) String() string
- func (i *Index) Trim()
- type Info
- type Locator
- type Option
- func AlignCenter() Option
- func AlignLeft() Option
- func AlignNumber() Option
- func AlignRight() Option
- func AlignVersion() Option
- func SetAlignment(flags Flags) Option
- func SetFlags(flags, mask Flags) Option
- func SetSort(flags Flags) Option
- func SortAscending() Option
- func SortDescending() Option
- func SortWithPriority(prio int) Option
- type Width
Constants ¶
const ( UnconfiguredFlags Flags = 0b000_00_000 // .... .... - an unconfigured column: default alignment, no sorting AlignDefaultFlag Flags = 0b000_00_000 // .... .000 - default alignment (left aligned, but without a ruler hint) AlignRightFlag Flags = 0b000_00_001 // .... .001 - align text to the right of the column AlignLeftFlag Flags = 0b000_00_100 // .... .100 - align text to the left of the column AlignCenterFlag Flags = 0b000_00_010 // .... .010 - center text within the column (psv style |--:--|) AlignCenterAltFlag Flags = 0b000_00_101 // .... .101 - center text within the columna (markdown style |:---:|) AlignNumberFlag Flags = 0b000_00_011 // .... .011 - align numbers around their decimal point, otherwise right aligned AlignVersionFlag Flags = 0b000_00_110 // .... .110 - align on first point or left, sort using integer numbers only AlignPivotMask Flags = 0b000_00_010 // .... ..1. - align content relative to a calculated "pivot" position AlignFlagsMask Flags = 0b000_00_111 // .... .111 SortEnabledFlag Flags = 0b000_01_000 // .... 1... - indicate that the column should be sorted (default: no sorting) SortColumnMask Flags = 0b000_01_000 // .... 1... SortAscendingFlag Flags = 0b000_00_000 // ...0 1... - only valid in combination with FlagSortColumn SortDescendingFlag Flags = 0b000_10_000 // ...1 1... - only valid in combination with FlagSortColumn SortDirectionMask Flags = 0b000_10_000 // ...1 .... SortFlagsMask Flags = 0b000_11_000 // ...1 1... SortPriorityMask Flags = 0b111_00_000 // 111. .... - 1 .. 7 only - only only valid in combination with FlagSortColumn AllFlagsMask Flags = 0b111_11_111 // 1111 1111 SortPriorityShift int = 5 // 111. .... == .... .111 << 5 )
const ( FirstPosition = 0 LastPosition = -1 )
Variables ¶
var SearchStrategies = []strategyProvider{
&stringEqualityStrategy{name: "full exact"},
®exStrategy{name: "lone number", beforeRE: `(^|\W)`, afterRE: `(\W|$)`, validate: `^\d+$`},
®exStrategy{name: "embedded number", beforeRE: `(^|\D)`, afterRE: `(\D|$)`, validate: `^\d+$`},
®exStrategy{name: "prefix exact", beforeRE: `^`, afterRE: ``},
®exStrategy{name: "word exact", beforeRE: `\b`, afterRE: `\b`, validate: `^\w(.*\w)?$`},
®exStrategy{name: "word prefix exact", beforeRE: `\b`, afterRE: ``, validate: `^\w(.*\w)?$`},
®exStrategy{name: "any exact", beforeRE: ``, afterRE: ``},
®exStrategy{name: "full relaxed", beforeRE: `(?i)^`, afterRE: `$`},
®exStrategy{name: "prefix relaxed", beforeRE: `(?i)^`, afterRE: ``},
®exStrategy{name: "word relaxed", beforeRE: `(?i)\b`, afterRE: `\b`, validate: `^\w(.*\w)?$`},
®exStrategy{name: "word prefix relaxed", beforeRE: `(?i)\b`, afterRE: ``, validate: `^\w(.*\w)?$`},
®exStrategy{name: "any relaxed", beforeRE: `(?i)`, afterRE: ``},
}
Functions ¶
This section is empty.
Types ¶
type Flags ¶
type Flags byte
Flags flags are used to specify how a column should be prepared for rendering.
- Alignment - Sorting (incl. sort priority, between 0 and 7)
func FlagsFromString ¶
FlagsFromString parses a Flags string and returns a flags byte
Assumption: all flags strings are 7-bit ASCII
Examples:
| string | flags | | | ------ | --------------------------------------------------------- | -------------------------------- | | | none | empty string, no hints, no flags | | l | left aligned | | | c | center aligned | | | r | right aligned | | | sa | sort ascending | | | nsa | align and sort numerically, in ascending order | | | vsd3 | align and sort by version, in descending order and prio 3 | |
func (Flags) AlignmentString ¶
func (Flags) CmpSign ¶
CmpSign returns -1, 0 or +1 depending on the columne's sort configuration
- -1 for descending order
- 0 for no sort
- +1 for ascending order
func (*Flags) DisableSort ¶
func (f *Flags) DisableSort()
func (*Flags) EnableSort ¶
func (f *Flags) EnableSort()
func (Flags) HasPriority ¶
func (Flags) IsAlignedCenter ¶
func (Flags) IsAlignedDefault ¶
func (Flags) IsAlignedLeft ¶
func (Flags) IsAlignedNumber ¶
func (Flags) IsAlignedPivot ¶
func (Flags) IsAlignedRight ¶
func (Flags) IsAlignedVersion ¶
func (Flags) IsAlignment ¶
func (Flags) IsAscendingOrder ¶
func (Flags) IsConfigured ¶
func (Flags) IsDescendingOrder ¶
func (*Flags) ReverseSort ¶
func (f *Flags) ReverseSort()
func (*Flags) SetAlignment ¶
func (*Flags) SetSortPriority ¶
SetSortPriority sets the priority used when determining which columns to compare, and in what order, when sorting rows
Setting a column's priority does not enable or disable a column's sort status. (Setting a columns priority should always be compbined with EnableSort())
func (Flags) SortPriority ¶
SortPriority returns the sort-priority of the column.
Invariants:
- only values between 0 and 7 will be returned
- 0 indicates 'no special priority'
func (Flags) String ¶
String returns a string representing the alignment and sorting configuration of the column.
The string will have 0, 1, 2 or 3 positional characters for the alignment, sorting direction and sorting priority.
- "" indicates a default column without any alignment or sorting preferences
- justification character: "l" - left justified "r" - right justified "c" - center justified "n" - justified to decimal point (numerically) "v" - justify to major version number
- sorting direction character: "^" - sort column from lowest to highest values "V" - sort column from highest to lowest values
- sorting priority character: [0…7] - comparison priority of the column when sorting
e.g.: "nv2" would indicate "numeric alignment", "sorted in descending order" and "compared with priority 3 while sorting"
type Index ¶
type Index struct {
Info []Info
}
func (*Index) At ¶
At returns the column.Info for a column, indexed by its position in the index.
The index will grow if necessary
func (*Index) ColumnNames ¶
func (*Index) FindLocation ¶
func (*Index) FindName ¶
FindName searches for a column by name and returns the index of the column and the name of the strategy that found the matching name
func (*Index) HasPostion ¶
func (*Index) ResetPositions ¶
func (i *Index) ResetPositions()
ResetPositions re-numbers all of the columns so that their .Position value represents their current position in the column index.
Purpose:
- this is called after applying commands to columns (re-arranging, adding, removing)
type Info ¶
type Locator ¶
type Locator struct {
IsKeyword bool // the position was specified by keyword (stored in Name)
IsPosition bool // column was specifed by number
Position int // position of the column
Name string // column name to search for
}
Locator is used to identify a column depending on how the column was specified, in order of priority: - via keywords "first" or "last" - as an integer number, e.g. 3, 5, 11 etc (starting at 1) - as a name to be searched
type Option ¶
func AlignCenter ¶
func AlignCenter() Option
func AlignNumber ¶
func AlignNumber() Option
func AlignRight ¶
func AlignRight() Option
func AlignVersion ¶
func AlignVersion() Option
func SetAlignment ¶
func SortAscending ¶
func SortAscending() Option
func SortDescending ¶
func SortDescending() Option