term

package
v0.4.0-beta.30 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Continue ExecutionResult = "Continue"
	Skip                     = "Skip"
	Stop                     = "Stop"
)

Variables

View Source
var BlockquoteAttributeFilter = GlobalAttributeFilter.Extend(
	[]byte("cite"),
)

BlockquoteAttributeFilter defines attribute names which blockquote elements can have

View Source
var CodeAttributeFilter = GlobalAttributeFilter

CodeAttributeFilter defines attribute names which code elements can have.

View Source
var ColorsEnabled bool
View Source
var ConsoleRenderer = &consoleRendererExt{}

Strikethrough is an extension that allow you to use invisibleBlock expression like '~~text~~' .

View Source
var DefaultWriter = &defaultWriter{}

DefaultWriter is a default implementation of the Writer.

View Source
var EmphasisAttributeFilter = GlobalAttributeFilter

EmphasisAttributeFilter defines attribute names which emphasis elements can have.

View Source
var GlobalAttributeFilter = util.NewBytesFilter(
	[]byte("accesskey"),
	[]byte("autocapitalize"),
	[]byte("class"),
	[]byte("contenteditable"),
	[]byte("contextmenu"),
	[]byte("dir"),
	[]byte("draggable"),
	[]byte("dropzone"),
	[]byte("hidden"),
	[]byte("id"),
	[]byte("itemprop"),
	[]byte("lang"),
	[]byte("slot"),
	[]byte("spellcheck"),
	[]byte("style"),
	[]byte("tabindex"),
	[]byte("title"),
	[]byte("translate"),
)

GlobalAttributeFilter defines attribute names which any elements can have.

View Source
var HeadingAttributeFilter = GlobalAttributeFilter

HeadingAttributeFilter defines attribute names which heading elements can have

View Source
var ImageAttributeFilter = GlobalAttributeFilter.Extend(
	[]byte("align"),
	[]byte("border"),
	[]byte("crossorigin"),
	[]byte("decoding"),
	[]byte("height"),
	[]byte("importance"),
	[]byte("intrinsicsize"),
	[]byte("ismap"),
	[]byte("loading"),
	[]byte("referrerpolicy"),
	[]byte("sizes"),
	[]byte("srcset"),
	[]byte("usemap"),
	[]byte("width"),
)

ImageAttributeFilter defines attribute names which image elements can have.

View Source
var LinkAttributeFilter = GlobalAttributeFilter.Extend(
	[]byte("download"),

	[]byte("hreflang"),
	[]byte("media"),
	[]byte("ping"),
	[]byte("referrerpolicy"),
	[]byte("rel"),
	[]byte("shape"),
	[]byte("target"),
)

LinkAttributeFilter defines attribute names which link elements can have.

View Source
var ListAttributeFilter = GlobalAttributeFilter.Extend(
	[]byte("start"),
	[]byte("reversed"),
)

ListAttributeFilter defines attribute names which list elements can have.

View Source
var ListItemAttributeFilter = GlobalAttributeFilter.Extend(
	[]byte("value"),
)

ListItemAttributeFilter defines attribute names which list item elements can have.

View Source
var NewSpinnerFunc func(w io.Writer) Spinner = nil
View Source
var ParagraphAttributeFilter = GlobalAttributeFilter

ParagraphAttributeFilter defines attribute names which paragraph elements can have.

View Source
var ThematicAttributeFilter = GlobalAttributeFilter.Extend(
	[]byte("align"),
	[]byte("color"),
	[]byte("noshade"),
	[]byte("size"),
	[]byte("width"),
)

ThematicAttributeFilter defines attribute names which hr elements can have.

Functions

func HandleCommands

func HandleCommands(spinner Spinner, context *renderer.Context) func(s string)

func NewRenderer

func NewRenderer(context *rundown_renderer.Context, opts ...Option) renderer.NodeRenderer

NewRenderer returns a new Renderer with given options.

func RenderAttributes

func RenderAttributes(w util.BufWriter, node ast.Node, filter util.BytesFilter)

RenderAttributes renders given node's attributes. You can specify attribute names to render by the filter. If filter is nil, RenderAttributes renders all attributes.

func WithConsoleWidth

func WithConsoleWidth(width int) interface {
	renderer.Option
	Option
}

The mutator is responsible for changing the inside of a RundownInline block before it's written to the output, but after it's been rendered.

func WithLevel

func WithLevel(level int) interface {
	renderer.Option
	Option
}

The mutator is responsible for changing the inside of a RundownInline block before it's written to the output, but after it's been rendered.

func WithLevelChange

func WithLevelChange(changer func(level int)) interface {
	renderer.Option
	Option
}

The mutator is responsible for changing the inside of a RundownInline block before it's written to the output, but after it's been rendered.

func WithRundownHandler

func WithRundownHandler(handler RundownHandler) interface {
	renderer.Option
	Option
}

The mutator is responsible for changing the inside of a RundownInline block before it's written to the output, but after it's been rendered.

Types

type AnsiScreenWriter

type AnsiScreenWriter struct {
	CommandHandler func(string)
	// contains filtered or unexported fields
}

Writes terminal output to the screen, while allowing for per-line alterations.

func NewAnsiScreenWriter

func NewAnsiScreenWriter(writer io.Writer) *AnsiScreenWriter

func (*AnsiScreenWriter) AfterFlush

func (f *AnsiScreenWriter) AfterFlush(cb func())

func (*AnsiScreenWriter) BeforeFlush

func (f *AnsiScreenWriter) BeforeFlush(cb func())

func (*AnsiScreenWriter) CHA

func (f *AnsiScreenWriter) CHA(pos int) error

Cursor Horizontal position Absolute

func (*AnsiScreenWriter) CNL

func (f *AnsiScreenWriter) CNL(count int) error

Cursor to Next Line

func (*AnsiScreenWriter) CPL

func (f *AnsiScreenWriter) CPL(count int) error

Cursor to Previous Line

func (*AnsiScreenWriter) CUB

func (f *AnsiScreenWriter) CUB(count int) error

Cursor Backward

func (*AnsiScreenWriter) CUD

func (f *AnsiScreenWriter) CUD(count int) error

CUrsor Down

func (*AnsiScreenWriter) CUF

func (f *AnsiScreenWriter) CUF(count int) error

Cursor Forward

func (*AnsiScreenWriter) CUP

func (f *AnsiScreenWriter) CUP(x int, y int) error

CUrsor Position

func (*AnsiScreenWriter) CUU

func (f *AnsiScreenWriter) CUU(count int) error

Cursor Up

func (*AnsiScreenWriter) DA

func (f *AnsiScreenWriter) DA(values []string) error

Device Attributes

func (*AnsiScreenWriter) DCH

func (f *AnsiScreenWriter) DCH(count int) error

Delete Character

func (*AnsiScreenWriter) DECCOLM

func (f *AnsiScreenWriter) DECCOLM(enable bool) error

132 Column Mode

func (*AnsiScreenWriter) DECOM

func (f *AnsiScreenWriter) DECOM(enable bool) error

Origin Mode

func (*AnsiScreenWriter) DECSTBM

func (f *AnsiScreenWriter) DECSTBM(x, y int) error

Set Top and Bottom Margins

func (*AnsiScreenWriter) DECTCEM

func (f *AnsiScreenWriter) DECTCEM(enable bool) error

Text Cursor Enable Mode

func (*AnsiScreenWriter) DL

func (f *AnsiScreenWriter) DL(count int) error

Delete Line

func (*AnsiScreenWriter) ED

func (f *AnsiScreenWriter) ED(count int) error

Erase in Display

func (*AnsiScreenWriter) EL

func (f *AnsiScreenWriter) EL(count int) error

Erase in Line

func (*AnsiScreenWriter) Execute

func (f *AnsiScreenWriter) Execute(b byte) error

Execute C0 commands

func (*AnsiScreenWriter) Flush

func (f *AnsiScreenWriter) Flush() error

Flush updates from previous commands

func (*AnsiScreenWriter) HVP

func (f *AnsiScreenWriter) HVP(x int, y int) error

Horizontal and Vertical Position (depends on PUM)

func (*AnsiScreenWriter) ICH

func (f *AnsiScreenWriter) ICH(count int) error

Insert Character

func (*AnsiScreenWriter) IL

func (f *AnsiScreenWriter) IL(count int) error

Insert Line

func (*AnsiScreenWriter) IND

func (f *AnsiScreenWriter) IND() error

Index

func (*AnsiScreenWriter) OSC

func (f *AnsiScreenWriter) OSC(b []byte) error

func (*AnsiScreenWriter) PrefixEachLine

func (f *AnsiScreenWriter) PrefixEachLine(prefix string)

func (*AnsiScreenWriter) Print

func (f *AnsiScreenWriter) Print(b byte) error

Print

func (*AnsiScreenWriter) Process

func (f *AnsiScreenWriter) Process()

func (*AnsiScreenWriter) RI

func (f *AnsiScreenWriter) RI() error

Reverse Index

func (*AnsiScreenWriter) SD

func (f *AnsiScreenWriter) SD(count int) error

Pan Up

func (*AnsiScreenWriter) SGR

func (f *AnsiScreenWriter) SGR(values []int) error

Set Graphics Rendition

func (*AnsiScreenWriter) SU

func (f *AnsiScreenWriter) SU(count int) error

Pan Down

func (*AnsiScreenWriter) VPA

func (f *AnsiScreenWriter) VPA(pos int) error

Vertical line Position Absolute

func (*AnsiScreenWriter) Write

func (f *AnsiScreenWriter) Write(data []byte) (int, error)

type Buffer

type Buffer interface {
	String() (string, int)
	SubscribeToFlush() chan bool
}

type BulletSequenceStyle

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

func NewBulletSequence

func NewBulletSequence(marker string, level string) BulletSequenceStyle

func (BulletSequenceStyle) Begin

func (s BulletSequenceStyle) Begin() string

func (BulletSequenceStyle) End

func (s BulletSequenceStyle) End() string

func (BulletSequenceStyle) Wrap

func (s BulletSequenceStyle) Wrap(str string) string

type Color

type Color aurora.Color

func (Color) Begin

func (c Color) Begin() string

func (Color) End

func (c Color) End() string

func (Color) Wrap

func (c Color) Wrap(str string) string

type Config

type Config struct {
	TempDir        string
	RundownHandler RundownHandler
	Level          int
	ConsoleWidth   int
	LevelChange    func(level int)
}

A Config struct has configurations for the HTML based renderers.

func NewConfig

func NewConfig() Config

NewConfig returns a new Config with defaults.

func (*Config) SetOption

func (c *Config) SetOption(name renderer.OptionName, value interface{})

SetOption implements renderer.NodeRenderer.SetOption.

type ExecutionResult

type ExecutionResult string

type FlushingWriter

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

func NewFlushingWriter

func NewFlushingWriter(w io.Writer) *FlushingWriter

func (*FlushingWriter) Write

func (f *FlushingWriter) Write(b []byte) (int, error)

type Handler

type Handler func()

type IntegerSequenceStyle

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

func NewIntegerSequence

func NewIntegerSequence(start int, level string) *IntegerSequenceStyle

func (*IntegerSequenceStyle) Begin

func (s *IntegerSequenceStyle) Begin() string

func (*IntegerSequenceStyle) End

func (s *IntegerSequenceStyle) End() string

func (*IntegerSequenceStyle) Wrap

func (s *IntegerSequenceStyle) Wrap(str string) string

type Option

type Option interface {
	SetConsoleOption(*Config)
}

An Option interface sets options for HTML based renderers.

type Renderer

type Renderer struct {
	Config

	Context *rundown_renderer.Context
	// contains filtered or unexported fields
}

A Renderer struct is an implementation of renderer.NodeRenderer that renders nodes as Console strings

func (*Renderer) CurrentLevel

func (r *Renderer) CurrentLevel() int

func (*Renderer) RegisterFuncs

func (r *Renderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)

RegisterFuncs implements NodeRenderer.RegisterFuncs .

func (*Renderer) SetLevel

func (r *Renderer) SetLevel(level int)

func (*Renderer) StartAt

func (r *Renderer) StartAt(node ast.Node)

type RundownHandler

type RundownHandler interface {
	Mutate([]byte, ast.Node) ([]byte, error)
	OnRundownNode(node ast.Node, entering bool) (ast.WalkStatus, error)
	OnExecute(node *rundown_ast.ExecutionBlock, source []byte, out util.BufWriter) (ExecutionResult, error)
}

type ScreenWriter

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

func NewScreenWriter

func NewScreenWriter(writer io.Writer, buffer Buffer) *ScreenWriter

func (*ScreenWriter) Done

func (s *ScreenWriter) Done()

func (*ScreenWriter) Run

func (s *ScreenWriter) Run()

func (*ScreenWriter) SetAfterFunc

func (s *ScreenWriter) SetAfterFunc(handler Handler)

func (*ScreenWriter) SetBeforeFunc

func (s *ScreenWriter) SetBeforeFunc(handler Handler)

func (*ScreenWriter) Write

func (s *ScreenWriter) Write(b []byte) (int, error)

type Spinner

type Spinner interface {
	Active() bool
	Start()
	Stop()
	Success(message string)
	Error(message string)
	Skip(message string)
	SetMessage(message string)
	NewStep(message string)
	HideAndExecute(f func())
	CurrentHeading() string
	StampShadow()
}

type StdoutBuffer

type StdoutBuffer struct {
	LastFlushLines int
	// contains filtered or unexported fields
}

Buffers an output stream. Consecutive flushes should reposition cursor to the original cursor point.

func NewStdoutBuffer

func NewStdoutBuffer() *StdoutBuffer

func (*StdoutBuffer) AnythingToFlush

func (f *StdoutBuffer) AnythingToFlush() bool

func (*StdoutBuffer) CHA

func (f *StdoutBuffer) CHA(pos int) error

Cursor Horizontal position Absolute

func (*StdoutBuffer) CNL

func (f *StdoutBuffer) CNL(count int) error

Cursor to Next Line

func (*StdoutBuffer) CPL

func (f *StdoutBuffer) CPL(count int) error

Cursor to Previous Line

func (*StdoutBuffer) CUB

func (f *StdoutBuffer) CUB(count int) error

Cursor Backward

func (*StdoutBuffer) CUD

func (f *StdoutBuffer) CUD(count int) error

CUrsor Down

func (*StdoutBuffer) CUF

func (f *StdoutBuffer) CUF(count int) error

Cursor Forward

func (*StdoutBuffer) CUP

func (f *StdoutBuffer) CUP(x int, y int) error

CUrsor Position

func (*StdoutBuffer) CUU

func (f *StdoutBuffer) CUU(count int) error

Cursor Up

func (*StdoutBuffer) DA

func (f *StdoutBuffer) DA(values []string) error

Device Attributes

func (*StdoutBuffer) DCH

func (f *StdoutBuffer) DCH(count int) error

Delete Character

func (*StdoutBuffer) DECCOLM

func (f *StdoutBuffer) DECCOLM(enable bool) error

132 Column Mode

func (*StdoutBuffer) DECOM

func (f *StdoutBuffer) DECOM(enable bool) error

Origin Mode

func (*StdoutBuffer) DECSTBM

func (f *StdoutBuffer) DECSTBM(x, y int) error

Set Top and Bottom Margins

func (*StdoutBuffer) DECTCEM

func (f *StdoutBuffer) DECTCEM(enable bool) error

Text Cursor Enable Mode

func (*StdoutBuffer) DL

func (f *StdoutBuffer) DL(count int) error

Delete Line

func (*StdoutBuffer) ED

func (f *StdoutBuffer) ED(count int) error

Erase in Display

func (*StdoutBuffer) EL

func (f *StdoutBuffer) EL(count int) error

Erase in Line

func (*StdoutBuffer) Execute

func (f *StdoutBuffer) Execute(b byte) error

Execute C0 commands

func (*StdoutBuffer) Flush

func (f *StdoutBuffer) Flush() error

Flush updates from previous commands

func (*StdoutBuffer) HVP

func (f *StdoutBuffer) HVP(x int, y int) error

Horizontal and Vertical Position (depends on PUM)

func (*StdoutBuffer) ICH

func (f *StdoutBuffer) ICH(count int) error

Insert Character

func (*StdoutBuffer) IL

func (f *StdoutBuffer) IL(count int) error

Insert Line

func (*StdoutBuffer) IND

func (f *StdoutBuffer) IND() error

Index

func (*StdoutBuffer) OSC

func (f *StdoutBuffer) OSC([]byte) error

func (*StdoutBuffer) Print

func (f *StdoutBuffer) Print(b byte) error

Print

func (*StdoutBuffer) Process

func (f *StdoutBuffer) Process(inStream io.Reader)

func (*StdoutBuffer) RI

func (f *StdoutBuffer) RI() error

Reverse Index

func (*StdoutBuffer) SD

func (f *StdoutBuffer) SD(count int) error

Pan Up

func (*StdoutBuffer) SGR

func (f *StdoutBuffer) SGR(values []int) error

Set Graphics Rendition

func (*StdoutBuffer) SU

func (f *StdoutBuffer) SU(count int) error

Pan Down

func (*StdoutBuffer) String

func (f *StdoutBuffer) String() string

func (*StdoutBuffer) SubscribeToFlush

func (f *StdoutBuffer) SubscribeToFlush() chan bool

func (*StdoutBuffer) VPA

func (f *StdoutBuffer) VPA(pos int) error

Vertical line Position Absolute

func (*StdoutBuffer) Write

func (f *StdoutBuffer) Write(data []byte) (int, error)

type Style

type Style interface {
	Wrap(str string) string
	Begin() string
	End() string
}

type StyleStack

type StyleStack struct {
	Styles []Style
}

func NewStyleStack

func NewStyleStack() *StyleStack

func (*StyleStack) Peek

func (s *StyleStack) Peek() Style

func (*StyleStack) Pop

func (s *StyleStack) Pop() Style

func (*StyleStack) Push

func (s *StyleStack) Push(style Style) Style

type Writer

type Writer interface {
	// Write writes the given source to writer with resolving references and unescaping
	// backslash escaped characters.
	Write(writer util.BufWriter, source []byte)

	// RawWrite writes the given source to writer without resolving references and
	// unescaping backslash escaped characters.
	RawWrite(writer util.BufWriter, source []byte)
}

A Writer interface writes textual contents to a writer.

Directories

Path Synopsis
Package spinner is a simple package to add a spinner / progress indicator to any terminal application.
Package spinner is a simple package to add a spinner / progress indicator to any terminal application.

Jump to

Keyboard shortcuts

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