Documentation ¶
Index ¶
Constants ¶
const ( // EmptyRuneCell is a rune that represents an empty cell. EmptyRuneCell rune = '\000' )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DrawTable ¶
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.
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.
type DtUnit ¶
type DtUnit[T DtUniter] struct { // contains filtered or unexported fields }
DtUnit represents a unit in a draw table. It contains the content of the unit
func NewDtUnit ¶
NewDtUnit creates a new DtUnit with the given content and style.
Parameters:
- content: The content of the unit.
- style: The style of the unit.
Returns:
- *DtUnit: The new DtUnit.
func (*DtUnit[T]) Draw ¶
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.
type DtUniter ¶
type DtUniter interface { // Runes returns the content of the unit 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 unit 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 // this. // - Errors are only for critical issues, such as the content not being able to be // converted to runes. However, out of bounds or other issues should not error. // Instead, the content should be drawn as much as possible before unable to be // drawn. Runes(width, height int) ([][]rune, error) }
DtUniter is an interface that represents the content of a unit in a draw table.