Documentation
¶
Overview ¶
Package live provides auto-refreshing terminal displays.
Index ¶
- type Live
- type LiveRender
- func (lr *LiveRender) PositionCursor() segment.Control
- func (lr *LiveRender) Render(c *console.Console, opts console.Options) []segment.Segment
- func (lr *LiveRender) RestoreCursor() segment.Control
- func (lr *LiveRender) SetRenderable(r console.Renderable)
- func (lr *LiveRender) Shape() (width, height int)
- type Option
- type VerticalOverflow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Live ¶
type Live struct {
// contains filtered or unexported fields
}
Live provides an auto-refreshing terminal display.
func (*Live) ProcessRenderables ¶
func (l *Live) ProcessRenderables(renderables []console.Renderable) []console.Renderable
ProcessRenderables implements console.RenderHook. This intercepts all console.Render calls while Live is active.
Note: We read console properties BEFORE acquiring l.mu to avoid deadlock. console.Render() holds c.mu when calling this method, so calling l.console.IsTerminal() while holding l.mu would try to acquire c.mu again.
func (*Live) Update ¶
func (l *Live) Update(r console.Renderable)
Update changes the renderable being displayed.
type LiveRender ¶
type LiveRender struct {
// contains filtered or unexported fields
}
LiveRender tracks the rendered state and handles cursor repositioning.
func NewLiveRender ¶
func NewLiveRender(renderable console.Renderable, overflow VerticalOverflow) *LiveRender
NewLiveRender creates a new LiveRender.
func (*LiveRender) PositionCursor ¶
func (lr *LiveRender) PositionCursor() segment.Control
PositionCursor returns a Control that moves the cursor back to the start of the previously rendered content, erasing it in the process.
func (*LiveRender) RestoreCursor ¶
func (lr *LiveRender) RestoreCursor() segment.Control
RestoreCursor returns a Control that moves the cursor to erase all content and returns to the original position. Used for transient mode.
func (*LiveRender) SetRenderable ¶
func (lr *LiveRender) SetRenderable(r console.Renderable)
SetRenderable updates the renderable to display.
func (*LiveRender) Shape ¶
func (lr *LiveRender) Shape() (width, height int)
Shape returns the last rendered shape (width, height).
type Option ¶
type Option func(*Live)
Option configures a Live display.
func WithAutoRefresh ¶
WithAutoRefresh enables automatic refresh at the given rate.
func WithGetRenderable ¶
func WithGetRenderable(fn func() console.Renderable) Option
WithGetRenderable sets a callback to get the renderable on each refresh.
func WithRefreshRate ¶
WithRefreshRate sets the refresh rate (default 10Hz).
func WithTransient ¶
WithTransient makes the live display disappear when stopped.
func WithVerticalOverflow ¶
func WithVerticalOverflow(overflow VerticalOverflow) Option
WithVerticalOverflow sets how vertical overflow is handled.
type VerticalOverflow ¶
type VerticalOverflow int
VerticalOverflow determines how vertical overflow is handled.
const ( OverflowVisible VerticalOverflow = iota // Show all content OverflowCrop // Crop to terminal height OverflowEllipsis // Show ellipsis for cropped content )