tview

package
v0.4.16 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPlaceholderLines added in v0.3.0

func BuildPlaceholderLines(placeholder *nav.ImagePlaceholder) []string

BuildPlaceholderLines generates the Unicode placeholder lines for a resolved image. Each line is a string of tview-tagged text containing U+10EEEE characters with combining diacritics encoding row/column/id and foreground color encoding image ID.

Each placeholder cell has 3 combining marks matching icat's protocol:

  1. Row diacritic (encodes the row index)
  2. Column diacritic (encodes the column index)
  3. ID diacritic (encodes the upper byte of the image ID)

The lower 3 bytes of the image ID are encoded in the foreground color (RGB).

Types

type BoxViewer added in v0.1.1

type BoxViewer struct {
	*tview.Box
	// contains filtered or unexported fields
}

boxViewer is a TView adapter for the core navidown markdown session. it renders core ANSI output into tview primitives and supports link navigation + activation.

func NewBox added in v0.1.1

func NewBox() *BoxViewer

newBox creates a new TView markdown viewer backed by a Box.

func (*BoxViewer) Core added in v0.1.1

func (v *BoxViewer) Core() *nav.MarkdownSession

Core exposes the underlying UI-agnostic markdown session.

func (*BoxViewer) Draw added in v0.1.1

func (v *BoxViewer) Draw(screen tcell.Screen)

draw renders the component.

func (*BoxViewer) InputHandler added in v0.1.1

func (v *BoxViewer) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

inputHandler returns the input handler for this component.

func (*BoxViewer) SetAnsiConverter added in v0.1.1

func (v *BoxViewer) SetAnsiConverter(c *util.AnsiConverter)

setAnsiConverter configures optional ANSI->tview conversion. If nil, tview.TranslateANSI is used.

func (*BoxViewer) SetBackgroundColor added in v0.1.1

func (v *BoxViewer) SetBackgroundColor(color tcell.Color) *BoxViewer

setBackgroundColor sets the background color for empty space. use tcell.ColorDefault to disable background filling (default behavior).

func (*BoxViewer) SetCorrelator added in v0.1.1

func (v *BoxViewer) SetCorrelator(c nav.PositionCorrelator)

setCorrelator delegates to the core viewer.

func (*BoxViewer) SetImageManager added in v0.3.0

func (v *BoxViewer) SetImageManager(m *ImageManager) *BoxViewer

SetImageManager enables Kitty image protocol support. When set, images in markdown will be rendered as Unicode placeholders.

func (*BoxViewer) SetMarkdown added in v0.1.1

func (v *BoxViewer) SetMarkdown(content string) *BoxViewer

setMarkdown sets markdown content to display.

func (*BoxViewer) SetMarkdownWithSource added in v0.1.1

func (v *BoxViewer) SetMarkdownWithSource(content string, sourceFilePath string, pushToHistory bool) *BoxViewer

setMarkdownWithSource sets markdown content with source file context.

func (*BoxViewer) SetRenderer added in v0.1.1

func (v *BoxViewer) SetRenderer(r nav.Renderer) *BoxViewer

setRenderer configures the renderer used by the core viewer. this allows dynamic switching between light/dark styles.

func (*BoxViewer) SetSelectHandler added in v0.1.1

func (v *BoxViewer) SetSelectHandler(handler func(*BoxViewer, nav.NavElement)) *BoxViewer

setSelectHandler sets the callback for when Enter is pressed on a selected element.

func (*BoxViewer) SetStateChangedHandler added in v0.1.1

func (v *BoxViewer) SetStateChangedHandler(handler func(*BoxViewer)) *BoxViewer

setStateChangedHandler sets a callback for when navigation state changes (selection/scroll/history).

type ImageManager added in v0.3.0

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

ImageManager handles Kitty image protocol transmission and lifecycle. It tracks which images have been transmitted to the terminal and manages ID allocation for the Unicode placeholder protocol.

func NewImageManager added in v0.3.0

func NewImageManager(resolver *nav.ImageResolver, cellWidth, cellHeight int) *ImageManager

NewImageManager creates a new image manager. cellWidth and cellHeight are the assumed pixel dimensions of a terminal cell. Common defaults: 8x16 for standard terminals, 10x20 for HiDPI.

func (*ImageManager) DeleteAll added in v0.3.0

func (m *ImageManager) DeleteAll(screen tcell.Screen)

DeleteAll removes all images from the terminal.

func (*ImageManager) DeleteImage added in v0.3.0

func (m *ImageManager) DeleteImage(screen tcell.Screen, id uint32)

DeleteImage removes an image from the terminal and internal tracking.

func (*ImageManager) DetectSupport added in v0.3.0

func (m *ImageManager) DetectSupport(screen tcell.Screen)

DetectSupport queries the terminal for Kitty graphics protocol support. This sends a test graphics command and checks for a response. Must be called with access to a Tty that supports reading responses.

func (*ImageManager) EnsureTransmitted added in v0.3.0

func (m *ImageManager) EnsureTransmitted(screen tcell.Screen, id uint32)

EnsureTransmitted transmits an image to the terminal if it hasn't been sent yet. Images are downscaled to match the display grid pixel dimensions before transmission to stay within Kitty's 320MB RGBA storage quota.

func (*ImageManager) InvalidateAll added in v0.4.15

func (m *ImageManager) InvalidateAll(screen tcell.Screen)

InvalidateAll resets all image tracking state, clears the resolver cache, and purges all Kitty terminal images. Call before re-rendering to force fresh image resolution and transmission.

func (*ImageManager) InvalidateForDocument added in v0.4.15

func (m *ImageManager) InvalidateForDocument(screen tcell.Screen, urls []string)

InvalidateForDocument evicts image tracking for the given URLs and purges their Kitty terminal images. Other images remain cached.

func (*ImageManager) PreResolveImages added in v0.4.1

func (m *ImageManager) PreResolveImages(urls []string, sourceFilePath string)

PreResolveImages resolves multiple image URLs in parallel, warming the cache. Subsequent ResolveAndAllocate calls for these URLs will be fast cache hits.

func (*ImageManager) ResolveAndAllocate added in v0.3.0

func (m *ImageManager) ResolveAndAllocate(url, sourceFilePath string, maxCols int) (*nav.ImagePlaceholder, error)

ResolveAndAllocate resolves an image URL and assigns it a Kitty image ID. Returns the ImagePlaceholder with dimensions calculated for the given viewport width.

func (*ImageManager) SetMaxRows added in v0.3.0

func (m *ImageManager) SetMaxRows(maxRows int)

SetMaxRows sets the maximum number of terminal rows an image can occupy. Use 0 for no limit. Default is 0 (no limit).

func (*ImageManager) SetSupported added in v0.3.0

func (m *ImageManager) SetSupported(supported bool)

SetSupported explicitly sets whether image support is available. Call this after terminal capability detection.

func (*ImageManager) Supported added in v0.3.0

func (m *ImageManager) Supported() bool

Supported returns whether the terminal supports Kitty graphics protocol. Returns false if detection hasn't run or the terminal doesn't support it.

func (*ImageManager) UpdateCellSize added in v0.3.0

func (m *ImageManager) UpdateCellSize(screen tcell.Screen) bool

UpdateCellSize queries the terminal for actual cell pixel dimensions and updates the manager if they differ from the current values. When cell size changes, cached display dimensions and transmission state are invalidated so images are re-resolved and re-transmitted at the correct size. Returns true if cell size changed, false otherwise.

type KittyImageProcessor added in v0.3.0

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

KittyImageProcessor replaces image placeholder tokens with Kitty Unicode placeholder lines. It uses an ImageManager to resolve images and allocate IDs.

func NewKittyImageProcessor added in v0.3.0

func NewKittyImageProcessor(manager *ImageManager) *KittyImageProcessor

NewKittyImageProcessor creates a new processor backed by the given manager.

func (*KittyImageProcessor) ProcessImageTokens added in v0.3.0

func (p *KittyImageProcessor) ProcessImageTokens(lines []string, sourceFilePath string, maxCols int) []string

ProcessImageTokens scans lines for image tokens and replaces them with Kitty Unicode placeholder rows. Images are pre-resolved in parallel before sequential placeholder generation.

type TextViewViewer added in v0.1.1

type TextViewViewer struct {
	*tview.TextView
	// contains filtered or unexported fields
}

TextViewViewer is a TextView-based adapter for the core navidown markdown session. it preserves TextView paging while supporting link navigation + activation.

func NewTextView added in v0.1.1

func NewTextView() *TextViewViewer

NewTextView creates a new TView markdown viewer backed by a TextView.

func (*TextViewViewer) Core added in v0.1.1

func (v *TextViewViewer) Core() *nav.MarkdownSession

Core exposes the underlying UI-agnostic markdown session.

func (*TextViewViewer) Draw added in v0.2.1

func (v *TextViewViewer) Draw(screen tcell.Screen)

Draw handles rendering and width changes.

func (*TextViewViewer) InputHandler added in v0.1.1

func (v *TextViewViewer) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

inputHandler returns the input handler for this component.

func (*TextViewViewer) InvalidateAll added in v0.4.15

func (v *TextViewViewer) InvalidateAll(screen tcell.Screen)

InvalidateAll flushes all caches (diagram renderers, image resolver, SVG rasterizer) and purges Kitty terminal images. Call before re-loading content with SetMarkdownWithSource to force a complete re-render from disk.

func (*TextViewViewer) InvalidateForDocument added in v0.4.15

func (v *TextViewViewer) InvalidateForDocument(screen tcell.Screen)

InvalidateForDocument evicts only cache entries used by the currently displayed document. Other documents' cached diagrams and images are preserved.

func (*TextViewViewer) ScrollToAnchor added in v0.2.0

func (v *TextViewViewer) ScrollToAnchor(slug string, pushToHistory bool) bool

ScrollToAnchor scrolls to a header by slug and triggers UI redraw.

func (*TextViewViewer) SetAnsiConverter added in v0.1.1

func (v *TextViewViewer) SetAnsiConverter(c *util.AnsiConverter)

SetAnsiConverter configures optional ANSI->tview conversion. If nil, tview.TranslateANSI is used.

func (*TextViewViewer) SetBackgroundColor added in v0.1.1

func (v *TextViewViewer) SetBackgroundColor(color tcell.Color) *TextViewViewer

SetBackgroundColor sets the background color for empty space. use tcell.ColorDefault to disable background filling (default behavior).

func (*TextViewViewer) SetCorrelator added in v0.1.1

func (v *TextViewViewer) SetCorrelator(c nav.PositionCorrelator)

setCorrelator delegates to the core viewer.

func (*TextViewViewer) SetImageManager added in v0.3.0

func (v *TextViewViewer) SetImageManager(m *ImageManager) *TextViewViewer

SetImageManager enables Kitty image protocol support. When set, images in markdown will be rendered as Unicode placeholders.

func (*TextViewViewer) SetMarkdown added in v0.1.1

func (v *TextViewViewer) SetMarkdown(content string) *TextViewViewer

SetMarkdown sets markdown content to display.

func (*TextViewViewer) SetMarkdownWithSource added in v0.1.1

func (v *TextViewViewer) SetMarkdownWithSource(content string, sourceFilePath string, pushToHistory bool) *TextViewViewer

SetMarkdownWithSource sets markdown content with source file context.

func (*TextViewViewer) SetRenderer added in v0.1.1

func (v *TextViewViewer) SetRenderer(r nav.Renderer) *TextViewViewer

SetRenderer configures the renderer used by the core viewer. this allows dynamic switching between light/dark styles.

func (*TextViewViewer) SetSelectHandler added in v0.1.1

func (v *TextViewViewer) SetSelectHandler(handler func(*TextViewViewer, nav.NavElement)) *TextViewViewer

SetSelectHandler sets the callback for when Enter is pressed on a selected element.

func (*TextViewViewer) SetStateChangedHandler added in v0.1.1

func (v *TextViewViewer) SetStateChangedHandler(handler func(*TextViewViewer)) *TextViewViewer

SetStateChangedHandler sets a callback for when navigation state changes (selection/scroll/history).

Jump to

Keyboard shortcuts

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