Documentation ¶
Index ¶
- Constants
- Variables
- type Color
- type Item
- type KeyValueItem
- func (v *KeyValueItem) ForceInline()
- func (v *KeyValueItem) GetKey() Item
- func (v *KeyValueItem) GetValue() Item
- func (v *KeyValueItem) Height() int
- func (v *KeyValueItem) IsInline() bool
- func (v *KeyValueItem) String() string
- func (v *KeyValueItem) WriteItem(w io.Writer, cur int, p *Printer) (int, error)
- type Printer
- func (p *Printer) Depth() int
- func (p *Printer) GetColor(t Color) *color.Color
- func (p *Printer) GetScreenWidth() int
- func (p *Printer) HaveVisited(v rt.Value) bool
- func (p *Printer) Indent() string
- func (p *Printer) MainThread() *rt.Thread
- func (p *Printer) NewItem(v rt.Value) Item
- func (p *Printer) PopDepth() int
- func (p *Printer) PopIndent() string
- func (p *Printer) PopVisited()
- func (p *Printer) PushDepth() int
- func (p *Printer) PushIndent() string
- func (p *Printer) PushVisited(v rt.Value)
- func (p *Printer) SetColor(enable bool)
- func (p *Printer) SetScreenWidth(w int)
- func (p *Printer) WriteTo(w io.Writer, x Item) (int64, error)
Constants ¶
const ( ColorNone = Color(iota) ColorBold ColorUnderline ColorError ColorNil ColorInt ColorFloat ColorBool ColorString ColorTable ColorClosure ColorThread ColorUserData ColorCircular ColorEmptyItem ColorTruncatedArray ColorUnknown )
The valid colours.
const ( NilItem = nilItem(0) CircularItem = circularItem(0) TrueItem = boolItem(true) FalseItem = boolItem(false) EmptyStringItem = stringItem("") EmptyKeyItem = keyItem("") )
Standard constant values.
const ErrRetryNoInline = printerError(0)
ErrRetryNoInline indicates that printing failed because an object was printed inline and failed to fit. This is a temporary error: printing should be retried until no more ErrRetryNoInline are returned.
Variables ¶
var NoColor = color.New()
NoColor is the default lack of a color returned by getColor. Treat this value as a constant.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item interface { fmt.Stringer // IsInline returns true iff the item will be printed inline. IsInline() bool // ForceInline forces the item to be printed inline. ForceInline() // WriteItem writes the item to w, with initial cursor location cur, using the printer p. Returns the new cursor location. WriteItem(w io.Writer, cur int, p *Printer) (int, error) // Height returns the maximum depth of an item in the tree, rooted at the given item. Height() int }
Item is the interface satisfied by an object that can be pretty-printed.
type KeyValueItem ¶
KeyValueItem represents a key-value item for printing.
func (*KeyValueItem) ForceInline ¶
func (v *KeyValueItem) ForceInline()
ForceInline forces the item to be printed inline.
func (*KeyValueItem) GetKey ¶
func (v *KeyValueItem) GetKey() Item
GetKey returns the key for this key-value item, as an item.
func (*KeyValueItem) GetValue ¶
func (v *KeyValueItem) GetValue() Item
GetValue returns the value for this key-value item.
func (*KeyValueItem) Height ¶
func (v *KeyValueItem) Height() int
Height returns the maximum depth of an item in the tree, rooted at the given item.
func (*KeyValueItem) IsInline ¶
func (v *KeyValueItem) IsInline() bool
IsInline returns true iff the item will be printed inline.
func (*KeyValueItem) String ¶
func (v *KeyValueItem) String() string
String returns a string representation of the item.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer provides a way to print values to a io.Writer.
func (*Printer) GetScreenWidth ¶
GetScreenWidth returns the target display width (in characters). This will be used for line-wrapping. A width <= 0 indicates an "infinitely" wide target display.
func (*Printer) HaveVisited ¶
HaveVisited returns true iff the given value is currently in the visited stack.
func (*Printer) MainThread ¶
MainThread returns the main thread in the runtime.
func (*Printer) PopVisited ¶
func (p *Printer) PopVisited()
PopVisited pops a value off the visited stack.
func (*Printer) PushDepth ¶
PushDepth increases the recursion depth. Every call to PushDepth should be balanced by a call to PopDepth. Returns the new depth.
func (*Printer) PushIndent ¶
PushIndent increases the indentation depth. Every call to PushIndent should be balanced by a call to PopIndent. Returns the new indent.
func (*Printer) PushVisited ¶
PushVisited pushes the value onto the visited stack. Every call to PushVisited should be balanced by a call to PopVisited.
func (*Printer) SetScreenWidth ¶
SetScreenWidth sets the target display width (in characters). This will be used for line-wrapping. A width <= 0 indicates an :infinitely" wide target display.