kittyimg

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 32 Imported by: 1 module, 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

Index

Constants

View Source
const MaxRows = 4

MaxRows is the maximum number of terminal rows an image may span.

Variables

View Source
var (
	BaseImageDirectory = filepath.Join(xdg.DataHome, "chatuino")
)
View Source
var ErrUnsupportedAnimatedFormat = errors.New("emote is animated but in non supported format")

Functions

func PlaceholderRowsAbove added in v1.4.0

func PlaceholderRowsAbove(line string, rows int) []string

PlaceholderRowsAbove returns the rows-1 terminal lines that must be rendered above line, so multi-row images in line (which contains their bottom row) are displayed in full. Every placeholder cell in line is repeated at the same column with the matching row diacritic; all other cells become spaces. Returns nil if rows <= 1 or line contains no placeholders.

Types

type DecodedImage

type DecodedImage struct {
	ID     int32               `json:"-"`
	Cols   int                 `json:"cols"`
	Images []DecodedImageFrame `json:"images"`

	// Rows is the number of terminal rows the image spans. Not persisted, since it
	// depends on the current settings and is applied when the image is loaded.
	Rows int `json:"-"`
	// contains filtered or unexported fields
}

func (DecodedImage) DisplayUnicodePlaceholder

func (i DecodedImage) DisplayUnicodePlaceholder() string

DisplayUnicodePlaceholder returns the placeholder text for the last (bottom) row of the image, so the image is bottom aligned with the surrounding text. For multi-row images the rows above are derived via PlaceholderRowsAbove.

func (DecodedImage) MarshalEasyJSON

func (v DecodedImage) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (DecodedImage) PrepareCommand

func (i DecodedImage) PrepareCommand() string

func (*DecodedImage) UnmarshalEasyJSON

func (v *DecodedImage) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type DecodedImageFrame

type DecodedImageFrame struct {
	Width       int    `json:"width"`
	Height      int    `json:"height"`
	EncodedPath string `json:"encoded_path"`
	DelayInMS   int    `json:"delay_in_ms"`
}

func (DecodedImageFrame) MarshalEasyJSON

func (v DecodedImageFrame) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*DecodedImageFrame) UnmarshalEasyJSON

func (v *DecodedImageFrame) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type DisplayManager

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

func NewDisplayManager

func NewDisplayManager(fs afero.Fs, cellWidth, cellHeight float32, opts DisplayOptions) *DisplayManager

NewDisplayManager creates a display manager for a terminal with the given cell size in pixels.

func (*DisplayManager) CleanupAllImagesCommand

func (d *DisplayManager) CleanupAllImagesCommand() string

func (*DisplayManager) CleanupOldImagesCommand

func (d *DisplayManager) CleanupOldImagesCommand(maxAge time.Duration) string

func (*DisplayManager) Convert

func (d *DisplayManager) Convert(unit DisplayUnit) (KittyDisplayUnit, error)

type DisplayOptions added in v1.4.0

type DisplayOptions struct {
	Rows int // terminal rows an image spans, clamped to [1, MaxRows]
}

DisplayOptions configures how images are displayed.

type DisplayUnit

type DisplayUnit struct {
	ID           string
	Directory    string
	IsAnimated   bool
	RightPadding int                                   // pixels of transparent padding to add on right side
	Load         func() (io.ReadCloser, string, error) `json:"-"`
}

type KittyDisplayUnit

type KittyDisplayUnit struct {
	PrepareCommand  string
	ReplacementText string
}

Jump to

Keyboard shortcuts

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