preview

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package preview implements the file preview panel for the grut TUI. It provides syntax-highlighted code display, markdown rendering, binary file detection, and a scrollable viewport.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Preview

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

Preview is the file preview panel. It displays syntax-highlighted source code, rendered markdown, or file metadata for binary/oversized files.

func New

func New(cfg config.PreviewConfig) *Preview

New creates a new Preview panel with the given configuration.

func (*Preview) Blur

func (p *Preview) Blur()

Blur implements panels.Panel.

func (*Preview) FilePath

func (p *Preview) FilePath() string

FilePath returns the path of the currently displayed file (empty if none).

func (*Preview) Focus

func (p *Preview) Focus()

Focus implements panels.Panel.

func (*Preview) Init

func (p *Preview) Init(_ context.Context) tea.Cmd

Init implements panels.Panel.

func (*Preview) KeyBindings

func (p *Preview) KeyBindings() []panels.KeyBinding

KeyBindings implements panels.Panel.

func (*Preview) SetGitClient

func (p *Preview) SetGitClient(gc git.StatusReader)

SetGitClient configures the git client for diff-aware preview.

func (*Preview) SetSize

func (p *Preview) SetSize(width, height int)

SetSize implements panels.Panel.

func (*Preview) Title

func (p *Preview) Title() string

Title implements panels.Panel. Returns the filename when a file is loaded, the GitHub item title when in ghMode, or "preview" when nothing is selected.

func (*Preview) Update

func (p *Preview) Update(msg tea.Msg) (panels.Panel, tea.Cmd)

Update implements panels.Panel. It handles file selection messages and keyboard events for scrolling and toggling display options.

func (*Preview) View

func (p *Preview) View(width, height int) string

View implements panels.Panel. It renders the preview content into the given width×height area.

Jump to

Keyboard shortcuts

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