Documentation ¶
Overview ¶
Package raster implements text buffering.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatText ¶
FormatText formats special characters like code points below 32.
TODO(maruel): This must add coloring too.
TODO(maruel): Improve performance for the common case (no special character).
TODO(maruel): Handles special unicode whitespaces. Since the editor is meant for mono-space font, all except U+0020 and \t should be escaped. https://en.wikipedia.org/wiki/Whitespace_character
Types ¶
type Buffer ¶
type Buffer struct { Width int Height int Stride int Cells CellStride }
Buffer represents a buffer of Cells.
The Cells slice can be shared across multiple Buffer when using SubBuffer(). Width Height are guaranteed to be either both zero or non-zero.
func (*Buffer) Blit ¶
Blit copies src into b.
To copy a section of a buffer, use SubBuffer() first. Areas that falls either outside of src or of b are ignored.
func (*Buffer) Cell ¶
Cell returns the pointer to a specific character cell.
If the position is outside the buffer, an empty temporary cell is returned.
func (*Buffer) DrawString ¶
func (b *Buffer) DrawString(s string, X, Y int, f CellFormat)
DrawString draws a string into the buffer.
Text will be automatically elided if necessary.
func (*Buffer) Fill ¶
Fill fills a buffer with a Cell.
To fill a section of a buffer, use SubBuffer() first.
func (*Buffer) Line ¶
func (b *Buffer) Line(Y int) CellStride
Line returns a single line in the buffer.
If the requested line number if outside the buffer, an empty slice is returned.
type Cell ¶
type Cell struct { R rune F CellFormat }
Cell represents the properties of a single character on screen.
Some properties are ignored on different terminals.
type CellFormat ¶
CellFormat describes all the properties of a single cell on screen.
func (CellFormat) Empty ¶
func (c CellFormat) Empty() bool
Empty reports whether the CellFormat is black on black. In that case it doesn't matter if it's italic or underlined.
type CellStride ¶
type CellStride []Cell
CellStride is a slice of cells.
func (CellStride) Formats ¶
func (c CellStride) Formats() []CellFormat
Formats returns cells format as a slice.