Documentation
¶
Overview ¶
Package pearl provides some huninn components.
Index ¶
- type AddTaskMsg
- type Block
- type BlockSetContentMsg
- type BufferedBlock
- func (c *BufferedBlock) Append(str string)
- func (c *BufferedBlock) Capacity() int
- func (c *BufferedBlock) Clear()
- func (c *BufferedBlock) Entries() []*tapioca.Entry
- func (c *BufferedBlock) Init() tea.Cmd
- func (c *BufferedBlock) Prepend(str string)
- func (c *BufferedBlock) ResizeBuffer(newSize int)
- func (c *BufferedBlock) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (c *BufferedBlock) UpdateInto(msg tea.Msg) (*BufferedBlock, tea.Cmd)
- func (c *BufferedBlock) View() string
- type LogMsg
- type LogPanel
- func (lp *LogPanel) CreateWriter(send func(tea.Msg), also io.Writer) io.Writer
- func (lp *LogPanel) Init() tea.Cmd
- func (lp *LogPanel) ScrollController() tapioca.ScrollController
- func (lp *LogPanel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (lp *LogPanel) UpdateInto(msg tea.Msg) (*LogPanel, tea.Cmd)
- func (lp *LogPanel) View() string
- type RemoveTaskMsg
- type Span
- type SpanSetContentMsg
- type TaskController
- type TaskList
- type TaskManager
- type TaskState
- type UpdateTaskDescMsg
- type UpdateTaskStateMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddTaskMsg ¶
AddTaskMsg is a message to add a new task.
If the id already exists, the task will not be added.
type Block ¶
type Block struct {
tapioca.Scrollable
// contains filtered or unexported fields
}
Block is a component that displays lines of text with scrollable capabilities.
func NewBlock ¶
func NewBlock() *Block
NewBlock creates a new Block component with horizontal and vertical scrolling enabled.
func (*Block) SetContent ¶ added in v0.0.2
SetContent sets the content of the Block to the provided lines of text.
You should use it only when you are handling an event message.
type BlockSetContentMsg ¶
type BlockSetContentMsg struct {
// contains filtered or unexported fields
}
BlockSetContentMsg is a message type used to set the content of a Block component.
type BufferedBlock ¶ added in v0.0.2
type BufferedBlock struct {
tapioca.Scrollable
// contains filtered or unexported fields
}
BufferedBlock is the default implementation of a huninn component that provides scrollable text display functionality.
If you need proper control over text display, you might want to take a look at tapioca.Entry.
func NewBufferedBlock ¶ added in v0.0.2
func NewBufferedBlock(size int, hScroll, vScroll bool) *BufferedBlock
NewBufferedBlock creates a new component with the specified entry capacity. The size parameter determines how many entries the circular buffer can hold. When the buffer is full, adding new entries will overwrite the oldest ones.
func (*BufferedBlock) Append ¶ added in v0.0.2
func (c *BufferedBlock) Append(str string)
Append adds a new entry to the end of the virtual screen. In a log panel context, this would add a new log message at the bottom (older messages are shown by default since the viewport starts at position 0,0).
func (*BufferedBlock) Capacity ¶ added in v0.0.2
func (c *BufferedBlock) Capacity() int
Capacity returns the maximum number of entries the component can hold.
func (*BufferedBlock) Clear ¶ added in v0.0.2
func (c *BufferedBlock) Clear()
Clear removes all entries from the component.
func (*BufferedBlock) Entries ¶ added in v0.0.2
func (c *BufferedBlock) Entries() []*tapioca.Entry
Entries returns all entries currently stored in the component.
func (*BufferedBlock) Init ¶ added in v0.0.2
func (c *BufferedBlock) Init() tea.Cmd
Init implements the tea.Model interface.
func (*BufferedBlock) Prepend ¶ added in v0.0.2
func (c *BufferedBlock) Prepend(str string)
Prepend adds a new entry to the beginning of the virtual screen. In a log panel context, this would add a new log message at the top (newer messages are shown by default since the viewport starts at position 0,0).
func (*BufferedBlock) ResizeBuffer ¶ added in v0.0.2
func (c *BufferedBlock) ResizeBuffer(newSize int)
ResizeBuffer changes the capacity of the entries buffer to newSize.
func (*BufferedBlock) Update ¶ added in v0.0.2
Update implements the tea.Model interface. It handles ResizeMsg and scroll-related messages. When embedding this Component in your own model, you should forward ResizeMsg and scroll messages to this method while handling your own messages separately.
func (*BufferedBlock) UpdateInto ¶ added in v0.0.2
func (c *BufferedBlock) UpdateInto(msg tea.Msg) (*BufferedBlock, tea.Cmd)
UpdateInto is identical to Update, but returns a *Component instead of a tea.Model.
This is useful when embedding this Component in your own model, as it avoids the need for type assertions.
func (*BufferedBlock) View ¶ added in v0.0.2
func (c *BufferedBlock) View() string
View implements the tea.Model interface. It returns a string representation of the current viewport, applying the current scroll position and wrapping behavior based on the component's configuration.
type LogPanel ¶
type LogPanel struct {
// if true, new log messages are placed at the top
// by default, new log messages are placed at the bottom
Reverse bool
// contains filtered or unexported fields
}
LogPanel displays log messages in an area.
You must create LogPanel with NewLogPanel().
LogPanel does not support manually scrolling.
func (*LogPanel) CreateWriter ¶
CreateWriter returns an io.Writer that writes log messages to the given LogPanel.
The send function is used to send LogMsg messages to the Bubble Tea program.
If also is not nil, the returned io.Writer also writes to also.
You can use LogPanelWriter like this:
var logPanel *pearl.LogPanel
var logFile *os.File
...
logger := log.New(pearl.LogPanelWriter(logPanel, send, logFile), "", log.LstdFlags)
logger.Println("This log message is written to both logPanel and logFile")
func (*LogPanel) ScrollController ¶ added in v0.0.2
func (lp *LogPanel) ScrollController() tapioca.ScrollController
func (*LogPanel) UpdateInto ¶
UpdateInto is identical to Update, but returns *LogPanel instead of tea.Model.
type RemoveTaskMsg ¶
RemoveTaskMsg is a message to remove a task.
If the id does not exist, the message will be ignored.
type Span ¶ added in v0.0.2
type Span struct {
// contains filtered or unexported fields
}
Span is a single line text box that can be used to display a single entry of text.
It warps the content to fit the width of the box, and truncates the content to fit the height of the box.
func (*Span) SetContent ¶ added in v0.0.2
SetContent sets the content of the span.
You should use it only when you are handling an event message.
func (*Span) Setter ¶ added in v0.0.2
Setter returns a function that can be used to set the content of the span by sending a SpanSetContentMsg to bubble tea program.
func (*Span) UpdateInto ¶ added in v0.0.2
UpdateInto is identical to Update but returns a *Span instead of tea.Model to prevent type assertion.
type SpanSetContentMsg ¶ added in v0.0.2
type SpanSetContentMsg struct {
// contains filtered or unexported fields
}
type TaskController ¶
type TaskController interface {
SetDesc(desc string)
SetState(state TaskState, progress float64)
Done()
Fail()
Remove()
}
TaskController is used to control what info is shown for a task.
type TaskList ¶
type TaskList struct {
// contains filtered or unexported fields
}
TaskList is a component that manages and displays a list of tasks with their states.
You might send task message by your own, or use TaskManager.
func (*TaskList) CreateManager ¶
func (tl *TaskList) CreateManager(send func(tea.Msg)) TaskManager
CreateManager creates a new TaskManager.
type TaskManager ¶
type TaskManager interface {
AddTask(desc, id string) TaskController
}
TaskManager is used to create and manage tasks.
func NopTaskManager ¶ added in v0.0.2
func NopTaskManager() TaskManager
NopTaskManager returns a TaskManager that does nothing.
This can be useful when you have to support both a UI and a non-UI mode.
type UpdateTaskDescMsg ¶
UpdateTaskDescMsg is a message to update the description of a task.
If the id does not exist, the message will be ignored.
type UpdateTaskStateMsg ¶
type UpdateTaskStateMsg struct {
TaskListID int64
ID string
State TaskState
// ignored if State is not TaskRunning
// value between 0.0 and 1.0
// if > 1.0, it will be set to 1.0
// if < 0.0, hide progress counter
Progress float64
}
UpdateTaskStateMsg is a message to update the state of a task.
If the id does not exist, the message will be ignored.