term

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListThemes

func ListThemes() []string

ListThemes returns a list of all available theme names

Types

type Attributes

type Attributes struct {
	Bold          bool
	Italic        bool
	Underline     bool
	Strikethrough bool
	Blink         bool
}

type Cell

type Cell struct {
	Char    rune
	FgColor color.Color
	BgColor color.Color
	Attrs   Attributes
	IsWide  bool // For handling wide characters
}

type TermRenderer

type TermRenderer struct {
	Output []byte
	Style  *TermStyle
	// contains filtered or unexported fields
}

func DefaultRenderer

func DefaultRenderer(input []byte) *TermRenderer

func NewRenderer

func NewRenderer(input []byte, style *TermStyle) *TermRenderer

func (*TermRenderer) Render

func (r *TermRenderer) Render() (image.Image, error)

func (*TermRenderer) WithArgs

func (r *TermRenderer) WithArgs(args []string) *TermRenderer

func (*TermRenderer) WithAutoSize

func (r *TermRenderer) WithAutoSize() *TermRenderer

func (*TermRenderer) WithFont

func (r *TermRenderer) WithFont(font *fonts.Font) *TermRenderer

func (*TermRenderer) WithFontName

func (r *TermRenderer) WithFontName(name string, style *fonts.FontStyle) *TermRenderer

func (*TermRenderer) WithFontSize

func (r *TermRenderer) WithFontSize(size float64) *TermRenderer

func (*TermRenderer) WithHeight

func (r *TermRenderer) WithHeight(height int) *TermRenderer

func (*TermRenderer) WithLineHeight

func (r *TermRenderer) WithLineHeight(height float64) *TermRenderer

func (*TermRenderer) WithPadding

func (r *TermRenderer) WithPadding(left, right, top, bottom int) *TermRenderer

func (*TermRenderer) WithPromptFunc

func (r *TermRenderer) WithPromptFunc(promptFunc func(command string) string) *TermRenderer

func (*TermRenderer) WithShowPrompt

func (r *TermRenderer) WithShowPrompt() *TermRenderer

func (*TermRenderer) WithTerminalSize

func (r *TermRenderer) WithTerminalSize(fd uintptr) *TermRenderer

func (*TermRenderer) WithTheme

func (r *TermRenderer) WithTheme(theme string) *TermRenderer

func (*TermRenderer) WithWidth

func (r *TermRenderer) WithWidth(width int) *TermRenderer

type TermStyle

type TermStyle struct {
	Args          []string                    // Command and arguments
	Theme         string                      // The terminal theme to use
	Font          *fonts.Font                 // The font to use
	FontSize      float64                     // The font size in points
	LineHeight    float64                     // The line height multiplier
	PaddingLeft   int                         // Padding between the code and the left edge
	PaddingRight  int                         // Padding between the code and the right edge
	PaddingTop    int                         // Padding between the code and the top edge
	PaddingBottom int                         // Padding between the code and the bottom edge
	Width         int                         // Terminal width in cells
	Height        int                         // Terminal height in cells
	AutoSize      bool                        // Whether to automatically size the output to the content
	CellSpacing   int                         // Additional horizontal spacing between cells
	ShowPrompt    bool                        // Whether to show a prompt
	PromptFunc    func(command string) string // Template function that returns the prompt text
}

type Terminal

type Terminal struct {
	Cells         [][]Cell
	Width         int
	Height        int
	CursorX       int
	CursorY       int
	CurrAttrs     Attributes
	CurrFg        color.Color
	CurrBg        color.Color
	Style         *Theme // Theme colors from theme
	MaxX          int    // For dynamic sizing
	MaxY          int    // For dynamic sizing
	DefaultFg     color.Color
	DefaultBg     color.Color
	AutoSize      bool // Whether to automatically size the terminal
	PaddingLeft   int
	PaddingRight  int
	PaddingTop    int
	PaddingBottom int
}

func NewTerminal

func NewTerminal(style *TermStyle, theme *Theme) *Terminal

func (*Terminal) NewLine

func (t *Terminal) NewLine()

func (*Terminal) Reset

func (t *Terminal) Reset()

func (*Terminal) Resize

func (t *Terminal) Resize(width, height int)

func (*Terminal) SetCell

func (t *Terminal) SetCell(x, y int, ch rune)

type Theme

type Theme struct {
	Name    string `yaml:"name"`
	Author  string `yaml:"author"`
	Variant string `yaml:"variant"`

	// Standard colors (0-7)
	Color01 string `yaml:"color_01"` // Black
	Color02 string `yaml:"color_02"` // Red
	Color03 string `yaml:"color_03"` // Green
	Color04 string `yaml:"color_04"` // Yellow
	Color05 string `yaml:"color_05"` // Blue
	Color06 string `yaml:"color_06"` // Magenta
	Color07 string `yaml:"color_07"` // Cyan
	Color08 string `yaml:"color_08"` // White

	// Bright colors (8-15)
	Color09 string `yaml:"color_09"` // Bright Black
	Color10 string `yaml:"color_10"` // Bright Red
	Color11 string `yaml:"color_11"` // Bright Green
	Color12 string `yaml:"color_12"` // Bright Yellow
	Color13 string `yaml:"color_13"` // Bright Blue
	Color14 string `yaml:"color_14"` // Bright Magenta
	Color15 string `yaml:"color_15"` // Bright Cyan
	Color16 string `yaml:"color_16"` // Bright White

	// Special colors
	Background string `yaml:"background"`
	Foreground string `yaml:"foreground"`
	Cursor     string `yaml:"cursor"`
}

Theme represents a terminal color theme

func GetTheme

func GetTheme(name string) *Theme

GetTheme returns a theme by name

func (*Theme) GetBackground

func (t *Theme) GetBackground() color.Color

GetBackground returns the theme's background color

func (*Theme) GetColor

func (t *Theme) GetColor(index int) color.Color

GetColor returns the color for the given index (0-15)

func (*Theme) GetCursor

func (t *Theme) GetCursor() color.Color

GetCursor returns the theme's cursor color

func (*Theme) GetForeground

func (t *Theme) GetForeground() color.Color

GetForeground returns the theme's foreground color

Jump to

Keyboard shortcuts

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