widgets

package
v0.0.0-...-020cec0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Text

type Text struct {
	tooey.Element
	Content string
	Theme   *tooey.Theme
	Wrap    bool
}

Text represents a simple styled block of text with wrapping paragraph capabilities

func NewText

func NewText(theme *tooey.Theme) *Text

NewText returns a basic empty *Text

func (*Text) Draw

func (t *Text) Draw(s tcell.Screen)

Draw draws the text to its given Rect taking into account left and right padding, wrapping, etc

func (*Text) Draw2

func (t *Text) Draw2(s tcell.Screen)

Draw ...

func (*Text) DrawableRect

func (t *Text) DrawableRect() image.Rectangle

DrawableRect returns a set of ints representing the calculated drawable space based on all padding and positioning

Returns image.Rectangle

func (*Text) FillRuneBuffer

func (t *Text) FillRuneBuffer(r image.Rectangle) [][]rune

FillRuneBuffer prefills a buffer of size image.Rectangle for filling drawable text areas

This is unfortunately destructive and prevents things like overlapping which may or may not be desirable but it was the way I could think of to prepare a buffer for managing alignment of text within a text space

func (*Text) ProcessCenterAlignment

func (t *Text) ProcessCenterAlignment(r image.Rectangle) [][]rune

ProcessCenterAlignment ...

func (*Text) ProcessFullAlignment

func (t *Text) ProcessFullAlignment(r image.Rectangle) [][]rune

ProcessFullAlignment ...

func (*Text) ProcessLeftAlignment

func (t *Text) ProcessLeftAlignment(r image.Rectangle) [][]rune

ProcessLeftAlignment accepts a space of image.Rectangle and processes Text.Content within that space to be left justified, and attempt to wrap word-aware when possible. If the word will fit on a line by itself it will wrap, otherwise it will wrap mid-word.

returns [y][x]rune

func (*Text) ProcessRightAlignment

func (t *Text) ProcessRightAlignment(r image.Rectangle) [][]rune

ProcessRightAlignment accepts a space of image.Rectangle and processes Text.Content within that space to be right justified and attempt to wrap word-aware when possible. If the word will fit on a line by itself it will wrap, otherwise it will wrap mid-word

returns [y][x]rune

func (*Text) ProcessUnwrapped

func (t *Text) ProcessUnwrapped(x int, maxWidth int) map[int]rune

ProcessUnwrapped needs rewritten...

returns [y][x]rune

func (*Text) SetTheme

func (t *Text) SetTheme(theme *tooey.Theme)

SetTheme sets the theme for the Text and it's underlying Element

Jump to

Keyboard shortcuts

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