Documentation ¶
Index ¶
- Variables
- func Equal(a, b Grid) bool
- func Fill(g Grid, c Cell)
- func Height(s string) int
- func Render(g Grid) string
- func RenderLine(g Grid, n int) (w int, line string)
- type AttrMask
- type Buffer
- type Cell
- type Grid
- type Link
- type Segment
- type Style
- func (s *Style) Background(c ansi.Color) *Style
- func (s *Style) Bold(v bool) *Style
- func (s *Style) Conceal(v bool) *Style
- func (s Style) DiffSequence(o Style) string
- func (s *Style) Empty() bool
- func (s Style) Equal(o Style) bool
- func (s *Style) Faint(v bool) *Style
- func (s *Style) Foreground(c ansi.Color) *Style
- func (s *Style) Italic(v bool) *Style
- func (s *Style) RapidBlink(v bool) *Style
- func (s *Style) Reset() *Style
- func (s *Style) Reverse(v bool) *Style
- func (s Style) Sequence() string
- func (s *Style) SlowBlink(v bool) *Style
- func (s *Style) Strikethrough(v bool) *Style
- func (s *Style) Underline(v bool) *Style
- func (s *Style) UnderlineColor(c ansi.Color) *Style
- func (s *Style) UnderlineStyle(style UnderlineStyle) *Style
- type UnderlineStyle
- type WidthMethod
Constants ¶
This section is empty.
Variables ¶
var ErrOutOfBounds = errors.New("out of bounds")
ErrOutOfBounds is returned when the given x, y position is out of bounds.
Functions ¶
func Render ¶
Render returns a string representation of the grid with ANSI escape sequences. Use ansi.Strip to remove them.
Types ¶
type AttrMask ¶
type AttrMask uint8
AttrMask is a bitmask for text attributes that can change the look of text. These attributes can be combined to create different styles.
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a 2D grid of cells representing a screen or terminal.
func (*Buffer) Resize ¶
Resize resizes the buffer to the given width and height. It grows the buffer if necessary and fills the new cells with space cells. Otherwise, it truncates the buffer.
type Cell ¶
type Cell struct { // The style of the cell. Nil style means no style. Zero value prints a // reset sequence. Style Style // Link is the hyperlink of the cell. Link Link // Content is the string representation of the cell as a grapheme cluster. Content string // Width is the mono-space width of the grapheme cluster. Width int }
Cell represents a single cell in the terminal screen.
type Grid ¶
type Grid interface { // Width returns the width of the grid. Width() int // Height returns the height of the grid. Height() int // Set writes a cell to the grid at the given position. It returns true if // the cell was written successfully. Set(x, y int, c Cell) bool // At returns the cell at the given position. At(x, y int) (Cell, error) // Resize resizes the grid to the given width and height. Resize(width, height int) }
Grid represents an interface for a grid of cells that can be written to and read from.
type Link ¶
Link represents a hyperlink in the terminal screen.
type Segment ¶
type Segment = Cell
Segment represents a continuous segment of cells with the same style attributes and hyperlink.
type Style ¶
type Style struct { Fg ansi.Color Bg ansi.Color Ul ansi.Color Attrs AttrMask UlStyle UnderlineStyle }
Style represents the Style of a cell.
func (*Style) Background ¶
Background sets the background color.
func (Style) DiffSequence ¶
DiffSequence returns the ANSI sequence that sets the style as a diff from another style.
func (*Style) Foreground ¶
Foreground sets the foreground color.
func (*Style) RapidBlink ¶
RapidBlink sets the rapid blink attribute.
func (*Style) Strikethrough ¶
Strikethrough sets the strikethrough attribute.
func (*Style) Underline ¶
Underline sets the underline attribute. This is a syntactic sugar for UnderlineStyle.
func (*Style) UnderlineColor ¶
UnderlineColor sets the underline color.
func (*Style) UnderlineStyle ¶
func (s *Style) UnderlineStyle(style UnderlineStyle) *Style
UnderlineStyle sets the underline style.
type UnderlineStyle ¶
type UnderlineStyle uint8
UnderlineStyle is the style of underline to use for text.
const ( NoUnderline UnderlineStyle = iota SingleUnderline DoubleUnderline CurlyUnderline DottedUnderline DashedUnderline )
These are the available underline styles.
func (UnderlineStyle) String ¶
func (u UnderlineStyle) String() string
String returns a string representation of the underline style.
type WidthMethod ¶
type WidthMethod uint8
WidthMethod is a type that represents the how the renderer should calculate the display width of cells.
const ( WcWidth WidthMethod = iota GraphemeWidth )
Display width modes.
func (WidthMethod) SetContent ¶
func (m WidthMethod) SetContent(g Grid, content string) []int
SetContent writes the given data to the grid starting from the first cell.
func (WidthMethod) SetContentAt ¶
func (m WidthMethod) SetContentAt(b Grid, c string, x, y, w, h int) []int
SetContentAt writes the given data to the grid starting from the given position and with the given width and height.