sgr

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsertFormatting

func InsertFormatting(text string, spans ...*Span) string

Insert formatting into text at the specified offsets, overriding any existing formatting, and restoring existing formatting after the replaced sections.

Types

type BoolVal

type BoolVal struct{ Is_set, Val bool }

func (*BoolVal) AsCSI

func (self *BoolVal) AsCSI(set, reset string) string

func (*BoolVal) Set

func (self *BoolVal) Set(val bool)

type Color

type Color struct {
	Red, Green, Blue uint8
	Is_numbered      bool
}

func (Color) AsCSI

func (self Color) AsCSI(base int) string

func (*Color) FromExtended

func (self *Color) FromExtended(nums ...int) bool

func (*Color) FromNumber

func (self *Color) FromNumber(n uint8)

func (*Color) Set

func (self *Color) Set(val any) (err error)

type ColorVal

type ColorVal struct {
	Is_set, Is_default bool
	Val                Color
}

func (*ColorVal) AsCSI

func (self *ColorVal) AsCSI(base int) string

func (*ColorVal) Set

func (self *ColorVal) Set(val any)

type SGR

type SGR struct {
	Italic, Reverse, Bold, Dim, Strikethrough BoolVal
	Underline_style                           UnderlineStyleVal
	Foreground, Background, Underline_color   ColorVal
}

func SGRFromCSI

func SGRFromCSI(csi string) (ans SGR)

func (*SGR) ApplyMask

func (self *SGR) ApplyMask(other SGR)

func (*SGR) ApplySGR

func (self *SGR) ApplySGR(other SGR)

func (*SGR) AsCSI

func (self *SGR) AsCSI() string

func (*SGR) IsEmpty

func (self *SGR) IsEmpty() bool

type Span

type Span struct {
	Offset, Size int // in bytes
	// contains filtered or unexported fields
}

func NewSpan

func NewSpan(offset, size int) *Span

func (*Span) SetBackground

func (self *Span) SetBackground(val any) *Span

func (*Span) SetBold

func (self *Span) SetBold(val bool) *Span

func (*Span) SetClosingBackground

func (self *Span) SetClosingBackground(val any) *Span

func (*Span) SetClosingBold

func (self *Span) SetClosingBold(val bool) *Span

func (*Span) SetClosingDim

func (self *Span) SetClosingDim(val bool) *Span

func (*Span) SetClosingForeground

func (self *Span) SetClosingForeground(val any) *Span

func (*Span) SetClosingItalic

func (self *Span) SetClosingItalic(val bool) *Span

func (*Span) SetClosingReverse

func (self *Span) SetClosingReverse(val bool) *Span

func (*Span) SetClosingStrikethrough

func (self *Span) SetClosingStrikethrough(val bool) *Span

func (*Span) SetClosingUnderlineColor

func (self *Span) SetClosingUnderlineColor(val any) *Span

func (*Span) SetClosingUnderlineStyle

func (self *Span) SetClosingUnderlineStyle(val UnderlineStyle) *Span

func (*Span) SetDim

func (self *Span) SetDim(val bool) *Span

func (*Span) SetForeground

func (self *Span) SetForeground(val any) *Span

func (*Span) SetItalic

func (self *Span) SetItalic(val bool) *Span

func (*Span) SetReverse

func (self *Span) SetReverse(val bool) *Span

func (*Span) SetStrikethrough

func (self *Span) SetStrikethrough(val bool) *Span

func (*Span) SetUnderlineColor

func (self *Span) SetUnderlineColor(val any) *Span

func (*Span) SetUnderlineStyle

func (self *Span) SetUnderlineStyle(val UnderlineStyle) *Span

type UnderlineStyle

type UnderlineStyle uint8
const (
	No_underline UnderlineStyle = iota
	Straight_underline
	Double_underline
	Curly_underline
	Dotted_underline
	Dashed_underline
)

type UnderlineStyleVal

type UnderlineStyleVal struct {
	Is_set bool
	Val    UnderlineStyle
}

func (*UnderlineStyleVal) AsCSI

func (self *UnderlineStyleVal) AsCSI() string

Jump to

Keyboard shortcuts

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