Section

package
v0.3.30 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Hellip defines the string to be used as an ellipsis when the content
	// of the MultilineText is truncated.
	// It is set to "...", which is the standard representation of an ellipsis
	// in text.
	Hellip string = "..."

	// HellipLen defines the length of the Hellip string.
	// It is set to 3, which is the number of characters in the Hellip string.
	HellipLen int = len(Hellip)

	// Space defines the string to be used as a space when writing content
	// into the MultilineText.
	// It is set to " ", which is the standard representation of a space in
	// text.
	Space string = " "

	// FieldSpacing defines the number of spaces between each field (word)
	// when they are written into the MultilineText.
	// It is set to 1, meaning there will be one spaces between each field.
	FieldSpacing int = 1

	// IndentLevel defines the number of spaces used for indentation when
	// writing content into the MultilineText.
	// It is set to 2, meaning there will be two spaces at the start of each
	// new line of content.
	IndentLevel int = 3
)
View Source
const (
	Asterisks string = "***"

	AsterisksLen int = len(Asterisks)

	TitleMinWidth int = 2 * (AsterisksLen + 1)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MultilineText

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

MultilineText represents a box that contains content.

func (*MultilineText) ApplyRender

func (mlt *MultilineText) ApplyRender(width, height int) ([]*Render, error)

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.

func (*MultilineText) FromTextBlock

func (mlt *MultilineText) FromTextBlock(lines [][]string) error

FromTextBlock sets the content of the MultilineText to the specified two-dimensional slice of strings.

Parameters:

  • lines - a two-dimensional slice of strings representing the content of the MultilineText.

Returns:

  • error - an error if the content could not be set.

func (*MultilineText) GetRawContent

func (mlt *MultilineText) GetRawContent() [][]string

GetRawContent returns the raw content of the MultilineText.

Returns:

  • [][]string - the raw content of the MultilineText.

type Render

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

Render is a type that represents a render of a section.

func NewRender

func NewRender(runeTable [][]rune) *Render

NewRender creates a new render.

Parameters:

  • runeTable: The table of runes of the render.

Returns:

  • *Render: The new render.

type Sectioner

type Sectioner interface {
	// FromTextBlock creates a section from words.
	//
	// Parameters:
	//   - lines: The words to create the section from.
	//
	// Returns:
	//   - error: An error if the section could not be created.
	FromTextBlock(lines [][]string) error

	// ApplyRender applies the render to the section.
	//
	// Parameters:
	//   - width: The width of the render.
	//   - height: The height of the render.
	//
	// Returns:
	//   - []*Render: The render of the section.
	//   - error: An error if the render could not be applied.
	ApplyRender(width, height int) ([]*Render, error)

	// GetRawContent returns the raw content of the section.
	//
	// Returns:
	//   - [][]string: The raw content of the section.
	GetRawContent() [][]string
}

Sectioner is an interface that represents a section.

type Title

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

Title represents the header of a process or application. It contains information about the title, current process, counters, message buffer, channels for receiving messages and errors, synchronization primitives, and the width of the header.

func NewTitle

func NewTitle(title string) *Title

NewTitle creates a new Title with the given title and a style.

Parameters:

  • title: The title of the new Title.
  • style: The style of the new Title.

Returns:

  • *Title: The new Title.

func (*Title) ApplyRender

func (t *Title) ApplyRender(width, height int) ([]*Render, error)

ForceDraw draws the title to the draw table.

Parameters:

  • table: The draw table.
  • x: The x coordinate to draw the title at.
  • y: The y coordinate to draw the title at.

Returns:

  • error: An error if the title could not be drawn.

func (*Title) GetRawContent

func (t *Title) GetRawContent() [][]string

GetRawContent returns the raw content of the Title.

Returns:

  • [][]string: The raw content of the Title.

func (*Title) GetSubtitle

func (t *Title) GetSubtitle() string

GetSubtitle returns the subtitle of the Title.

Returns:

  • string: The subtitle of the Title.

func (*Title) GetTitle

func (t *Title) GetTitle() string

GetTitle returns the title of the Title.

Returns:

  • string: The title of the Title.

func (*Title) SetSubtitle

func (t *Title) SetSubtitle(subtitle string)

SetSubtitle sets the subtitle of the Title.

Parameters:

  • subtitle: The new subtitle.

Behaviors:

  • If the subtitle is an empty string, the subtitle is removed.

Jump to

Keyboard shortcuts

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