prettyprint

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DEFAULT_DARKMODE_PRINT_COLORS = PrettyPrintColors{
		ControlKeyword:    GetFullColorSequence(termenv.ANSIBrightMagenta, false),
		OtherKeyword:      GetFullColorSequence(termenv.ANSIBlue, false),
		PatternLiteral:    GetFullColorSequence(termenv.ANSIRed, false),
		StringLiteral:     GetFullColorSequence(termenv.ANSI256Color(209), false),
		PathLiteral:       GetFullColorSequence(termenv.ANSI256Color(209), false),
		IdentifierLiteral: GetFullColorSequence(termenv.ANSIBrightCyan, false),
		NumberLiteral:     GetFullColorSequence(termenv.ANSIBrightGreen, false),
		Constant:          GetFullColorSequence(termenv.ANSIBlue, false),
		PatternIdentifier: GetFullColorSequence(termenv.ANSIBrightGreen, false),
		CssTypeSelector:   GetFullColorSequence(termenv.ANSIBlack, false),
		CssOtherSelector:  GetFullColorSequence(termenv.ANSIYellow, false),
		XmlTagName:        GetFullColorSequence(termenv.ANSIBlue, false),
		InvalidNode:       GetFullColorSequence(termenv.ANSIBrightRed, false),
		DiscreteColor:     GetFullColorSequence(termenv.ANSIBrightBlack, false),

		Folder:     GetFullColorSequence(termenv.ANSIBlue, false),
		Executable: GetFullColorSequence(termenv.ANSIBrightGreen, false),

		SuccessColor: GetFullColorSequence(termenv.ANSIBrightGreen, false),
		WarnColor:    GetFullColorSequence(termenv.ANSIYellow, false),
		ErrorColor:   GetFullColorSequence(termenv.ANSIRed, false),
	}

	DEFAULT_LIGHTMODE_PRINT_COLORS = PrettyPrintColors{
		ControlKeyword:    GetFullColorSequence(termenv.ANSI256Color(90), false),
		OtherKeyword:      GetFullColorSequence(termenv.ANSI256Color(26), false),
		PatternLiteral:    GetFullColorSequence(termenv.ANSI256Color(1), false),
		StringLiteral:     GetFullColorSequence(termenv.ANSI256Color(88), false),
		PathLiteral:       GetFullColorSequence(termenv.ANSI256Color(88), false),
		IdentifierLiteral: GetFullColorSequence(termenv.ANSI256Color(27), false),
		NumberLiteral:     GetFullColorSequence(termenv.ANSI256Color(28), false),
		Constant:          GetFullColorSequence(termenv.ANSI256Color(21), false),
		PatternIdentifier: GetFullColorSequence(termenv.ANSI256Color(28), false),
		CssTypeSelector:   GetFullColorSequence(termenv.ANSIBlack, false),
		CssOtherSelector:  GetFullColorSequence(termenv.ANSIYellow, false),
		XmlTagName:        GetFullColorSequence(termenv.ANSIBlue, false),
		InvalidNode:       GetFullColorSequence(termenv.ANSI256Color(160), false),
		DiscreteColor:     GetFullColorSequence(termenv.ANSIBrightBlack, false),

		Folder:     GetFullColorSequence(termenv.ANSI256Color(26), false),
		Executable: GetFullColorSequence(termenv.ANSI256Color(28), false),

		SuccessColor: GetFullColorSequence(termenv.ANSIBrightGreen, false),
		WarnColor:    GetFullColorSequence(termenv.ANSIYellow, false),
		ErrorColor:   GetFullColorSequence(termenv.ANSIRed, false),
	}
)
View Source
var (
	ANSI_RESET_SEQUENCE = []byte(termenv.CSI + termenv.ResetSeq + "m")

	LF_CR                               = []byte{'\n', '\r'}
	DASH_DASH                           = []byte{'-', '-'}
	SHARP_OPENING_PAREN                 = []byte{'#', '('}
	COLON_SPACE                         = []byte{':', ' '}
	COMMA_SPACE                         = []byte{',', ' '}
	CLOSING_BRACKET_CLOSING_PAREN       = []byte{']', ')'}
	CLOSING_CURLY_BRACKET_CLOSING_PAREN = []byte{'}', ')'}
	THREE_DOTS                          = []byte{'.', '.', '.'}
	DOT_OPENING_CURLY_BRACKET           = []byte{'.', '{'}
)

Functions

func GetFullColorSequence

func GetFullColorSequence(color termenv.Color, bg bool) []byte

Types

type PrettyPrintColors

type PrettyPrintColors struct {
	//inox code
	ControlKeyword, OtherKeyword, PatternLiteral, StringLiteral, PathLiteral, IdentifierLiteral,
	NumberLiteral, Constant, PatternIdentifier, CssTypeSelector, CssOtherSelector, XmlTagName, InvalidNode,

	DiscreteColor, Folder, Executable,
	SuccessColor, WarnColor, ErrorColor []byte
}

type PrettyPrintConfig

type PrettyPrintConfig struct {
	MaxDepth                    int
	Colorize                    bool
	Colors                      *PrettyPrintColors
	Compact                     bool
	Indent                      []byte
	PrintDecodedTopLevelStrings bool
}

type PrettyPrintWriter

type PrettyPrintWriter struct {
	Depth               int
	ParentIndentCount   int
	RemovePercentPrefix bool
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(writer *bufio.Writer, enableRegions bool) PrettyPrintWriter

func (PrettyPrintWriter) AreRegionsDisabled

func (w PrettyPrintWriter) AreRegionsDisabled() bool

func (PrettyPrintWriter) EnterPattern

func (w PrettyPrintWriter) EnterPattern() PrettyPrintWriter

func (PrettyPrintWriter) EnterRegion

func (w PrettyPrintWriter) EnterRegion(kind RegionKind) Region

func (PrettyPrintWriter) IncrDepth

func (w PrettyPrintWriter) IncrDepth() PrettyPrintWriter

func (PrettyPrintWriter) IncrDepthWithIndent

func (w PrettyPrintWriter) IncrDepthWithIndent(indentCount int) PrettyPrintWriter

func (PrettyPrintWriter) LeaveRegion

func (w PrettyPrintWriter) LeaveRegion(region Region)

func (*PrettyPrintWriter) Regions

func (w *PrettyPrintWriter) Regions() []Region

GetRegions returns the list of regions, this functions should be called after all writes.

func (PrettyPrintWriter) WithDepth

func (w PrettyPrintWriter) WithDepth(depth int) PrettyPrintWriter

func (PrettyPrintWriter) WithDepthIndent

func (w PrettyPrintWriter) WithDepthIndent(depth, indent int) PrettyPrintWriter

func (PrettyPrintWriter) WriteAnsiReset

func (w PrettyPrintWriter) WriteAnsiReset()

func (PrettyPrintWriter) WriteByte

func (w PrettyPrintWriter) WriteByte(b byte)

func (PrettyPrintWriter) WriteBytes

func (w PrettyPrintWriter) WriteBytes(b []byte)

func (PrettyPrintWriter) WriteClosingBracketClosingParen

func (w PrettyPrintWriter) WriteClosingBracketClosingParen()

func (PrettyPrintWriter) WriteClosingbracketClosingParen

func (w PrettyPrintWriter) WriteClosingbracketClosingParen()

func (PrettyPrintWriter) WriteColonSpace

func (w PrettyPrintWriter) WriteColonSpace()

func (PrettyPrintWriter) WriteCommaSpace

func (w PrettyPrintWriter) WriteCommaSpace()

func (PrettyPrintWriter) WriteDotOpeningCurlyBracket

func (w PrettyPrintWriter) WriteDotOpeningCurlyBracket()

func (PrettyPrintWriter) WriteLFCR

func (w PrettyPrintWriter) WriteLFCR()

func (PrettyPrintWriter) WriteManyBytes

func (w PrettyPrintWriter) WriteManyBytes(b ...[]byte)

func (PrettyPrintWriter) WriteName

func (w PrettyPrintWriter) WriteName(str string)

func (PrettyPrintWriter) WriteNameF

func (w PrettyPrintWriter) WriteNameF(fmtStr string, args ...any)

func (PrettyPrintWriter) WriteString

func (w PrettyPrintWriter) WriteString(str string)

func (PrettyPrintWriter) WriteStringF

func (w PrettyPrintWriter) WriteStringF(fmtStr string, args ...any)

func (PrettyPrintWriter) ZeroDepth

func (w PrettyPrintWriter) ZeroDepth() PrettyPrintWriter

func (PrettyPrintWriter) ZeroDepthIndent

func (w PrettyPrintWriter) ZeroDepthIndent() PrettyPrintWriter

func (PrettyPrintWriter) ZeroIndent

func (w PrettyPrintWriter) ZeroIndent() PrettyPrintWriter

type Region

type Region struct {
	Kind  RegionKind
	Depth uint8
	Start uint16
	End   uint16
}

func (Region) SubString

func (r Region) SubString(s string) string

type RegionFilter

type RegionFilter struct {
	ExactDepth   int
	MinimumDepth int        //ignored if ExactDepth is set
	Kind         RegionKind //ignored if zero
}

type RegionKind

type RegionKind uint8
const (
	ParamNameTypeRegion RegionKind = iota + 1
)

type Regions

type Regions []Region

func (Regions) FilteredForEach

func (rs Regions) FilteredForEach(filter RegionFilter, fn func(r Region) error) error

Jump to

Keyboard shortcuts

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