vfmt

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

README

custom fmt utils

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Reset     = []byte("\x1b[0m")
	ResetFG   = []byte("\033[0;00m")
	Bold      = []byte("\x1b[1m")
	Dim       = []byte("\x1b[2m")
	Italic    = []byte("\x1b[3m")
	Underline = []byte("\x1b[4m")
	Blink     = []byte("\x1b[5m")
	Reverse   = []byte("\x1b[7m")
	Hidden    = []byte("\x1b[8m")
)
View Source
var ResetAll = "\x1b[0m"

Functions

func APrintln

func APrintln(v ...interface{}) (int, error)

func Block

func Block(widthSize int, bg, fg, in string) (r string)

func Parse

func Parse(data string, ctags ...string) string

func ParseAsync

func ParseAsync(data string, ctags ...string) (result chan string, err error)

func Print

func Print(v ...interface{}) (int, error)

func Printf

func Printf(format string, v ...interface{}) (int, error)

func Println

func Println(v ...interface{}) (int, error)

func Sprintf

func Sprintf(format string, v ...interface{}) string

Types

type FormatSymbol

type FormatSymbol uint8
const (
	ResetSymbol FormatSymbol = iota
	DimSymbol
	ResetFGSymbol
	ResetBGSymbol
	BoldSymbol
	UnderlineSymbol
	ItalicSymbol
	ReverseSymbol
	StrikeOutSymbol
	NewlineSymbol
	ColorSymbol
	BGColorSymbol
	StyleSymbol
	BlinkSymbol
	HiddenSymbol
	ClearLineSymbol
	MovedownSymbol
	MoveupSymbol
	ListOrderedSymbol
	ListUnorderedSymbol
	ListItemSymbol
)

type Formatter

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

func (*Formatter) Exec

func (*Formatter) Exec(in, lt, rt string, d map[string]any) string

func (*Formatter) Output

func (c *Formatter) Output() []byte

func (*Formatter) Parse

func (c *Formatter) Parse(in string) string

func (*Formatter) Print

func (c *Formatter) Print(v ...any) (int, error)

func (*Formatter) Printf

func (c *Formatter) Printf(f string, v ...any) (int, error)

func (*Formatter) Println

func (c *Formatter) Println(v ...any) (int, error)

func (*Formatter) Reset

func (c *Formatter) Reset()

func (*Formatter) Sprint

func (c *Formatter) Sprint(v ...any) string

func (*Formatter) Sprintf

func (c *Formatter) Sprintf(f string, v ...any) string

type IFormatter

type IFormatter interface {
	Init() error
	GetSymbols() SymbolsMap
	IsSymbolOf(string) (FormatSymbol, bool)
}

type Screen

type Screen struct {
	Width  int
	Height int
	// contains filtered or unexported fields
}

func NewScreen

func NewScreen(width, height int, fgColor, bgColor []byte) *Screen

func (*Screen) Clear

func (c *Screen) Clear()

func (*Screen) Init

func (c *Screen) Init()

func (*Screen) MoveDown

func (c *Screen) MoveDown()

func (*Screen) MoveUp

func (c *Screen) MoveUp()

func (*Screen) Write

func (c *Screen) Write(str string, startPos ...int) (int, error)

type SymValue

type SymValue struct {
	Sym   FormatSymbol
	Value []byte
}

type SymbolsMap

type SymbolsMap map[FormatSymbol]string

func (SymbolsMap) GetValueOf

func (s SymbolsMap) GetValueOf(sym FormatSymbol) (result any, ok bool)

type TagFunc

type TagFunc = func(w io.Writer, tag string) (int, error)

type Writer

type Writer struct {
	io.Writer
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(format string, t ...string) *Writer

func (*Writer) HTML

func (w *Writer) HTML(input string) (r string)

func (*Writer) SetFormat

func (w *Writer) SetFormat(format string)

func (*Writer) SetStyle

func (w *Writer) SetStyle(clsName, style string)

func (*Writer) Write

func (w *Writer) Write(data []byte) (n int, err error)

Jump to

Keyboard shortcuts

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