format

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderImage added in v0.2.0

func RenderImage(data []byte, maxWidth, maxHeight int) (string, int, error)

RenderImage renders image data using the best available terminal protocol. Returns the rendered string and the number of lines.

func RenderImageHalfBlock

func RenderImageHalfBlock(data []byte, maxWidth, maxHeight int) (string, int, error)

RenderImageHalfBlock renders image data as half-block characters for terminal display. Uses U+2584 (Lower Half Block): top pixel = background color, bottom pixel = foreground color. Returns the rendered string and the number of lines.

func RenderStyledText

func RenderStyledText(text string, entities []tg.MessageEntityClass) string

RenderStyledText applies Telegram entity formatting to message text, returning a styled string suitable for terminal display. Newlines are replaced with spaces so each message occupies one visual line.

func RenderStyledTextMultiline

func RenderStyledTextMultiline(text string, entities []tg.MessageEntityClass, width int) string

RenderStyledTextMultiline applies Telegram entity formatting and preserves newlines. Long lines are word-wrapped to the given width (ANSI-aware).

Types

type ImageProtocol added in v0.2.0

type ImageProtocol int

ImageProtocol represents the best available image rendering protocol.

const (
	ProtoHalfBlock ImageProtocol = iota // Universal fallback
	ProtoKitty                          // Kitty graphics protocol
	ProtoIterm                          // iTerm2 inline images
	ProtoSixel                          // Sixel graphics
)

func DetectImageProtocol added in v0.2.0

func DetectImageProtocol() ImageProtocol

DetectImageProtocol returns the best image protocol available in the current terminal.

Jump to

Keyboard shortcuts

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