handler

package
v0.0.50 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Nop added in v0.0.2

func Nop() tui.Handler

Nop returns a Handler that does nothing.

func NopFromComponent added in v0.0.2

func NopFromComponent(c tui.Component) tui.Handler

NopFromComponent wraps a Component to provide a Handler that does nothing.

func Sync added in v0.0.2

func Sync(mu sync.Locker, h tui.Handler) tui.Handler

Sync wraps a tui.Handler to provide access synchronization with mu.

func WithComponent

func WithComponent(h tui.Handler, comp tui.Component) tui.Handler

WithComponent wraps h with comp for the methods of h that satisfy tui.Component and delegates the remaining tui.Handler methods to h.

func Wrap

func Wrap(h tui.Handler, fn func(term.Event) (bool, bool)) tui.Handler

Wrap wraps a tui.Handler with a fn that gets called instead of Handle called on h. The rest of tui.Handler methods are delegated directly to h, so if h.Handle needs to be called, it's the client's responsibility to do so.

Additionally to the usual term.Events, term.EventResize events are also dispatched as events to fn, after Resize has been called on h.

Types

type Floating

type Floating interface {
	tui.Handler
	component.Floating
}

Floating handlers are not in principle confined to a predetermined space and so are allowed certain degree of freedom. See component.Floating for more details.

func NopFloating added in v0.0.2

func NopFloating() Floating

NopFloating returns a Floating that does nothing.

func NopFloatingFromComponent added in v0.0.2

func NopFloatingFromComponent(c tui.Component) Floating

NopFloatingFromComponent wraps a Component to provide a Floating that does nothing.

func NopFloatingFromHandler added in v0.0.2

func NopFloatingFromHandler(h tui.Handler) Floating

NopFloatingFromHandler wraps a Handler to provide a Floating that does nothing.

func PaddedFloating

func PaddedFloating(f Floating, padx, pady int) Floating

PaddedFloating wraps a Floating component and adds a pre-determined amount of x axis and y axis padding.

func StaticFloating

func StaticFloating(h tui.Handler, width, height int) Floating

StaticFloating wraps a tui.Handler and returns a Floating that always return the same Dimensions values.

type FloatingResponsive added in v0.0.2

type FloatingResponsive interface {
	Responsive
	Floating
}

FloatingResponsive is a Floating that also satisfies Responsive.

func NopFloatingFromResponsive added in v0.0.2

func NopFloatingFromResponsive(r Responsive) FloatingResponsive

NopFloatingFromResponsive wraps a Responsive to provide a FloatingResponsive that does nothing.

func NopFloatingResponsive added in v0.0.2

func NopFloatingResponsive() FloatingResponsive

NopFloatingResponsive returns a FloatingResponsive that does nothing.

func NopFloatingResponsiveFromComponent added in v0.0.2

func NopFloatingResponsiveFromComponent(c tui.Component) FloatingResponsive

NopFloatingResponsiveFromComponent wraps a Component to provide a FloatingResponsive that does nothing.

func NopFloatingResponsiveFromHandler added in v0.0.2

func NopFloatingResponsiveFromHandler(h tui.Handler) FloatingResponsive

NopFloatingResponsiveFromHandler wraps a Handler to provide a FloatingResponsive that does nothing.

func NopResponsiveFromFloating added in v0.0.2

func NopResponsiveFromFloating(f Floating) FloatingResponsive

NopResponsiveFromFloating wraps a Floating to provide a FloatingResponsive that does nothing.

type Frame added in v0.0.2

type Frame struct {
	component.Frame
	// contains filtered or unexported fields
}

Frame is a proxy handler that simply draws a frame around the underlying handler.

func NewFrame added in v0.0.2

func NewFrame(handler tui.Handler) (f *Frame)

NewFrame allocates storage for a new Frame and initializes it.

func (*Frame) Cursor added in v0.0.2

func (f *Frame) Cursor() (pos term.Coordinates, style term.CursorStyle, show bool)

Cursor returns the underlying handler's cursor position with the frame offset.

func (*Frame) Handle added in v0.0.2

func (f *Frame) Handle(ev term.Event) (bool, bool)

Handle delegates the event to the underlying handler.

func (*Frame) Init added in v0.0.2

func (f *Frame) Init(handler tui.Handler)

Init initializes this Frame with the given underlying handler and frame attributes.

func (*Frame) Selection added in v0.0.2

func (f *Frame) Selection() (string, bool)

Selection returns the underlying handler's selection.

type Prompt added in v0.0.17

type Prompt struct {
	component.Prompt
	// contains filtered or unexported fields
}

Prompt wraps a component.Prompt to satisfy tui.Handler.

func NewPrompt added in v0.0.17

func NewPrompt(cfg PromptConfig) (f *Prompt)

NewPrompt allocates storage for a new Prompt and initializes it. See Init for more details.

func (*Prompt) Close added in v0.0.17

func (f *Prompt) Close() error

Close satisfies tui.Handler running the configured close callback.

func (*Prompt) Cursor added in v0.0.17

func (f *Prompt) Cursor() (pos term.Coordinates, style term.CursorStyle, show bool)

Cursor satisfies tui.Handler.

func (*Prompt) Handle added in v0.0.17

func (f *Prompt) Handle(ev term.Event) (exit, handled bool)

Handle satisfies tui.Handler.

func (*Prompt) Init added in v0.0.17

func (f *Prompt) Init(cfg PromptConfig)

Init initializes this Prompt with the given PromptConfig. Note that if OptionBindings is defined, it should be of the same length as Options.

func (*Prompt) Selection added in v0.0.17

func (f *Prompt) Selection() (string, bool)

Selection satisfies tui.Handler but always returns false.

type PromptConfig added in v0.0.17

type PromptConfig struct {
	component.PromptConfig
	PromptHandler

	OptionBindings []term.KeyComb
	HighlightAttr  term.Attributes
	OptionAttr     term.Attributes
}

PromptConfig holds configuration for a Prompt.

type PromptHandler added in v0.0.17

type PromptHandler interface {
	// OnSelect is run when the user makes a choice from the prompt.
	OnSelect(idx int, option string)
	// OnClose runs when the user dismisses the prompt (usually by closing the
	// component that hosts the Prompt).
	OnClose() error
}

PromptHandler provides hooks to be called upon Prompt actions.

func FuncPromptHandler added in v0.0.17

func FuncPromptHandler(
	selectCb func(idx int, option string),
	closeCb func() error,
) PromptHandler

FuncPromptHandler will run the given callbacks upon selecting or closing.

func NopPromptHandler added in v0.0.17

func NopPromptHandler() PromptHandler

NopPromptHandler won't do anything on selecting prompt choices nor closing.

type Responsive added in v0.0.2

type Responsive interface {
	tui.Handler
	component.Responsive
}

Responsive components implement a backpressure mechanism (Height) for aggregate components to dynamically resize children based on their contents. See Height for more details.

func NopResponsive added in v0.0.2

func NopResponsive() Responsive

NopResponsive returns a Responsive that does nothing.

func NopResponsiveFromComponent added in v0.0.2

func NopResponsiveFromComponent(c tui.Component) Responsive

NopResponsiveFromComponent wraps a Component to provide a Responsive that does nothing.

func NopResponsiveFromHandler added in v0.0.2

func NopResponsiveFromHandler(h tui.Handler) Responsive

NopResponsiveFromHandler wraps a Handler to provide a Responsive that does nothing.

type Scrollable

type Scrollable interface {
	tui.Handler
	component.Scrollable
}

Scrollable is a tui.Handler that is capable of scrolling content. See component.Scrollable for more details.

func NopScrollable

func NopScrollable() Scrollable

NopScrollable returns a Scrollable that does nothing.

func NopScrollableFromComponent added in v0.0.2

func NopScrollableFromComponent(c tui.Component) Scrollable

NopScrollableFromComponent wraps a Component to provide a Scrollable that does nothing.

func NopScrollableFromHandler added in v0.0.2

func NopScrollableFromHandler(h tui.Handler) Scrollable

NopScrollableFromHandler wraps a Handler to provide a Scrollable that does nothing.

type ScrollableFloating

type ScrollableFloating interface {
	Scrollable
	component.Floating
}

ScrollableFloating is a Floating that is capable of scrolling content. See component.Scrollable for more details.

func NopFloatingFromScrollable added in v0.0.2

func NopFloatingFromScrollable(s Scrollable) ScrollableFloating

NopFloatingFromScrollable wraps a Scrollable to provide a ScrollableFloating that does nothing.

func NopScrollableFloating

func NopScrollableFloating() ScrollableFloating

NopScrollableFloating returns a ScrollableFloating that does nothing.

func NopScrollableFloatingFromComponent added in v0.0.2

func NopScrollableFloatingFromComponent(c tui.Component) ScrollableFloating

NopScrollableFloatingFromComponent wraps a Component to provide a ScrollableFloating that does nothing.

func NopScrollableFloatingFromHandler added in v0.0.2

func NopScrollableFloatingFromHandler(h tui.Handler) ScrollableFloating

NopScrollableFloatingFromHandler wraps a Handler to provide a ScrollableFloating that does nothing.

func NopScrollableFromFloating added in v0.0.2

func NopScrollableFromFloating(f Floating) ScrollableFloating

NopScrollableFromFloating wraps a Floating to provide a ScrollableFloating that does nothing.

type ScrollableFloatingWithAttributes added in v0.0.2

type ScrollableFloatingWithAttributes interface {
	Scrollable
	component.Floating
	component.WithAttributes
}

ScrollableFloatingWithAttributes is a FloatingWithAttributes that is capable of scrolling content. See component.Scrollable for more details.

func NopFloatingFromScrollableWithAttributes added in v0.0.2

func NopFloatingFromScrollableWithAttributes(sa ScrollableWithAttributes) ScrollableFloatingWithAttributes

NopFloatingFromScrollableWithAttributes wraps a ScrollableWithAttributes to provide a ScrollableFloatingWithAttributes that does nothing.

func NopScrollableFloatingFromWithAttributes added in v0.0.2

func NopScrollableFloatingFromWithAttributes(a WithAttributes) ScrollableFloatingWithAttributes

NopScrollableFloatingFromWithAttributes wraps a WithAttributes to provide a ScrollableFloatingWithAttributes that does nothing.

func NopScrollableFloatingWithAttributes added in v0.0.2

func NopScrollableFloatingWithAttributes() ScrollableFloatingWithAttributes

NopScrollableFloatingWithAttributes returns a ScrollableFloatingWithAttributes that does nothing.

func NopScrollableFloatingWithAttributesFromComponent added in v0.0.2

func NopScrollableFloatingWithAttributesFromComponent(c tui.Component) ScrollableFloatingWithAttributes

NopScrollableFloatingWithAttributesFromComponent wraps a Component to provide a ScrollableFloatingWithAttributes that does nothing.

func NopScrollableFloatingWithAttributesFromHandler added in v0.0.2

func NopScrollableFloatingWithAttributesFromHandler(h tui.Handler) ScrollableFloatingWithAttributes

NopScrollableFloatingWithAttributesFromHandler wraps a Handler to provide a ScrollableFloatingWithAttributes that does nothing.

func NopScrollableFromWithAttributesFloating added in v0.0.2

func NopScrollableFromWithAttributesFloating(af WithAttributesFloating) ScrollableFloatingWithAttributes

NopScrollableFromWithAttributesFloating wraps a WithAttributesFloating to provide a ScrollableFloatingWithAttributes that does nothing.

func NopScrollableWithAttributesFromFloating added in v0.0.2

func NopScrollableWithAttributesFromFloating(f Floating) ScrollableFloatingWithAttributes

NopScrollableWithAttributesFromFloating wraps a Floating to provide a ScrollableFloatingWithAttributes that does nothing.

func NopWithAttributesFloatingFromScrollable added in v0.0.2

func NopWithAttributesFloatingFromScrollable(s Scrollable) ScrollableFloatingWithAttributes

NopWithAttributesFloatingFromScrollable wraps a Scrollable to provide a ScrollableFloatingWithAttributes that does nothing.

func NopWithAttributesFromScrollableFloating added in v0.0.2

func NopWithAttributesFromScrollableFloating(sf ScrollableFloating) ScrollableFloatingWithAttributes

NopWithAttributesFromScrollableFloating wraps a ScrollableFloating to provide a ScrollableFloatingWithAttributes that does nothing.

type ScrollableWithAttributes added in v0.0.2

type ScrollableWithAttributes interface {
	Scrollable
	component.WithAttributes
}

ScrollableWithAttributes is a WithAttributes that is capable of scrolling content. See component.Scrollable for more details.

func NopScrollableFromWithAttributes added in v0.0.2

func NopScrollableFromWithAttributes(a WithAttributes) ScrollableWithAttributes

NopScrollableFromWithAttributes wraps a WithAttributes to provide a ScrollableWithAttributes that does nothing.

func NopScrollableWithAttributes added in v0.0.2

func NopScrollableWithAttributes() ScrollableWithAttributes

NopScrollableWithAttributes returns a ScrollableWithAttributes that does nothing.

func NopScrollableWithAttributesFromComponent added in v0.0.2

func NopScrollableWithAttributesFromComponent(c tui.Component) ScrollableWithAttributes

NopScrollableWithAttributesFromComponent wraps a Component to provide a ScrollableWithAttributes that does nothing.

func NopScrollableWithAttributesFromHandler added in v0.0.2

func NopScrollableWithAttributesFromHandler(h tui.Handler) ScrollableWithAttributes

NopScrollableWithAttributesFromHandler wraps a Handler to provide a ScrollableWithAttributes that does nothing.

func NopWithAttributesFromScrollable added in v0.0.2

func NopWithAttributesFromScrollable(s Scrollable) ScrollableWithAttributes

NopWithAttributesFromScrollable wraps a Scrollable to provide a ScrollableWithAttributes that does nothing.

type Span added in v0.0.25

type Span struct {
	component.Span
	// contains filtered or unexported fields
}

Span is a handler that takes another handler and handles padding and alignment. It is the handler counterpart to component.Span.

func NewSpan added in v0.0.25

func NewSpan(content tui.Handler, cfg component.SpanConfig) *Span

NewSpan returns an initialized Span.

func (*Span) Content added in v0.0.25

func (s *Span) Content() tui.Handler

Content returns this Span's underlying handler.

func (*Span) Cursor added in v0.0.25

func (s *Span) Cursor() (pos term.Coordinates, style term.CursorStyle, show bool)

Cursor satisfies tui.Handler by returning the underlying handler's cursor position offset by the span's content position.

func (*Span) Handle added in v0.0.25

func (s *Span) Handle(ev term.Event) (bool, bool)

Handle satisfies tui.Handler by delegating events to the underlying handler. Mouse events have their coordinates adjusted to account for the span's content offset.

func (*Span) Resize added in v0.0.36

func (s *Span) Resize(width, height int)

Resize satisfies tui.Component

func (*Span) Selection added in v0.0.25

func (s *Span) Selection() (string, bool)

Selection satisfies tui.Handler.

func (*Span) SetContent added in v0.0.25

func (s *Span) SetContent(content tui.Handler)

SetContent updates the underlying handler and resizes it to conform to this span's width and height.

type TestFloating added in v0.0.2

type TestFloating struct {
	TestHandler
	// contains filtered or unexported fields
}

TestFloating is a testing Handler.

func NewTestFloating added in v0.0.2

func NewTestFloating(width, height int) *TestFloating

NewTestFloating allocates storage for a new TestHandler and initializes it.

func (*TestFloating) Dimensions added in v0.0.2

func (t *TestFloating) Dimensions() (width, height int)

Dimensions returns the floating component dimensions.

type TestHandler added in v0.0.2

type TestHandler struct {
	component.TestComponent
	CursorPos      term.Coordinates
	CursorStyle    term.CursorStyle
	Exit           bool
	Handled        bool
	HandleOverride func(term.Event) (bool, bool)
}

TestHandler is a handler used to test composite handlers. Each event processed by this handler increments the Ch rune to the next rune.

func NewTestHandler added in v0.0.2

func NewTestHandler() (t *TestHandler)

NewTestHandler will allocate storage for a new handler and initialize it

func (*TestHandler) Cursor added in v0.0.2

func (t *TestHandler) Cursor() (term.Coordinates, term.CursorStyle, bool)

Cursor returns the set CursorPos.

func (*TestHandler) Handle added in v0.0.2

func (t *TestHandler) Handle(ev term.Event) (bool, bool)

Handle the next Event

func (*TestHandler) Selection added in v0.0.2

func (t *TestHandler) Selection() (string, bool)

Selection satisfies tui.Handler.

type Virtual added in v0.0.2

type Virtual[T tui.Handler] struct {
	component.Virtual[T]
}

Virtual wraps another tui.Handler to provide cursor event coordinates.

func (*Virtual[T]) Cursor added in v0.0.2

func (v *Virtual[T]) Cursor() (pos term.Coordinates, style term.CursorStyle, show bool)

Cursor satisfies tui.Handler.

func (*Virtual[T]) Handle added in v0.0.2

func (v *Virtual[T]) Handle(ev term.Event) (bool, bool)

Handle satisfies tui.Handler.

func (*Virtual[T]) Selection added in v0.0.2

func (v *Virtual[T]) Selection() (string, bool)

Selection satisfies tui.Handler.

type WithAttributes added in v0.0.2

type WithAttributes interface {
	tui.Handler
	SetAttr(term.Attributes) term.Attributes
}

WithAttributes represents a tui.Component that can be set attributes.

func NopWithAttributes added in v0.0.2

func NopWithAttributes() WithAttributes

NopWithAttributes returns a WithAttributes that does nothing.

func NopWithAttributesFromComponent added in v0.0.2

func NopWithAttributesFromComponent(c tui.Component) WithAttributes

NopWithAttributesFromComponent wraps a Component to provide a WithAttributes that does nothing.

func NopWithAttributesFromHandler added in v0.0.2

func NopWithAttributesFromHandler(h tui.Handler) WithAttributes

NopWithAttributesFromHandler wraps a Handler to provide a WithAttributes that does nothing.

type WithAttributesFloating added in v0.0.2

type WithAttributesFloating interface {
	WithAttributes
	component.Floating
}

WithAttributesFloating is a Floating that is capable of setting attributes.

func NopFloatingFromWithAttributes added in v0.0.2

func NopFloatingFromWithAttributes(a WithAttributes) WithAttributesFloating

NopFloatingFromWithAttributes wraps a WithAttributes to provide a WithAttributesFloating that does nothing.

func NopWithAttributesFloating added in v0.0.2

func NopWithAttributesFloating() WithAttributesFloating

NopWithAttributesFloating returns a WithAttributesFloating that does nothing.

func NopWithAttributesFloatingFromComponent added in v0.0.2

func NopWithAttributesFloatingFromComponent(c tui.Component) WithAttributesFloating

NopWithAttributesFloatingFromComponent wraps a Component to provide a WithAttributesFloating that does nothing.

func NopWithAttributesFloatingFromHandler added in v0.0.2

func NopWithAttributesFloatingFromHandler(h tui.Handler) WithAttributesFloating

NopWithAttributesFloatingFromHandler wraps a Handler to provide a WithAttributesFloating that does nothing.

func NopWithAttributesFromFloating added in v0.0.2

func NopWithAttributesFromFloating(f Floating) WithAttributesFloating

NopWithAttributesFromFloating wraps a Floating to provide a WithAttributesFloating that does nothing.

type WithAttributesResponsive added in v0.0.2

type WithAttributesResponsive interface {
	WithAttributes
	component.Responsive
}

WithAttributesResponsive is a Responsive that is capable of setting attributes.

func NopResponsiveFromWithAttributes added in v0.0.2

func NopResponsiveFromWithAttributes(a WithAttributes) WithAttributesResponsive

NopResponsiveFromWithAttributes wraps a WithAttributes to provide a WithAttributesResponsive that does nothing.

func NopWithAttributesFromResponsive added in v0.0.2

func NopWithAttributesFromResponsive(r Responsive) WithAttributesResponsive

NopWithAttributesFromResponsive wraps a Responsive to provide a WithAttributesResponsive that does nothing.

func NopWithAttributesResponsive added in v0.0.2

func NopWithAttributesResponsive() WithAttributesResponsive

NopWithAttributesResponsive returns a WithAttributesResponsive that does nothing.

func NopWithAttributesResponsiveFromComponent added in v0.0.2

func NopWithAttributesResponsiveFromComponent(c tui.Component) WithAttributesResponsive

NopWithAttributesResponsiveFromComponent wraps a Component to provide a WithAttributesResponsive that does nothing.

func NopWithAttributesResponsiveFromHandler added in v0.0.2

func NopWithAttributesResponsiveFromHandler(h tui.Handler) WithAttributesResponsive

NopWithAttributesResponsiveFromHandler wraps a Handler to provide a WithAttributesResponsive that does nothing.

type WithAttributesResponsiveFloating added in v0.0.2

type WithAttributesResponsiveFloating interface {
	WithAttributes
	component.Responsive
	component.Floating
}

WithAttributesResponsiveFloating is a Responsive and Floating that is capable of setting attributes.

func NopFloatingFromWithAttributesResponsive added in v0.0.2

func NopFloatingFromWithAttributesResponsive(ar WithAttributesResponsive) WithAttributesResponsiveFloating

NopFloatingFromWithAttributesResponsive wraps a WithAttributesResponsive to provide a WithAttributesResponsiveFloating that does nothing.

func NopResponsiveFloatingFromWithAttributes added in v0.0.2

func NopResponsiveFloatingFromWithAttributes(a WithAttributes) WithAttributesResponsiveFloating

NopResponsiveFloatingFromWithAttributes wraps a WithAttributes to provide a WithAttributesResponsiveFloating that does nothing.

func NopResponsiveFromWithAttributesFloating added in v0.0.2

func NopResponsiveFromWithAttributesFloating(af WithAttributesFloating) WithAttributesResponsiveFloating

NopResponsiveFromWithAttributesFloating wraps a WithAttributesFloating to provide a WithAttributesResponsiveFloating that does nothing.

func NopWithAttributesFloatingFromResponsive added in v0.0.2

func NopWithAttributesFloatingFromResponsive(r Responsive) WithAttributesResponsiveFloating

NopWithAttributesFloatingFromResponsive wraps a Responsive to provide a WithAttributesResponsiveFloating that does nothing.

func NopWithAttributesFromFloatingResponsive added in v0.0.2

func NopWithAttributesFromFloatingResponsive(fr FloatingResponsive) WithAttributesResponsiveFloating

NopWithAttributesFromFloatingResponsive wraps a FloatingResponsive to provide a WithAttributesResponsiveFloating that does nothing.

func NopWithAttributesResponsiveFloating added in v0.0.2

func NopWithAttributesResponsiveFloating() WithAttributesResponsiveFloating

NopWithAttributesResponsiveFloating returns a WithAttributesResponsiveFloating that does nothing.

func NopWithAttributesResponsiveFloatingFromComponent added in v0.0.2

func NopWithAttributesResponsiveFloatingFromComponent(c tui.Component) WithAttributesResponsiveFloating

NopWithAttributesResponsiveFloatingFromComponent wraps a Component to provide a WithAttributesResponsiveFloating that does nothing.

func NopWithAttributesResponsiveFloatingFromHandler added in v0.0.2

func NopWithAttributesResponsiveFloatingFromHandler(h tui.Handler) WithAttributesResponsiveFloating

NopWithAttributesResponsiveFloatingFromHandler wraps a Handler to provide a WithAttributesResponsiveFloating that does nothing.

func NopWithAttributesResponsiveFromFloating added in v0.0.2

func NopWithAttributesResponsiveFromFloating(f Floating) WithAttributesResponsiveFloating

NopWithAttributesResponsiveFromFloating wraps a Floating to provide a WithAttributesResponsiveFloating that does nothing.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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