Documentation
¶
Index ¶
Constants ¶
const MaxRows = 4
MaxRows is the maximum number of terminal rows an image may span.
Variables ¶
var (
BaseImageDirectory = filepath.Join(xdg.DataHome, "chatuino")
)
var ErrUnsupportedAnimatedFormat = errors.New("emote is animated but in non supported format")
Functions ¶
func PlaceholderID ¶ added in v1.5.0
PlaceholderID returns the image ID encoded in the first placeholder of text.
func PlaceholderRowsAbove ¶ added in v1.4.0
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 CellSize ¶ added in v1.5.0
type CellSize struct {
Width, Height float32
}
CellSize is the terminal cell size in pixels. Kept together because every image geometry calculation needs both dimensions.
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) PrepareCommand ¶
func (i DecodedImage) PrepareCommand() string
type DecodedImageFrame ¶
type DisplayManager ¶
type DisplayManager struct {
// contains filtered or unexported fields
}
func NewDisplayManager ¶
func NewDisplayManager(fs afero.Fs, cell CellSize, 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)
func (*DisplayManager) RefreshCellSize ¶ added in v1.5.0
func (d *DisplayManager) RefreshCellSize()
RefreshCellSize re-reads the terminal cell size. Images that are converted afterwards use the new size; images already placed in this session keep their geometry, because their placeholder cells and placement are already in the rendered chat and cannot be re-laid-out.
type DisplayOptions ¶ added in v1.4.0
type DisplayOptions struct {
Rows int // terminal rows an image spans, clamped to [1, MaxRows]
// Passthrough wraps every kitty command for tmux's allow-passthrough mode.
Passthrough bool
// CellSize, when set, re-reads the terminal cell size on RefreshCellSize so
// images converted after a resize or font change keep their aspect ratio.
CellSize func() (CellSize, error)
}
DisplayOptions configures how images are displayed.
type DisplayUnit ¶
type KittyDisplayUnit ¶
type PlaceholderSpan ¶ added in v1.5.0
type PlaceholderSpan struct {
Col int // first terminal column of the run
Width int // number of cells in the run
ID int32 // image ID encoded in the foreground color
}
PlaceholderSpan is a run of adjacent placeholder cells belonging to one image.
func PlaceholderSpans ¶ added in v1.5.0
func PlaceholderSpans(line string) []PlaceholderSpan
PlaceholderSpans returns the image placeholder runs in a rendered line, with their terminal columns. Returns nil when line contains no placeholders.