Documentation ¶
Index ¶
- Variables
- func ConfigureSurface(id uuid.UUID, origin ptypes.Point2I, size ptypes.Rectangle, style paint.Style) (err error)
- func FillSurface(id uuid.UUID, theme paint.Theme) (err error)
- func MakeTag(argv ...interface{}) (tag string)
- func RegisterSurface(id uuid.UUID, origin ptypes.Point2I, size ptypes.Rectangle, style paint.Style) (err error)
- func RemoveSurface(id uuid.UUID)
- type CSurface
- func (c *CSurface) Box(pos ptypes.Point2I, size ptypes.Rectangle, border, fill, overlay bool, ...)
- func (c *CSurface) BoxWithTheme(pos ptypes.Point2I, size ptypes.Rectangle, border, fill bool, ...)
- func (c *CSurface) Composite(id uuid.UUID) (err error)
- func (c *CSurface) CompositeSurface(v *CSurface) error
- func (c *CSurface) DebugBox(color paint.Color, format string, argv ...interface{})
- func (c *CSurface) DrawHorizontalLine(pos ptypes.Point2I, length int, style paint.Style)
- func (c *CSurface) DrawLine(pos ptypes.Point2I, length int, orient enums.Orientation, style paint.Style)
- func (c *CSurface) DrawSingleLineText(position ptypes.Point2I, maxChars int, ellipsize bool, ...)
- func (c *CSurface) DrawText(pos ptypes.Point2I, size ptypes.Rectangle, justify enums.Justification, ...)
- func (c *CSurface) DrawVerticalLine(pos ptypes.Point2I, length int, style paint.Style)
- func (c *CSurface) Equals(onlyDirty bool, v *CSurface) bool
- func (c *CSurface) Fill(theme paint.Theme)
- func (c *CSurface) FillBorder(dim, border bool, theme paint.Theme)
- func (c *CSurface) FillBorderTitle(dim bool, title string, justify enums.Justification, theme paint.Theme)
- func (c *CSurface) GetContent(x, y int) (textCell TextCell)
- func (c *CSurface) GetOrigin() ptypes.Point2I
- func (c *CSurface) GetRegion() (region ptypes.Region)
- func (c *CSurface) GetSize() ptypes.Rectangle
- func (c *CSurface) GetStyle() (style paint.Style)
- func (c *CSurface) Height() (height int)
- func (c *CSurface) Render(display Renderer) error
- func (c *CSurface) Resize(size ptypes.Rectangle, style paint.Style)
- func (c *CSurface) SetContent(x, y int, char string, s paint.Style) error
- func (c *CSurface) SetOrigin(origin ptypes.Point2I)
- func (c *CSurface) SetRegion(region ptypes.Region)
- func (c *CSurface) SetRune(x, y int, r rune, s paint.Style) error
- func (c CSurface) String() string
- func (c *CSurface) Width() (width int)
- type CSurfaceBuffer
- func (b *CSurfaceBuffer) GetBgColor(x, y int) (bg paint.Color)
- func (b *CSurfaceBuffer) GetCell(x int, y int) TextCell
- func (b *CSurfaceBuffer) GetDim(x, y int) bool
- func (b *CSurfaceBuffer) Height() (height int)
- func (b *CSurfaceBuffer) LoadData(d [][]TextCell)
- func (b *CSurfaceBuffer) Resize(size ptypes.Rectangle, style paint.Style)
- func (b *CSurfaceBuffer) SetCell(x int, y int, r rune, style paint.Style) error
- func (b *CSurfaceBuffer) Size() (size ptypes.Rectangle)
- func (b *CSurfaceBuffer) String() string
- func (b *CSurfaceBuffer) Style() (style paint.Style)
- func (b *CSurfaceBuffer) Width() (width int)
- type CTango
- type CTextBuffer
- func (b *CTextBuffer) CharacterCount() (cellCount int)
- func (b *CTextBuffer) ClearText(wordWrap enums.WrapMode, ellipsize bool, justify enums.Justification, ...) (plain string)
- func (b *CTextBuffer) Draw(canvas Surface, singleLine bool, wordWrap enums.WrapMode, ellipsize bool, ...) enums.EventFlag
- func (b *CTextBuffer) Input() (raw string)
- func (b *CTextBuffer) Mnemonic() (enabled bool)
- func (b *CTextBuffer) PlainText(wordWrap enums.WrapMode, ellipsize bool, justify enums.Justification, ...) (plain string)
- func (b *CTextBuffer) PlainTextInfo(wordWrap enums.WrapMode, ellipsize bool, justify enums.Justification, ...) (longestLine, lineCount int)
- func (b *CTextBuffer) Set(input string, style paint.Style)
- func (b *CTextBuffer) SetInput(input WordLine)
- func (b *CTextBuffer) SetMnemonic(enabled bool)
- func (b *CTextBuffer) SetStyle(style paint.Style)
- func (b *CTextBuffer) Style() paint.Style
- func (b *CTextBuffer) WordCount() (wordCount int)
- type CTextCell
- func (t *CTextCell) Dirty() bool
- func (t *CTextCell) Equals(mc rune, style paint.Style, width int) bool
- func (t *CTextCell) IsNil() bool
- func (t *CTextCell) IsSpace() bool
- func (t *CTextCell) Set(r rune)
- func (t *CTextCell) SetByte(b []byte)
- func (t *CTextCell) SetStyle(style paint.Style)
- func (t *CTextCell) String() string
- func (t *CTextCell) StringValue() string
- func (t *CTextCell) Style() paint.Style
- func (t *CTextCell) Value() rune
- func (t *CTextCell) Width() int
- type CTextChar
- type CWordCell
- func (w *CWordCell) AppendRune(r rune, style paint.Style)
- func (w *CWordCell) Characters() []TextCell
- func (w *CWordCell) CompactLen() (count int)
- func (w *CWordCell) GetCharacter(index int) (char TextCell)
- func (w *CWordCell) HasSpace() bool
- func (w *CWordCell) IsNil() bool
- func (w *CWordCell) IsSpace() bool
- func (w *CWordCell) Len() (count int)
- func (w *CWordCell) Set(word string, style paint.Style)
- func (w *CWordCell) String() (s string)
- func (w *CWordCell) Value() (word string)
- type CWordLine
- func (w *CWordLine) AppendWord(word string, style paint.Style)
- func (w *CWordLine) AppendWordCell(word WordCell)
- func (w *CWordLine) AppendWordRune(wordIndex int, char rune, style paint.Style) error
- func (w *CWordLine) CharacterCount() (count int)
- func (w *CWordLine) GetCharacter(index int) TextCell
- func (w *CWordLine) GetCharacterStyle(index int) (style paint.Style, ok bool)
- func (w *CWordLine) GetWord(index int) WordCell
- func (w *CWordLine) HasSpace() bool
- func (w *CWordLine) Len() (wordSpaceCount int)
- func (w *CWordLine) Make(mnemonic bool, wrap enums.WrapMode, ellipsize bool, ...) (formatted []WordLine)
- func (w *CWordLine) RemoveWord(index int)
- func (w *CWordLine) SetCharacter(index int, r rune)
- func (w *CWordLine) SetCharacterStyle(index int, style paint.Style)
- func (w *CWordLine) SetLine(line string, style paint.Style)
- func (w *CWordLine) String() (s string)
- func (w *CWordLine) Value() (s string)
- func (w *CWordLine) WordCount() (wordCount int)
- func (w *CWordLine) Words() []WordCell
- type CWordLineCache
- type CWordPage
- type Renderer
- type Surface
- type SurfaceBuffer
- type Tango
- type TextBuffer
- type TextCell
- type TextChar
- type WordCell
- type WordLine
- type WordLineCacheFn
- type WordPageCache
Constants ¶
This section is empty.
Variables ¶
var (
TapSpace = " "
)
Functions ¶
func ConfigureSurface ¶
func RegisterSurface ¶
func RemoveSurface ¶ added in v0.4.4
Types ¶
type CSurface ¶
type CSurface struct {
// contains filtered or unexported fields
}
concrete implementation of the Surface interface
func NewSurface ¶
create a new canvas object with the given origin point, size and theme
func (*CSurface) Box ¶
func (c *CSurface) Box(pos ptypes.Point2I, size ptypes.Rectangle, border, fill, overlay bool, fillRune rune, contentStyle, borderStyle paint.Style, borderRunes paint.BorderRuneSet)
draw a box, at position, of size, with or without a border, with or without being filled in and following the given theme
func (*CSurface) BoxWithTheme ¶
func (*CSurface) CompositeSurface ¶
apply the given canvas to this canvas, at the given one's origin. returns an error if the underlying buffer write failed or if the given canvas is beyond the bounds of this canvas
func (*CSurface) DebugBox ¶
draw a box with Sprintf-formatted text along the top-left of the box, useful for debugging more than anything else as the normal draw primitives are far more flexible
func (*CSurface) DrawHorizontalLine ¶
convenience method to draw a horizontal line
func (*CSurface) DrawLine ¶
func (c *CSurface) DrawLine(pos ptypes.Point2I, length int, orient enums.Orientation, style paint.Style)
draw a line vertically or horizontally with the given style
func (*CSurface) DrawSingleLineText ¶
func (c *CSurface) DrawSingleLineText(position ptypes.Point2I, maxChars int, ellipsize bool, justify enums.Justification, style paint.Style, markup, mnemonic bool, text string)
write a single line of text to the canvas at the given position, of at most maxChars, with the text justified and styled. supports Tango markup content
func (*CSurface) DrawText ¶
func (c *CSurface) DrawText(pos ptypes.Point2I, size ptypes.Rectangle, justify enums.Justification, singleLineMode bool, wrap enums.WrapMode, ellipsize bool, style paint.Style, markup, mnemonic bool, text string)
Write text to the canvas buffer origin is the top-left coordinate for the text area being rendered alignment is based on origin.X boxed by maxChars or canvas size.W
func (*CSurface) DrawVerticalLine ¶
convenience method to draw a vertical line
func (*CSurface) Equals ¶
returns true if the given canvas is painted the same as this one, can compare for only cells that were "set" (dirty) or compare every cell of the two canvases
func (*CSurface) FillBorder ¶
fill the entire canvas, with or without 'dim' styling, with or without a border
func (*CSurface) FillBorderTitle ¶
func (c *CSurface) FillBorderTitle(dim bool, title string, justify enums.Justification, theme paint.Theme)
fill the entire canvas, with or without 'dim' styling, with plain text justified across the top border
func (*CSurface) GetContent ¶
get the text cell at the given coordinates
func (*CSurface) GetRegion ¶ added in v0.4.4
GetRegion returns the origin and size as a Region type.
func (*CSurface) SetContent ¶
from the given string, set the character and style of the cell at the given coordinates. note that only the first UTF-8 byte is used
func (*CSurface) SetOrigin ¶
set the origin (top-left corner) position of the canvas, used when compositing one canvas with another
func (*CSurface) SetRegion ¶ added in v0.4.4
SetRegion is a convenience method wrapping SetOrigin and Resize, using the given Region for the values. The existing Style is used for the Resize call.
type CSurfaceBuffer ¶
concrete implementation of the SurfaceBuffer interface
func NewSurfaceBuffer ¶
func NewSurfaceBuffer(size ptypes.Rectangle, style paint.Style) *CSurfaceBuffer
construct a new canvas buffer
func (*CSurfaceBuffer) GetBgColor ¶
func (b *CSurfaceBuffer) GetBgColor(x, y int) (bg paint.Color)
return the background color at the given coordinates
func (*CSurfaceBuffer) GetCell ¶
func (b *CSurfaceBuffer) GetCell(x int, y int) TextCell
return the text cell at the given coordinates, nil if not found
func (*CSurfaceBuffer) GetDim ¶
func (b *CSurfaceBuffer) GetDim(x, y int) bool
return true if the given coordinates are styled 'dim', false otherwise
func (*CSurfaceBuffer) Height ¶
func (b *CSurfaceBuffer) Height() (height int)
return just the height of the buffer
func (*CSurfaceBuffer) LoadData ¶
func (b *CSurfaceBuffer) LoadData(d [][]TextCell)
given matrix array of text cells, load that data in this canvas space
func (*CSurfaceBuffer) Resize ¶
func (b *CSurfaceBuffer) Resize(size ptypes.Rectangle, style paint.Style)
resize the buffer
func (*CSurfaceBuffer) Size ¶
func (b *CSurfaceBuffer) Size() (size ptypes.Rectangle)
return the rectangle size of the buffer
func (*CSurfaceBuffer) String ¶
func (b *CSurfaceBuffer) String() string
return a string describing the buffer, only useful for debugging purposes
func (*CSurfaceBuffer) Style ¶
func (b *CSurfaceBuffer) Style() (style paint.Style)
return the rectangle size of the buffer
func (*CSurfaceBuffer) Width ¶
func (b *CSurfaceBuffer) Width() (width int)
return just the width of the buffer
type CTango ¶
type CTango struct {
// contains filtered or unexported fields
}
func (*CTango) TextBuffer ¶
func (m *CTango) TextBuffer(mnemonic bool) TextBuffer
type CTextBuffer ¶
func (*CTextBuffer) CharacterCount ¶
func (b *CTextBuffer) CharacterCount() (cellCount int)
func (*CTextBuffer) ClearText ¶
func (b *CTextBuffer) ClearText(wordWrap enums.WrapMode, ellipsize bool, justify enums.Justification, maxChars int) (plain string)
func (*CTextBuffer) Draw ¶
func (b *CTextBuffer) Draw(canvas Surface, singleLine bool, wordWrap enums.WrapMode, ellipsize bool, justify enums.Justification, vAlign enums.VerticalAlignment) enums.EventFlag
func (*CTextBuffer) Input ¶
func (b *CTextBuffer) Input() (raw string)
func (*CTextBuffer) Mnemonic ¶
func (b *CTextBuffer) Mnemonic() (enabled bool)
func (*CTextBuffer) PlainText ¶
func (b *CTextBuffer) PlainText(wordWrap enums.WrapMode, ellipsize bool, justify enums.Justification, maxChars int) (plain string)
func (*CTextBuffer) PlainTextInfo ¶
func (b *CTextBuffer) PlainTextInfo(wordWrap enums.WrapMode, ellipsize bool, justify enums.Justification, maxChars int) (longestLine, lineCount int)
func (*CTextBuffer) SetInput ¶
func (b *CTextBuffer) SetInput(input WordLine)
func (*CTextBuffer) SetMnemonic ¶
func (b *CTextBuffer) SetMnemonic(enabled bool)
func (*CTextBuffer) SetStyle ¶
func (b *CTextBuffer) SetStyle(style paint.Style)
func (*CTextBuffer) Style ¶
func (b *CTextBuffer) Style() paint.Style
func (*CTextBuffer) WordCount ¶
func (b *CTextBuffer) WordCount() (wordCount int)
type CTextCell ¶
func (*CTextCell) StringValue ¶ added in v0.2.2
type CTextChar ¶
func NewTextChar ¶
type CWordCell ¶
type CWordCell struct {
// contains filtered or unexported fields
}
func (*CWordCell) Characters ¶
func (*CWordCell) CompactLen ¶
same as `Len()` with space-words being treated as 1 character wide rather than the literal number of spaces from the input string
func (*CWordCell) GetCharacter ¶
type CWordLine ¶
type CWordLine struct {
// contains filtered or unexported fields
}
func (*CWordLine) AppendWordCell ¶
func (*CWordLine) AppendWordRune ¶
func (*CWordLine) CharacterCount ¶
func (*CWordLine) GetCharacter ¶
func (*CWordLine) GetCharacterStyle ¶ added in v0.2.2
func (*CWordLine) Make ¶
func (w *CWordLine) Make(mnemonic bool, wrap enums.WrapMode, ellipsize bool, justify enums.Justification, maxChars int, fillerStyle paint.Style) (formatted []WordLine)
wrap, justify and align the set input, with filler style
func (*CWordLine) RemoveWord ¶
func (*CWordLine) SetCharacter ¶
func (*CWordLine) SetCharacterStyle ¶ added in v0.2.2
type CWordLineCache ¶
type CWordLineCache struct {
// contains filtered or unexported fields
}
func NewWordPageCache ¶
func NewWordPageCache() (wpc *CWordLineCache)
func (*CWordLineCache) Clear ¶
func (c *CWordLineCache) Clear()
func (*CWordLineCache) Hit ¶
func (c *CWordLineCache) Hit(tag string, fn WordLineCacheFn) (lines []WordLine)
type Surface ¶
type Surface interface { GetStyle() (style paint.Style) String() string Resize(size ptypes.Rectangle, style paint.Style) GetContent(x, y int) (textCell TextCell) SetContent(x, y int, char string, s paint.Style) error SetRune(x, y int, r rune, s paint.Style) error SetOrigin(origin ptypes.Point2I) GetOrigin() ptypes.Point2I GetSize() ptypes.Rectangle Width() (width int) Height() (height int) GetRegion() (region ptypes.Region) SetRegion(region ptypes.Region) Equals(onlyDirty bool, v *CSurface) bool CompositeSurface(v *CSurface) error Composite(id uuid.UUID) (err error) Render(display Renderer) error DrawText(pos ptypes.Point2I, size ptypes.Rectangle, justify enums.Justification, singleLineMode bool, wrap enums.WrapMode, ellipsize bool, style paint.Style, markup, mnemonic bool, text string) DrawSingleLineText(position ptypes.Point2I, maxChars int, ellipsize bool, justify enums.Justification, style paint.Style, markup, mnemonic bool, text string) DrawLine(pos ptypes.Point2I, length int, orient enums.Orientation, style paint.Style) DrawHorizontalLine(pos ptypes.Point2I, length int, style paint.Style) DrawVerticalLine(pos ptypes.Point2I, length int, style paint.Style) Box(pos ptypes.Point2I, size ptypes.Rectangle, border, fill, overlay bool, fillRune rune, contentStyle, borderStyle paint.Style, borderRunes paint.BorderRuneSet) BoxWithTheme(pos ptypes.Point2I, size ptypes.Rectangle, border, fill bool, theme paint.Theme) DebugBox(color paint.Color, format string, argv ...interface{}) Fill(theme paint.Theme) FillBorder(dim, border bool, theme paint.Theme) FillBorderTitle(dim bool, title string, justify enums.Justification, theme paint.Theme) }
a Surface is the primary means of drawing to the terminal display within CDK
type SurfaceBuffer ¶
type SurfaceBuffer interface { String() string Style() (style paint.Style) Size() (size ptypes.Rectangle) Width() (width int) Height() (height int) Resize(size ptypes.Rectangle, style paint.Style) GetDim(x, y int) bool GetBgColor(x, y int) (bg paint.Color) GetCell(x, y int) (textCell TextCell) SetCell(x int, y int, r rune, style paint.Style) error LoadData(d [][]TextCell) sync.Locker }
provide an underlying buffer for Canvases
type Tango ¶
type Tango interface { Raw() string TextBuffer(mnemonic bool) TextBuffer }
type TextBuffer ¶
type TextBuffer interface { Set(input string, style paint.Style) Input() (raw string) SetInput(input WordLine) Style() paint.Style SetStyle(style paint.Style) Mnemonic() (enabled bool) SetMnemonic(enabled bool) CharacterCount() (cellCount int) WordCount() (wordCount int) ClearText(wordWrap enums.WrapMode, ellipsize bool, justify enums.Justification, maxChars int) (plain string) PlainText(wordWrap enums.WrapMode, ellipsize bool, justify enums.Justification, maxChars int) (plain string) PlainTextInfo(wordWrap enums.WrapMode, ellipsize bool, justify enums.Justification, maxChars int) (longestLine, lineCount int) Draw(canvas Surface, singleLine bool, wordWrap enums.WrapMode, ellipsize bool, justify enums.Justification, vAlign enums.VerticalAlignment) enums.EventFlag }
func NewEmptyTextBuffer ¶
func NewEmptyTextBuffer(style paint.Style, mnemonic bool) TextBuffer
func NewTextBuffer ¶
func NewTextBuffer(input string, style paint.Style, mnemonic bool) TextBuffer
type WordCell ¶
type WordCell interface { Characters() []TextCell Set(word string, style paint.Style) GetCharacter(index int) (char TextCell) AppendRune(r rune, style paint.Style) IsNil() bool IsSpace() bool HasSpace() bool Len() (count int) CompactLen() (count int) Value() (word string) String() (s string) }
func NewEmptyWordCell ¶
func NewEmptyWordCell() WordCell
func NewNilWordCell ¶
type WordLine ¶
type WordLine interface { SetLine(line string, style paint.Style) AppendWord(word string, style paint.Style) AppendWordCell(word WordCell) AppendWordRune(wordIndex int, char rune, style paint.Style) error GetWord(index int) WordCell RemoveWord(index int) GetCharacter(index int) TextCell SetCharacter(index int, r rune) GetCharacterStyle(index int) (style paint.Style, ok bool) SetCharacterStyle(index int, style paint.Style) Words() []WordCell Len() (wordSpaceCount int) CharacterCount() (count int) WordCount() (wordCount int) HasSpace() bool Value() (s string) String() (s string) Make(mnemonic bool, wrap enums.WrapMode, ellipsize bool, justify enums.Justification, maxChars int, fillerStyle paint.Style) (formatted []WordLine) }
func NewEmptyWordLine ¶
func NewEmptyWordLine() WordLine
type WordLineCacheFn ¶
type WordLineCacheFn = func() []WordLine
type WordPageCache ¶
type WordPageCache interface {
Hit(tag string, fn WordLineCacheFn) []WordLine
}