Documentation ¶
Index ¶
- Variables
- func Clear(d Buffer, rects ...Rectangle)
- func Equal(a, b Buffer) bool
- func Fill(d Buffer, c *Cell, rects ...Rectangle)
- func Height(s string) int
- func NewBuffer(width, height int) *buffer
- func Paint(d Buffer, m Method, content string, rect *Rectangle) []int
- func Render(d Buffer, opts ...RenderOption) string
- func RenderLine(d Buffer, n int, opts ...RenderOption) (w int, line string)
- type Buffer
- type Cell
- type Link
- type Method
- type Position
- type Rectangle
- type RenderOption
- type RenderOptions
- type Resizable
- type Segment
- type Style
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 Clear ¶ added in v0.0.6
Clear clears the canvas with space cells. If rect is not nil, it only clears the rectangle. Otherwise, it clears the whole canvas.
func Fill ¶
Fill fills the canvas with the given cell. If rect is not nil, it only fills the rectangle. Otherwise, it fills the whole canvas.
func NewBuffer ¶ added in v0.0.6
func NewBuffer(width, height int) *buffer
NewBuffer returns a new buffer with the given width and height.
func Paint ¶ added in v0.0.6
Paint writes the given data to the canvas. If rect is not nil, it only writes to the rectangle. Otherwise, it writes to the whole canvas.
func Render ¶
func Render(d Buffer, opts ...RenderOption) string
Render returns a string representation of the grid with ANSI escape sequences.
func RenderLine ¶
func RenderLine(d Buffer, n int, opts ...RenderOption) (w int, line string)
RenderLine returns a string representation of the yth line of the grid along with the width of the line.
Types ¶
type Buffer ¶
type Buffer interface { // Width returns the width of the grid. Width() int // Height returns the height of the grid. Height() int // Cell returns the cell at the given position. If the cell is out of // bounds, it returns nil. Cell(x, y int) *Cell // SetCell writes a cell to the grid at the given position. It returns true // if the cell was written successfully. If the cell is nil, a blank cell // is written. SetCell(x, y int, c *Cell) bool }
Buffer represents a screen grid of cells.
type Link ¶
Link represents a hyperlink in the terminal screen.
func ConvertLink ¶ added in v0.0.6
func ConvertLink(h Link, p colorprofile.Profile) Link
Convert converts a hyperlink to respect the given color profile.
type Method ¶ added in v0.0.2
type Method uint8
Method is a type that represents the how the renderer should calculate the display width of cells.
type RenderOption ¶ added in v0.0.6
type RenderOption func(*RenderOptions)
RenderOption is a function that configures a RenderOptions.
func WithRenderProfile ¶ added in v0.0.6
func WithRenderProfile(p colorprofile.Profile) RenderOption
WithRenderProfile sets the color profile to use when rendering the canvas.
type RenderOptions ¶ added in v0.0.6
type RenderOptions struct { // Profile is the color profile to use when rendering the canvas. Profile colorprofile.Profile }
RenderOptions represents options for rendering a canvas.
type Resizable ¶ added in v0.0.6
type Resizable interface { // Resize resizes the buffer to the given width and height. Resize(width, height int) }
Resizable is an interface for buffers that can be resized.
type Segment ¶
type Segment = Cell
Segment represents a continuous segment of cells with the same style attributes and hyperlink.
type Style ¶
Style represents the Style of a cell.
func ConvertStyle ¶ added in v0.0.6
func ConvertStyle(s Style, p colorprofile.Profile) Style
Convert converts a style to respect the given color profile.