Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColoredUnit ¶
type ColoredUnit struct {
// contains filtered or unexported fields
}
ColoredUnit represents a unit that contains a single color.
func LineToCells ¶
func LineToCells(line string, style tcell.Style) []*ColoredUnit
LineToCells converts a string to a slice of ColoredUnits with the given style.
Parameters:
- line: The string to convert.
- style: The style to use.
Returns:
- []*ColoredUnit: The slice of ColoredUnits.
func NewColoredUnit ¶
func NewColoredUnit(content rune, style tcell.Style) *ColoredUnit
NewColoredUnit creates a new ColorUnit with the given content and style.
Parameters:
- content: The content of the color.
- style: The style of the color.
Returns:
- *ColoredUnit: The new ColoredUnit.
func (*ColoredUnit) GetContent ¶
func (cu *ColoredUnit) GetContent() rune
GetContent returns the content of the color.
Returns:
- rune: The content of the color.
func (*ColoredUnit) GetStyle ¶
func (cu *ColoredUnit) GetStyle() tcell.Style
GetStyle returns the style of the color.
Returns:
- tcell.Style: The style of the color.
func (*ColoredUnit) Runes ¶
func (cu *ColoredUnit) Runes(width, height int) ([][]rune, error)
Runes returns the content of the color as a 2D slice of runes given the size of the table.
Parameters:
- width: The width of the table.
- height: The height of the table.
Returns:
- [][]rune: The content of the color as a 2D slice of runes.
- error: An error if the content could not be converted to runes.
Behaviors:
- Always assume that the width and height are greater than 0. No need to check for
type Displayer ¶
type Displayer interface { // Draw is a method of cdd.TableDrawer that draws the unit to the table at the given x and y // coordinates. // // Parameters: // - table: The table to draw the unit to. // - x: The x coordinate to draw the unit at. // - y: The y coordinate to draw the unit at. // // Returns: // - error: An error of type *ers.ErrInvalidParameter if the table is nil. // // Behaviors: // - Any value that would be drawn outside of the table is not drawn. // - Assumes that the table is not nil. Draw(table *DrawTable, x, y *int) error }
type DrawTable ¶
type DrawTable struct { *cdt.Table[*ColoredUnit] }
DrawTable represents a table of cells that can be drawn to the screen.
func NewDrawTable ¶
NewDrawTable creates a new DrawTable with the given width and height.
Parameters:
- width: The width of the drawTable.
- height: The height of the drawTable.
Returns:
- *DrawTable: The new drawTable.
Behaviors:
- If the width or height is negative, the absolute value is used.
func (*DrawTable) GetLines ¶
GetLines returns each line of the drawTable as a string.
Returns:
- []string: The lines of the drawTable.
Behaviors:
- Any nil cells in the drawTable are represented by a space character.
- The last line may not be full width.
func (*DrawTable) WriteLineAt ¶
WriteLineAt writes a string to the drawTable at the given coordinates.
Parameters:
- x: The x-coordinate of the starting cell.
- y: The y-coordinate of the starting cell.
- line: The string to write to the drawTable.
- style: The style of the string.
- isHorizontal: A boolean that determines if the string should be written horizontally or vertically.
Behaviors:
- This is just a convenience function that converts the string to a sequence of cells and calls WriteHorizontalSequence or WriteVerticalSequence.
- x and y are updated to the next available cell after the line is written.