render

package
v0.9.11 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ZBase is for base content:
	// revisions list, diff view, oplog, details, describe, bookmark operations
	ZBase = 0

	// ZFuzzyInput is for fuzzy input fields, text inputs, and revset list items
	ZFuzzyInput = 1

	// ZPreview is for preview panels and split views
	ZPreview = 10

	// ZRevsetOverlay is for revset overlay content (above preview)
	ZRevsetOverlay = 15

	// ZDialogs is for dialogs (undo/redo confirmation, input fields)
	// that should appear above the preview panel
	ZDialogs = 50

	// ZMenuBorder is for menu borders (git, bookmarks, choose, custom_commands)
	ZMenuBorder = 100

	// ZMenuContent is for menu content items
	ZMenuContent = 101

	// ZOverlay is for overlays like sequence overlay and flash messages
	ZOverlay = 200

	// ZExpandedStatus is for the expanded status bar help overlay (highest UI overlay)
	ZExpandedStatus = 275

	// ZPassword is for password input (highest priority modal)
	ZPassword = 300
)

Z-index constants for layered rendering. Higher values render on top. Components should use these named constants instead of magic numbers.

Variables

This section is empty.

Functions

func ClampStartLine

func ClampStartLine(startLine, viewHeight, totalLines int) int

ClampStartLine constrains a scroll start line to valid bounds. totalLines is the sum of all item heights; viewHeight is the visible area height.

func ProcessMouseEvent

func ProcessMouseEvent(interactions []InteractionOp, msg tea.MouseMsg) tea.Msg

ProcessMouseEvent matches a mouse event against interactions and returns the associated message. Interactions are expected to be sorted by Z-index (highest first) for proper priority handling. For scroll interactions, if the message implements ScrollDeltaCarrier, the delta will be set.

func ProcessMouseEventWithWindows

func ProcessMouseEventWithWindows(interactions []interactionOp, windows []windowOp, msg tea.MouseMsg) (tea.Msg, bool)

ProcessMouseEventWithWindows routes a mouse event through window scopes.

Types

type BoldEffect

type BoldEffect struct {
	Rect cellbuf.Rectangle
	Z    int
}

BoldEffect makes content bold.

func (BoldEffect) Apply

func (e BoldEffect) Apply(buf *cellbuf.Buffer)

func (BoldEffect) GetRect

func (e BoldEffect) GetRect() cellbuf.Rectangle

func (BoldEffect) GetZ

func (e BoldEffect) GetZ() int

type ClickMessage

type ClickMessage = tea.Msg

type ClickMessageFunc

type ClickMessageFunc func(index int) ClickMessage

type DimEffect

type DimEffect struct {
	Rect cellbuf.Rectangle
	Z    int
}

DimEffect dims the content by setting the Faint attribute.

func (DimEffect) Apply

func (e DimEffect) Apply(buf *cellbuf.Buffer)

func (DimEffect) GetRect

func (e DimEffect) GetRect() cellbuf.Rectangle

func (DimEffect) GetZ

func (e DimEffect) GetZ() int

type DisplayContext

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

DisplayContext holds all rendering operations for a frame. Operations are accumulated during the layout/render pass, then executed in order by batch and Z-index.

func NewDisplayContext

func NewDisplayContext() *DisplayContext

NewDisplayContext creates a new empty display context.

func (*DisplayContext) AddBold

func (dl *DisplayContext) AddBold(rect cellbuf.Rectangle, z int)

AddBold adds a BoldEffect.

func (*DisplayContext) AddDim

func (dl *DisplayContext) AddDim(rect cellbuf.Rectangle, z int)

AddDim adds a DimEffect (dims the content).

func (*DisplayContext) AddDraw

func (dl *DisplayContext) AddDraw(rect cellbuf.Rectangle, content string, z int)

AddDraw adds a Draw to the display context.

func (*DisplayContext) AddEffect

func (dl *DisplayContext) AddEffect(effect Effect)

AddEffect adds a custom Effect to the display context. This is the generic method that accepts any Effect implementation.

func (*DisplayContext) AddFill

func (dl *DisplayContext) AddFill(rect cellbuf.Rectangle, ch rune, style lipgloss.Style, z int)

AddFill fills a rectangle with the provided rune and style.

func (*DisplayContext) AddHighlight

func (dl *DisplayContext) AddHighlight(rect cellbuf.Rectangle, style lipgloss.Style, z int)

AddHighlight adds a HighlightEffect.

func (*DisplayContext) AddInteraction

func (dl *DisplayContext) AddInteraction(rect cellbuf.Rectangle, msg tea.Msg, typ InteractionType, z int)

AddInteraction adds an InteractionOp to the display context.

func (*DisplayContext) AddPaint

func (dl *DisplayContext) AddPaint(rect cellbuf.Rectangle, style lipgloss.Style, z int)

AddPaint adds a HighlightEffect with Force enabled, overriding existing background colors.

func (*DisplayContext) AddReverse

func (dl *DisplayContext) AddReverse(rect cellbuf.Rectangle, z int)

AddReverse adds a ReverseEffect (reverses foreground/background colors).

func (*DisplayContext) AddStrike

func (dl *DisplayContext) AddStrike(rect cellbuf.Rectangle, z int)

AddStrike adds a StrikeEffect (strikethrough).

func (*DisplayContext) AddUnderline

func (dl *DisplayContext) AddUnderline(rect cellbuf.Rectangle, z int)

AddUnderline adds an UnderlineEffect.

func (*DisplayContext) Clear

func (dl *DisplayContext) Clear()

Clear removes all operations from the display context. Useful for reusing a DisplayContext across frames.

func (*DisplayContext) DrawList

func (dl *DisplayContext) DrawList() []Draw

DrawList returns a copy of all Draw calls (useful for debugging/inspection)

func (*DisplayContext) EffectsList

func (dl *DisplayContext) EffectsList() []Effect

EffectsList returns a copy of all Effects (useful for debugging/inspection)

func (*DisplayContext) InteractionsList

func (dl *DisplayContext) InteractionsList() []InteractionOp

InteractionsList returns all interactions sorted by Z-index (highest first for priority).

func (*DisplayContext) Len

func (dl *DisplayContext) Len() int

Len returns the total number of operations in the display context

func (*DisplayContext) Merge

func (dl *DisplayContext) Merge(other *DisplayContext)

Merge adds all operations from another DisplayContext into this one.

func (*DisplayContext) ProcessMouseEvent

func (dl *DisplayContext) ProcessMouseEvent(msg tea.MouseMsg) (tea.Msg, bool)

ProcessMouseEvent routes a mouse event through the window stack.

func (*DisplayContext) Render

func (dl *DisplayContext) Render(buf *cellbuf.Buffer)

Render executes all operations in the display context to the given cellbuf. Order of execution: 1. Draw sorted by Z-index (low to high) 2. Effects sorted by Z-index (low to high)

func (*DisplayContext) RenderToString

func (dl *DisplayContext) RenderToString(width, height int) string

RenderToString is a convenience method that renders to a new buffer and returns the final string output.

func (*DisplayContext) Text

func (dl *DisplayContext) Text(x, y, z int) *TextBuilder

func (*DisplayContext) Window

func (dl *DisplayContext) Window(rect cellbuf.Rectangle, z int) *DisplayContext

Window creates a scoped display context that routes interactions to a window.

type DragStartCarrier

type DragStartCarrier interface {
	SetDragStart(x, y int) tea.Msg
}

DragStartCarrier is an interface for messages that carry drag start coordinates. The ProcessMouseEvent function will set the drag start position for drag interactions.

type Draw

type Draw struct {
	Rect    cellbuf.Rectangle // The area to draw in
	Content string            // Rendered ANSI string (from lipgloss, etc.)
	Z       int               // Z-index for layering (lower = back, higher = front)
}

Draw represents a content rendering operation. DrawOps are rendered first, sorted by Z-index (lower values render first).

type Effect

type Effect interface {
	// Apply applies the effect to the buffer
	Apply(buf *cellbuf.Buffer)
	// GetZ returns the Z-index for layering (higher Z renders later)
	GetZ() int
	// GetRect returns the rectangle this effect applies to
	GetRect() cellbuf.Rectangle
}

Effect is the interface that all effect operations must implement. Effects are post-processing operations that modify already-rendered content.

type FillEffect

type FillEffect struct {
	Rect  cellbuf.Rectangle
	Char  rune
	Style cellbuf.Style
	Z     int
}

func (FillEffect) Apply

func (e FillEffect) Apply(buf *cellbuf.Buffer)

func (FillEffect) GetRect

func (e FillEffect) GetRect() cellbuf.Rectangle

func (FillEffect) GetZ

func (e FillEffect) GetZ() int

type HighlightEffect

type HighlightEffect struct {
	Rect  cellbuf.Rectangle
	Style lipgloss.Style
	Z     int
	Force bool
}

HighlightEffect applies a highlight style by changing the background color. Extracts the background color from the lipgloss.Style and applies it to cells.

func (HighlightEffect) Apply

func (e HighlightEffect) Apply(buf *cellbuf.Buffer)

func (HighlightEffect) GetRect

func (e HighlightEffect) GetRect() cellbuf.Rectangle

func (HighlightEffect) GetZ

func (e HighlightEffect) GetZ() int

type InteractionOp

type InteractionOp struct {
	Rect cellbuf.Rectangle // The interactive area (absolute coordinates)
	Msg  tea.Msg           // Message to send
	Type InteractionType   // What kind of interaction this supports
	Z    int               // Z-index for overlapping regions (higher = priority)
}

InteractionOp represents an interactive region that responds to input.

type InteractionType

type InteractionType int

InteractionType defines what kinds of input an interactive region responds to. Multiple types can be combined using bitwise OR.

const (
	InteractionClick InteractionType = 1 << iota
	InteractionScroll
	InteractionDrag
	InteractionHover
)

type ListRenderer

type ListRenderer struct {
	StartLine     int
	ScrollMsg     tea.Msg
	FirstRowIndex int
	LastRowIndex  int
}

func NewListRenderer

func NewListRenderer(scrollMsg tea.Msg) *ListRenderer

func (*ListRenderer) GetFirstRowIndex

func (r *ListRenderer) GetFirstRowIndex() int

func (*ListRenderer) GetLastRowIndex

func (r *ListRenderer) GetLastRowIndex() int

func (*ListRenderer) GetScrollOffset

func (r *ListRenderer) GetScrollOffset() int

func (*ListRenderer) RegisterScroll

func (r *ListRenderer) RegisterScroll(dl *DisplayContext, viewRect layout.Box)

RegisterScroll registers a scroll interaction for the given view rect. Call this after Render if you want to enable mouse wheel scrolling.

func (*ListRenderer) Render

func (r *ListRenderer) Render(
	dl *DisplayContext,
	viewRect layout.Box,
	itemCount int,
	cursor int,
	ensureCursorVisible bool,
	measure measureItemFunc,
	render RenderItemFunc,
	clickMsg ClickMessageFunc,
)

Render renders visible items to the DisplayContext. Note: Scroll interaction registration is the caller's responsibility.

func (*ListRenderer) SetScrollOffset

func (r *ListRenderer) SetScrollOffset(offset int)

type RenderItemFunc

type RenderItemFunc func(dl *DisplayContext, index int, rect cellbuf.Rectangle)

type ReverseEffect

type ReverseEffect struct {
	Rect cellbuf.Rectangle
	Z    int
}

ReverseEffect reverses foreground and background colors.

func (ReverseEffect) Apply

func (e ReverseEffect) Apply(buf *cellbuf.Buffer)

func (ReverseEffect) GetRect

func (e ReverseEffect) GetRect() cellbuf.Rectangle

func (ReverseEffect) GetZ

func (e ReverseEffect) GetZ() int

type ScrollDeltaCarrier

type ScrollDeltaCarrier interface {
	SetDelta(delta int, horizontal bool) tea.Msg
}

ScrollDeltaCarrier is an interface for messages that carry scroll delta information. The ProcessMouseEvent function will set the Delta field for scroll interactions.

type StrikeEffect

type StrikeEffect struct {
	Rect cellbuf.Rectangle
	Z    int
}

StrikeEffect adds strikethrough to content.

func (StrikeEffect) Apply

func (e StrikeEffect) Apply(buf *cellbuf.Buffer)

func (StrikeEffect) GetRect

func (e StrikeEffect) GetRect() cellbuf.Rectangle

func (StrikeEffect) GetZ

func (e StrikeEffect) GetZ() int

type TextBuilder

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

func (*TextBuilder) Clickable

func (tb *TextBuilder) Clickable(text string, style lipgloss.Style, onClick tea.Msg) *TextBuilder

func (*TextBuilder) Done

func (tb *TextBuilder) Done()

func (*TextBuilder) Measure

func (tb *TextBuilder) Measure() (int, int)

func (*TextBuilder) NewLine

func (tb *TextBuilder) NewLine() *TextBuilder

func (*TextBuilder) Space

func (tb *TextBuilder) Space(count int) *TextBuilder

func (*TextBuilder) Styled

func (tb *TextBuilder) Styled(text string, style lipgloss.Style) *TextBuilder

func (*TextBuilder) Write

func (tb *TextBuilder) Write(text string) *TextBuilder

type UnderlineEffect

type UnderlineEffect struct {
	Rect cellbuf.Rectangle
	Z    int
}

UnderlineEffect adds underline to content.

func (UnderlineEffect) Apply

func (e UnderlineEffect) Apply(buf *cellbuf.Buffer)

func (UnderlineEffect) GetRect

func (e UnderlineEffect) GetRect() cellbuf.Rectangle

func (UnderlineEffect) GetZ

func (e UnderlineEffect) GetZ() int

Jump to

Keyboard shortcuts

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