Documentation
¶
Index ¶
- Constants
- func TruncateBasedOnStyle(line string, maxWidth int, truncateStyle TruncateStyle) string
- type BorderConfig
- type ContentRenderer
- type Renderer
- func (r *Renderer) AddLineWithCustomTruncate(line string, truncateStyle TruncateStyle)
- func (r *Renderer) AddLines(lines ...string) *Renderer
- func (r *Renderer) AddSection()
- func (r *Renderer) AddStyleModifier(modifier StyleModifier) *Renderer
- func (r *Renderer) AreInfoItemsTruncated() bool
- func (r *Renderer) Render() string
- func (r *Renderer) SetBorderInfoItems(infoItems ...string)
- func (r *Renderer) SetBorderTitle(title string)
- func (r *Renderer) Style() lipgloss.Style
- type RendererConfig
- type StyleModifier
- type TruncateStyle
Constants ¶
const ( MinWidthForBorder = 2 MinHeightForBorder = 2 )
Border rendering constants
const ( PlainTruncateRight = iota TailsTruncateRight )
These truncate styles must preserve ansi escape codes. If something doesn't preserves it shouldn't be here
Variables ¶
This section is empty.
Functions ¶
func TruncateBasedOnStyle ¶
func TruncateBasedOnStyle(line string, maxWidth int, truncateStyle TruncateStyle) string
Types ¶
type BorderConfig ¶
type BorderConfig struct {
// contains filtered or unexported fields
}
func NewBorderConfig ¶
func NewBorderConfig(height int, width int) BorderConfig
func (*BorderConfig) AddDivider ¶
func (b *BorderConfig) AddDivider(idx int)
func (*BorderConfig) AreInfoItemsTruncated ¶
func (b *BorderConfig) AreInfoItemsTruncated() bool
func (*BorderConfig) GetBorder ¶
func (b *BorderConfig) GetBorder(borderStrings lipgloss.Border) lipgloss.Border
border.Top with something that takes up more than 1 runewidth will not work, so we only allow 1 runewidth for now, in the config. multiple things like border corner characters must be single rune, or else it would break rendering. This is all filled in one function to prevent passing around too many values in helper functions
func (*BorderConfig) SetInfoItems ¶
func (b *BorderConfig) SetInfoItems(infoItems ...string)
func (*BorderConfig) SetTitle ¶
func (b *BorderConfig) SetTitle(title string)
type ContentRenderer ¶
type ContentRenderer struct {
// contains filtered or unexported fields
}
func NewContentRenderer ¶
func NewContentRenderer(maxLines int, maxLineWidth int, truncateStyle TruncateStyle, name string) ContentRenderer
func (*ContentRenderer) AddLineWithCustomTruncate ¶
func (r *ContentRenderer) AddLineWithCustomTruncate(lineStr string, truncateStyle TruncateStyle)
Maybe better return an error ? AddLineWithCustomTruncate adds lines to the renderer, truncating each line according to the specified style. It does not trims whitespace, and its possible to add multiple empty lines using this.
func (*ContentRenderer) AddLines ¶
func (r *ContentRenderer) AddLines(lines ...string)
func (*ContentRenderer) ClearLines ¶
func (r *ContentRenderer) ClearLines()
func (*ContentRenderer) CntLines ¶
func (r *ContentRenderer) CntLines() int
func (*ContentRenderer) Render ¶
func (r *ContentRenderer) Render() string
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
For now we are not allowing to add/update/remove lines to previous sections We may allow that later. Also we could have functions about getting sections count, line count, adding updating a specific line in a specific section, and adjusting section sizes. But not needed now. TODO: zero value of Renderer - `Renderer{}` is unusable, It will cause panic on AddLines(), completely eliminate usage of zero values in the code.
func NewRenderer ¶
func NewRenderer(cfg RendererConfig) (*Renderer, error)
func (*Renderer) AddLineWithCustomTruncate ¶
func (r *Renderer) AddLineWithCustomTruncate(line string, truncateStyle TruncateStyle)
Truncate would always preserve ansi codes.
func (*Renderer) AddSection ¶
func (r *Renderer) AddSection()
Lines until now will belong to current section, and Any new lines will belong to a new section
func (*Renderer) AddStyleModifier ¶ added in v1.5.0
func (r *Renderer) AddStyleModifier(modifier StyleModifier) *Renderer
func (*Renderer) AreInfoItemsTruncated ¶
func (*Renderer) SetBorderInfoItems ¶
func (*Renderer) SetBorderTitle ¶
type RendererConfig ¶
type RendererConfig struct {
TotalHeight int
TotalWidth int
DefTruncateStyle TruncateStyle
TruncateHeight bool
BorderRequired bool
ContentFGColor lipgloss.TerminalColor
ContentBGColor lipgloss.TerminalColor
BorderFGColor lipgloss.TerminalColor
BorderBGColor lipgloss.TerminalColor
Border lipgloss.Border
RendererName string
}
func DefaultRendererConfig ¶
func DefaultRendererConfig(totalHeight int, totalWidth int) RendererConfig
type TruncateStyle ¶
type TruncateStyle int