Display

package
v0.2.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsESCPressed

func IsESCPressed(err error) bool

IsESCPressed checks if the given error is of type ErrESCPressed.

Parameters:

  • err: The error to check.

Returns:

  • bool: True if the error is of type ErrESCPressed, false otherwise.

Types

type Display

type Display struct {
	// contains filtered or unexported fields
}

Display represents a display that can be used to draw to the screen.

func NewDisplay

func NewDisplay(frameRate float64) (*Display, error)

NewDisplay creates a new display with the given frame rate.

If the frame rate is less than or equal to 0, an error of type *ers.ErrInvalidParameter will be returned.

Parameters:

  • frameRate: The frame rate of the display.

Returns:

  • *Display: A pointer to the new display.
  • error: An error if the display could not be created.

func (*Display) Clear

func (d *Display) Clear()

Clear clears the display.

func (*Display) Close

func (d *Display) Close()

Close closes the display.

func (*Display) GetErrChannel

func (d *Display) GetErrChannel() <-chan error

GetErrChannel returns the error channel of the display.

Returns:

  • <-chan error: The error channel of the display.

func (*Display) GetTable

func (d *Display) GetTable() WriteOnlyDTer

GetTable returns the table that the display will draw to.

Returns:

  • WriteOnlyDTer: The table that the display will draw to.

func (*Display) Start

func (d *Display) Start()

Start starts the display.

func (*Display) Wait

func (d *Display) Wait()

Wait waits for the display to finish.

type DrawTable

type DrawTable struct {
	// contains filtered or unexported fields
}

DrawTable represents a table that can be drawn to the screen.

func NewDrawTable

func NewDrawTable(width, height int, defaultStyle tcell.Style) (*DrawTable, error)

NewDrawTable creates a new table with the given width, height, and default style.

If the width or height is less than 0, an error of type *ers.ErrInvalidParameter will be returned.

Parameters:

  • width: The width of the table.
  • height: The height of the table.
  • defaultStyle: The default style of the table.

Returns:

  • *DrawTable: A pointer to the new table.
  • error: An error if the table could not be created.

func (*DrawTable) GetHeight

func (dt *DrawTable) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table.

func (*DrawTable) GetWidth

func (dt *DrawTable) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table.

func (*DrawTable) ResizeHeight

func (dt *DrawTable) ResizeHeight(height int) error

ResizeHeight resizes the height of the table. No op if the height is the same.

If the height is less than 0, an error of type *ers.ErrInvalidParameter will be returned.

Parameters:

  • height: The new height of the table.

Returns:

  • error: An error if the height could not be resized.

func (*DrawTable) ResizeWidth

func (dt *DrawTable) ResizeWidth(width int) error

ResizeWidth resizes the width of the table. No op if the width is the same.

If the width is less than 0, an error of type *ers.ErrInvalidParameter will be returned.

Parameters:

  • width: The new width of the table.

Returns:

  • error: An error if the width could not be resized.

func (*DrawTable) WriteAt

func (dt *DrawTable) WriteAt(x, y int, value *DtCell) error

GetStyle returns the style of the table at the given position.

If the position is out of bounds, an error of type *ers.ErrInvalidParameter will be returned.

Parameters:

  • x: The x-coordinate of the position.
  • y: The y-coordinate of the position.
  • value: The value to set.

Returns:

  • *DtCell: The style of the table at the given position.
  • error: An error if the style could not be retrieved.

type DtCell

type DtCell struct {
	// Char represents the character of the cell.
	Char rune

	// Style represents the style of the cell.
	Style tcell.Style
}

DtCell represents a cell in a table that can be drawn to the screen.

func NewDtCell

func NewDtCell(char rune, style tcell.Style) DtCell

type ErrESCPressed

type ErrESCPressed struct{}

ErrESCPressed is an error that is returned when the ESC key is pressed.

func NewErrESCPressed

func NewErrESCPressed() *ErrESCPressed

NewErrESCPressed creates a new ErrESCPressed error.

Returns:

  • *ErrESCPressed: A pointer to the new error.

func (ErrESCPressed) Error

func (e ErrESCPressed) Error() string

Error returns the error message.

Returns:

  • string: The error message.

type WriteOnlyDTer

type WriteOnlyDTer interface {
	// WriteAt writes a cell to the table at the given x and y coordinates.
	//
	// If the x-coordinate is out of bounds, an error of type *ers.ErrInvalidParameter
	// will be returned.
	//
	// If the y-coordinate is out of bounds, an error of type *ers.ErrInvalidParameter
	// will be returned.
	//
	// Parameters:
	//
	//   - x: The x-coordinate of the position.
	//   - y: The y-coordinate of the position.
	//   - value: The value to set.
	//
	// Returns:
	//
	//   - error: An error if the cell could not be written.
	WriteAt(x, y int, value *DtCell) error

	// GetWidth returns the width of the table.
	//
	// Returns:
	//
	//   - int: The width of the table.
	GetWidth() int

	// GetHeight returns the height of the table.
	//
	// Returns:
	//
	//   - int: The height of the table.
	GetHeight() int
}

WriteOnlyDTer is an interface that represents a table that can be written to.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL