hub

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DrawOptions added in v0.6.0

type DrawOptions struct {
	Prompt       bool // draw only the prompt
	PurgeCache   bool // purge display cache only
	RunningQuery bool // a query is currently running
	DisableCache bool // disable display cache
	ForceSync    bool // force a full screen sync
}

DrawOptions controls how the screen is drawn.

type Hub

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

Hub acts as the messaging hub between components -- that is, it controls how the communication that goes through channels are handled.

func New

func New(bufsiz int) *Hub

New creates a new Hub struct

func (*Hub) Batch

func (h *Hub) Batch(ctx context.Context, f func(ctx context.Context))

Batch allows you to synchronously send messages during the scope of f() being executed. The mutex is acquired automatically unless this is a nested Batch call (detected via context).

func (*Hub) DrawCh

func (h *Hub) DrawCh() chan *Payload[*DrawOptions]

DrawCh returns the channel to redraw the terminal display

func (*Hub) PagingCh

func (h *Hub) PagingCh() chan *Payload[PagingRequest]

PagingCh returns the channel to page through the results

func (*Hub) QueryCh

func (h *Hub) QueryCh() chan *Payload[string]

QueryCh returns the underlying channel for queries

func (*Hub) SendDraw

func (h *Hub) SendDraw(ctx context.Context, options *DrawOptions)

SendDraw sends a request to redraw the terminal display

func (*Hub) SendDrawPrompt

func (h *Hub) SendDrawPrompt(ctx context.Context)

SendDrawPrompt sends a request to redraw the prompt only

func (*Hub) SendPaging

func (h *Hub) SendPaging(ctx context.Context, x PagingRequest)

SendPaging sends a request to move the cursor around

func (*Hub) SendQuery

func (h *Hub) SendQuery(ctx context.Context, q string)

SendQuery sends the query string to be processed by the Filter

func (*Hub) SendStatusMsg

func (h *Hub) SendStatusMsg(ctx context.Context, q string, clearDelay time.Duration)

SendStatusMsg sends a string to be displayed in the status message. If clearDelay is non-zero, the message will be cleared after that duration.

func (*Hub) StatusMsgCh

func (h *Hub) StatusMsgCh() chan *Payload[StatusMsg]

StatusMsgCh returns the channel to update the status message

type JumpToLineRequest added in v0.6.0

type JumpToLineRequest int

JumpToLineRequest is a PagingRequest that jumps to a specific line

func (JumpToLineRequest) Line added in v0.6.0

func (jlr JumpToLineRequest) Line() int

Line returns the target line number

func (JumpToLineRequest) Type added in v0.6.0

Type satisfies the PagingRequest interface

type PagingRequest added in v0.6.0

type PagingRequest interface {
	Type() PagingRequestType
}

PagingRequest can be sent to move the selection cursor

type PagingRequestType added in v0.6.0

type PagingRequestType int

PagingRequestType is the type of a paging request

const (
	ToLineAbove       PagingRequestType = iota // ToLineAbove moves the selection to the line above
	ToScrollPageDown                           // ToScrollPageDown moves the selection to the next page
	ToLineBelow                                // ToLineBelow moves the selection to the line below
	ToScrollPageUp                             // ToScrollPageUp moves the selection to the previous page
	ToScrollLeft                               // ToScrollLeft scrolls screen to the left
	ToScrollRight                              // ToScrollRight scrolls screen to the right
	ToLineInPage                               // ToLineInPage jumps to a particular line on the page
	ToScrollFirstItem                          // ToScrollFirstItem
	ToScrollLastItem                           // ToScrollLastItem
)

func (PagingRequestType) String added in v0.6.0

func (i PagingRequestType) String() string

func (PagingRequestType) Type added in v0.6.0

Type satisfies the PagingRequest interface for PagingRequestType itself

type Payload

type Payload[T any] struct {
	// contains filtered or unexported fields
}

Payload is a wrapper around the actual request value that needs to be passed. It contains an optional channel field which can be filled to force synchronous communication between the sender and receiver

func NewPayload

func NewPayload[T any](data T, batch bool) *Payload[T]

NewPayload creates a new Payload with the given data and batch flag.

func (*Payload[T]) Batch added in v0.5.7

func (p *Payload[T]) Batch() bool

Batch returns true if this payload is part of a batch operation.

func (*Payload[T]) Data

func (p *Payload[T]) Data() T

Data returns the underlying data.

func (*Payload[T]) Done

func (p *Payload[T]) Done()

Done marks the request as done. In non-batch mode it's a no-op. In batch mode it signals the sender that the receiver has finished processing this payload.

type StatusMsg added in v0.5.7

type StatusMsg interface {
	Message() string
	Delay() time.Duration
}

StatusMsg is an interface for status message requests.

Jump to

Keyboard shortcuts

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