filepreview

package
v0.98.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package filepreview loads a regular file into a text preview. It is the shared loader for the Files plugin and docview, so neither surface needs to import the other.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Highlight

func Highlight(content, extension, syntaxTheme string) (string, error)

Highlight returns a syntax highlighted string.

func LoadPreview

func LoadPreview(rootDir, path string, epoch uint64) tea.Cmd

LoadPreview creates a command to load file content.

func LoadPreviewFile

func LoadPreviewFile(file *os.File, path string, epoch uint64) tea.Cmd

LoadPreviewFile reads an already-open regular file and takes ownership of it.

Types

type PreviewLoadedMsg

type PreviewLoadedMsg struct {
	Epoch              uint64
	NavigateGeneration uint64
	Result             PreviewResult
	Path               string
}

PreviewLoadedMsg signals that file preview content is ready.

func (PreviewLoadedMsg) GetEpoch

func (m PreviewLoadedMsg) GetEpoch() uint64

GetEpoch implements plugin.EpochMessage.

type PreviewResult

type PreviewResult struct {
	Content          string
	Lines            []string
	HighlightedLines []string
	IsBinary         bool
	IsImage          bool
	IsTruncated      bool
	TotalSize        int64
	ModTime          time.Time
	Mode             os.FileMode
	Error            error
}

PreviewResult contains the loaded file content.

Jump to

Keyboard shortcuts

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