text

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrawText

func DrawText(bounds rl.Rectangle, text string, opts Options)

DrawText draws the text in the given bounds.

Types

type Align

type Align int
const (
	AlignStart Align = iota
	AlignMiddle
	AlignEnd
)

func (Align) String

func (a Align) String() string

type Area

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

Area represents a text area.

It retains its state.

TODO: - Selection - Copy / paste - Undo / redo - Scrollbar and scroll with mouse wheel - auto grow with max height

func NewArea

func NewArea(bounds rl.Rectangle, text string, opts AreaOptions) Area

NewArea returns a new, unfocused, text Area with the given bounds, text and text options

It works best with a monospaced font.

func (*Area) Draw

func (a *Area) Draw(keyPressed int32)

Draw draws the text area

func (*Area) Focused

func (a *Area) Focused() bool

Focused returns whether the area is focused

func (*Area) SetBounds

func (a *Area) SetBounds(bounds rl.Rectangle)

SetBounds sets the bounds of the area

func (*Area) SetDisabled

func (a *Area) SetDisabled(disabled bool)

func (*Area) SetFocused

func (a *Area) SetFocused(focused bool)

SetFocused sets the focused state of the area

func (*Area) SetText

func (a *Area) SetText(text string)

SetText sets the text in the area

func (*Area) Text

func (a *Area) Text() string

Text returns the current text in the area

type AreaOptions

type AreaOptions struct {
	// Font to use
	Font rl.Font
	// Font size
	Size float32
	// Text color
	Color rl.Color
	// Spacing between letters
	Spacing float32
	// Spacing between lines
	LineSpacing float32
	// Draw in disabled state and ignore inputs
	Disabled bool
}

type Options

type Options struct {
	// Font to use
	Font rl.Font
	// Font size
	Size float32
	// Text color
	Color rl.Color
	// Spacing between letters
	Spacing float32
	// Spacing between lines
	LineSpacing float32
	// Whether to print/draw debug info
	Debug bool

	// Horizontal alignment
	Align Align
	// Vertical alignment
	VerticalAlign Align
	// Whether to wrap text
	Wrap Wrap
}

type Wrap

type Wrap int
const (
	// No wrapping (X-overflow possible)
	WrapNone Wrap = iota
	// Wrap on words only (X-overflow possible)
	WrapWord
	// Wrap on words then on chars (no X-overflow)
	WrapChar
)

func (Wrap) String

func (w Wrap) String() string

Jump to

Keyboard shortcuts

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