Documentation
¶
Index ¶
- Variables
- type Axis
- func (a *Axis) CalcWidth() int
- func (a *Axis) Draw(screen tcell.Screen)
- func (a *Axis) Highlight() DecimalValue
- func (a *Axis) HighlightStyle() tcell.Style
- func (a *Axis) Scale() Scale
- func (a *Axis) SetHighlight(highlight DecimalValue)
- func (a *Axis) SetHighlightStyle(highlightStyle tcell.Style)
- func (a *Axis) SetScale(scale Scale)
- func (a *Axis) SetStyle(style tcell.Style)
- func (a *Axis) Style() tcell.Style
- type AxisBox
- type Bars
- func (b Bars) Data() []Decimal
- func (b Bars) DataSlice() []Decimal
- func (b *Bars) Draw(screen tcell.Screen)
- func (b Bars) Runes() []rune
- func (b Bars) Scale() Scale
- func (b Bars) SetData(data []Decimal)
- func (b Bars) SetRunes(runes []rune)
- func (b Bars) SetScale(scale Scale)
- func (b Bars) SetSliceMethod(method SliceMethod)
- func (b Bars) SetSpacing(spacing int)
- func (b Bars) SetStyle(style tcell.Style)
- func (b Bars) SliceMethod() SliceMethod
- func (b Bars) Spacing() int
- func (b Bars) Style() tcell.Style
- func (b Bars) Values() []Decimal
- type BlockBindings
- type Container
- func (c *Container) Draw(screen tcell.Screen)
- func (c *Container) Focus(delegate func(p tview.Primitive))
- func (c *Container) HasFocus() bool
- func (c *Container) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))
- func (c *Container) MouseHandler() ...
- func (c *Container) SetPrimitive(item tview.Primitive)
- type Decimal
- type DecimalFactory
- type DecimalValue
- type Direction
- type Flex
- func (f *Flex) Bindings() *FlexBindings
- func (f *Flex) Direction() Direction
- func (b *Flex) Focus(setFocus func(p tview.Primitive))
- func (f *Flex) FocusedItem() (i int, count int, item tview.Primitive)
- func (b *Flex) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))
- func (f *Flex) SetBindings(bindings *FlexBindings)
- func (f *Flex) SetDirection(direction Direction)
- type FlexBindings
- type Float
- func (f Float) Add(other Decimal) Decimal
- func (f Float) Div(other Decimal) Decimal
- func (f Float) Equal(other Decimal) bool
- func (f Float) Float64() float64
- func (f Float) GreaterThan(other Decimal) bool
- func (f Float) IntPart() int64
- func (f Float) IsZero() bool
- func (f Float) LessThan(other Decimal) bool
- func (f Float) Mul(other Decimal) Decimal
- func (f Float) Round() Decimal
- func (f Float) String() string
- func (f Float) Sub(other Decimal) Decimal
- type FloatFactory
- type Focus
- type OHLC
- type OHLCCandles
- func (o *OHLCCandles) Draw(screen tcell.Screen)
- func (o *OHLCCandles) NegativeStyle() tcell.Style
- func (o *OHLCCandles) PositiveStyle() tcell.Style
- func (o *OHLCCandles) Runes() OHLCRunes
- func (o *OHLCCandles) Scale() Scale
- func (o *OHLCCandles) SetData(data []OHLC)
- func (o *OHLCCandles) SetNegativeStyle(negativeStyle tcell.Style)
- func (o *OHLCCandles) SetPositiveStyle(positiveStyle tcell.Style)
- func (o *OHLCCandles) SetRunes(runes OHLCRunes)
- func (o *OHLCCandles) SetScale(scale Scale)
- func (o *OHLCCandles) SetSpacing(spacing int)
- func (o *OHLCCandles) Spacing() int
- type OHLCChart
- func (o *OHLCChart) AddOffset(delta int)
- func (o *OHLCChart) AddSpacing(delta int)
- func (o *OHLCChart) Draw(screen tcell.Screen)
- func (o *OHLCChart) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))
- func (o *OHLCChart) Items() []OHLC
- func (o *OHLCChart) Logger() io.Writer
- func (o *OHLCChart) MouseHandler() ...
- func (o *OHLCChart) NegativeStyle() tcell.Style
- func (o *OHLCChart) OHLCAxisStyle() tcell.Style
- func (o *OHLCChart) OHLCCandlesRunes() OHLCRunes
- func (o *OHLCChart) Offset() int
- func (o *OHLCChart) PositiveStyle() tcell.Style
- func (o *OHLCChart) SetItems(items []OHLC)
- func (o *OHLCChart) SetLogger(w io.Writer)
- func (o *OHLCChart) SetNegativeStyle(negativeStyle tcell.Style)
- func (o *OHLCChart) SetOHLCAxisStyle(style tcell.Style)
- func (o *OHLCChart) SetOHLCCandlesRunes(runes OHLCRunes)
- func (o *OHLCChart) SetOffset(offset int)
- func (o *OHLCChart) SetPositiveStyle(positiveStyle tcell.Style)
- func (o *OHLCChart) SetSpacing(spacing int)
- func (o *OHLCChart) SetVolumeAxisStyle(style tcell.Style)
- func (o *OHLCChart) SetVolumeBarsRunes(runes []rune)
- func (o *OHLCChart) SetVolumeBarsStyle(style tcell.Style)
- func (o *OHLCChart) SetVolumeHeight(fraction float64)
- func (o *OHLCChart) Spacing() int
- func (o *OHLCChart) VolumeAxisStyle() tcell.Style
- func (o *OHLCChart) VolumeBarsRunes() []rune
- func (o *OHLCChart) VolumeBarsStyle() tcell.Style
- type OHLCRunes
- type Position
- type Primitive
- type Range
- type Scale
- type ScaleLinear
- func (a *ScaleLinear) Copy() Scale
- func (a *ScaleLinear) NumDecimals() int
- func (a *ScaleLinear) Range() Range
- func (a *ScaleLinear) Reverse(i int) Decimal
- func (a *ScaleLinear) SetRange(rng Range)
- func (a *ScaleLinear) SetSize(size int)
- func (a *ScaleLinear) Size() int
- func (a *ScaleLinear) Value(v Decimal) int
- type SliceMethod
- type Ticks
- func (b Ticks) Data() []Decimal
- func (b Ticks) DataSlice() []Decimal
- func (b *Ticks) Draw(screen tcell.Screen)
- func (b Ticks) Runes() []rune
- func (b Ticks) Scale() Scale
- func (b Ticks) SetData(data []Decimal)
- func (b Ticks) SetRunes(runes []rune)
- func (b Ticks) SetScale(scale Scale)
- func (b Ticks) SetSliceMethod(method SliceMethod)
- func (b Ticks) SetSpacing(spacing int)
- func (b Ticks) SetStyle(style tcell.Style)
- func (b Ticks) SliceMethod() SliceMethod
- func (b Ticks) Spacing() int
- func (b Ticks) Style() tcell.Style
- func (b Ticks) Values() []Decimal
- type Tile
Constants ¶
This section is empty.
Variables ¶
var DefaultBarsRunes = []rune{'▃', '▄', '▆', '█'}
var DefaultBlockBindings = &BlockBindings{ SplitH: tcell.KeyCtrlS, SplitV: tcell.KeyCtrlV, Delete: tcell.KeyCtrlX, FlexBindings: DefaultFlexBindings, Reset: tcell.KeyCtrlO, }
var DefaultFlexBindings = &FlexBindings{ FocusLeft: tcell.KeyCtrlH, FocusDown: tcell.KeyCtrlJ, FocusUp: tcell.KeyCtrlK, FocusRight: tcell.KeyCtrlL, }
var DefaultOHLCRunes = OHLCRunes{
Same: '─',
HighOpenClose: '┬',
LowOpenClose: '┴',
HighOpen: '╻',
LowClose: '╹',
High: '╷',
Low: '╵',
OpenClose: '┼',
Open: '╽',
Close: '╿',
Thick: '┃',
Thin: '│',
}
DefaultOHLCRunes contains the default runes using the box drawing characters. Examples:
╽ ╷ ╷ │ ┃╻ │ ╵ ┃ ─ ┼ ┼ ┬ ┴ ╿╹ │ │
See more at: https://en.wikipedia.org/wiki/Box-drawing_character
var DefaultTicksRunes = []rune{'⎽', '⎼', '—', '⎻', '⎺'}
Functions ¶
This section is empty.
Types ¶
type Axis ¶
Axis represents a chart Axis. The current implementation only supports a vertical axis.
func (*Axis) Highlight ¶
func (a *Axis) Highlight() DecimalValue
Highlight returns the currently highlighted item.
func (*Axis) HighlightStyle ¶
func (a *Axis) HighlightStyle() tcell.Style
HighlightStyle returns the style for highlighting an item on the axis.
func (*Axis) SetHighlight ¶
func (a *Axis) SetHighlight(highlight DecimalValue)
SetHighlight sets the value for highlighting.
func (*Axis) SetHighlightStyle ¶
func (a *Axis) SetHighlightStyle(highlightStyle tcell.Style)
SetHighlightStyle sets the style for highlighting an item on the axis.
type Bars ¶
type Bars struct {
// contains filtered or unexported fields
}
func NewBars ¶
func NewBars(factory DecimalFactory) *Bars
func (Bars) DataSlice ¶
func (b Bars) DataSlice() []Decimal
DataSlice returns data, but only the items that fit on the screen.
func (Bars) SetSliceMethod ¶
func (b Bars) SetSliceMethod(method SliceMethod)
func (Bars) SetSpacing ¶
func (b Bars) SetSpacing(spacing int)
func (Bars) SliceMethod ¶
func (b Bars) SliceMethod() SliceMethod
type BlockBindings ¶
type BlockBindings struct { *FlexBindings SplitH tcell.Key SplitV tcell.Key Delete tcell.Key Reset tcell.Key }
type Container ¶
Container is a dynamic box that can dynamically render different primitives.
func NewContainer ¶
func NewContainer() *Container
func (*Container) InputHandler ¶
func (*Container) MouseHandler ¶
func (*Container) SetPrimitive ¶
type DecimalFactory ¶
type DecimalValue ¶
type DecimalValue struct { // Decimal value. Decimal Decimal // Valid is ture when Decimal is defined. Valid bool }
DecimalValue represents a decimal value that can be undefined, in which case Valid is set to false.
type Flex ¶
Flex is a wrapper around tview.Flex that allows easy keyboard navigation.
func (*Flex) Bindings ¶
func (f *Flex) Bindings() *FlexBindings
func (*Flex) InputHandler ¶
func (*Flex) SetBindings ¶
func (f *Flex) SetBindings(bindings *FlexBindings)
func (*Flex) SetDirection ¶
type FlexBindings ¶
type FlexBindings struct { FocusLeft tcell.Key FocusDown tcell.Key FocusUp tcell.Key FocusRight tcell.Key }
type Float ¶
type Float float64
Float is an implemnetation of Decimal that uses float64.
func (Float) GreaterThan ¶
type FloatFactory ¶
type FloatFactory struct{}
func (FloatFactory) NewFromInt64 ¶
func (f FloatFactory) NewFromInt64(i int64) Decimal
func (FloatFactory) Zero ¶
func (f FloatFactory) Zero() Decimal
type OHLCCandles ¶
func NewOHLCCandles ¶
func NewOHLCCandles(factory DecimalFactory) *OHLCCandles
func (*OHLCCandles) Draw ¶
func (o *OHLCCandles) Draw(screen tcell.Screen)
func (*OHLCCandles) NegativeStyle ¶
func (o *OHLCCandles) NegativeStyle() tcell.Style
func (*OHLCCandles) PositiveStyle ¶
func (o *OHLCCandles) PositiveStyle() tcell.Style
func (*OHLCCandles) Runes ¶
func (o *OHLCCandles) Runes() OHLCRunes
Runes returns the current set of runes used to plot the chart.
func (*OHLCCandles) Scale ¶
func (o *OHLCCandles) Scale() Scale
func (*OHLCCandles) SetData ¶
func (o *OHLCCandles) SetData(data []OHLC)
func (*OHLCCandles) SetNegativeStyle ¶
func (o *OHLCCandles) SetNegativeStyle(negativeStyle tcell.Style)
func (*OHLCCandles) SetPositiveStyle ¶
func (o *OHLCCandles) SetPositiveStyle(positiveStyle tcell.Style)
func (*OHLCCandles) SetRunes ¶
func (o *OHLCCandles) SetRunes(runes OHLCRunes)
SetRunes sets the runes used to plot the chart.
func (*OHLCCandles) SetScale ¶
func (o *OHLCCandles) SetScale(scale Scale)
func (*OHLCCandles) SetSpacing ¶
func (o *OHLCCandles) SetSpacing(spacing int)
func (*OHLCCandles) Spacing ¶
func (o *OHLCCandles) Spacing() int
type OHLCChart ¶
OHLCChart is a Box component that can render OHLCChart data.
func NewOHLCChart ¶
func NewOHLCChart(factory DecimalFactory) *OHLCChart
NewOHLCChart creates a new instance of the OHLC component.
func (*OHLCChart) AddSpacing ¶
func (*OHLCChart) Draw ¶
func (o *OHLCChart) Draw(screen tcell.Screen)
Draw implements tview.Primitive.
func (*OHLCChart) InputHandler ¶
MouseHandler implements tview.Primitive.
func (*OHLCChart) MouseHandler ¶
func (o *OHLCChart) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)
MouseHandler implements tview.Primitive.
func (*OHLCChart) NegativeStyle ¶
func (o *OHLCChart) NegativeStyle() tcell.Style
func (*OHLCChart) OHLCAxisStyle ¶
func (o *OHLCChart) OHLCAxisStyle() tcell.Style
func (*OHLCChart) OHLCCandlesRunes ¶
func (*OHLCChart) PositiveStyle ¶
func (o *OHLCChart) PositiveStyle() tcell.Style
func (*OHLCChart) SetNegativeStyle ¶
func (o *OHLCChart) SetNegativeStyle(negativeStyle tcell.Style)
func (*OHLCChart) SetOHLCAxisStyle ¶
func (o *OHLCChart) SetOHLCAxisStyle(style tcell.Style)
func (*OHLCChart) SetOHLCCandlesRunes ¶
func (*OHLCChart) SetOffset ¶
SetOffset sets the scroll offset for OHLC data. It ensures it's always less than the size of the items and is never negative.
func (*OHLCChart) SetPositiveStyle ¶
func (o *OHLCChart) SetPositiveStyle(positiveStyle tcell.Style)
func (*OHLCChart) SetSpacing ¶
SetSpacing sets the chart spacing.
func (*OHLCChart) SetVolumeAxisStyle ¶
func (o *OHLCChart) SetVolumeAxisStyle(style tcell.Style)
func (*OHLCChart) SetVolumeBarsRunes ¶
func (*OHLCChart) SetVolumeBarsStyle ¶
func (o *OHLCChart) SetVolumeBarsStyle(style tcell.Style)
func (*OHLCChart) SetVolumeHeight ¶
func (*OHLCChart) VolumeAxisStyle ¶
func (o *OHLCChart) VolumeAxisStyle() tcell.Style
func (*OHLCChart) VolumeBarsRunes ¶
func (*OHLCChart) VolumeBarsStyle ¶
func (o *OHLCChart) VolumeBarsStyle() tcell.Style
type OHLCRunes ¶
type OHLCRunes struct { Same rune HighOpenClose rune LowOpenClose rune HighOpen rune LowClose rune High rune Low rune OpenClose rune Open rune Close rune Thick rune Thin rune }
OHLCRunes contains definitions for each OHLC drawing.
type Primitive ¶
type Primitive interface { // SetRect is the tview.Primitive.SetRect method. SetRect(x, y, w, h int) // SetRect is the tview.Primitive.Draw method. Draw(screen tcell.Screen) // SetScale sets the scale to the Primitive. SetScale(Scale) // Scale returns the current scale used by the Primitive. Scale() Scale }
Primitive is a tview.Primitive that can set and retrieve a Scale.
type Scale ¶
type Scale interface { Copy() Scale // Size returns the current size. Size() int // SetSize sets the size. SetSize(int) // SetRange sets the range of the values. SetRange(Range) // Range returns the current range. Range() Range // NumDecimals returns the number of decimals // needed to draw the axis. NumDecimals() int // Value returns the place on scale. Value(Decimal) int // Reverse returns the min value for the place on // scale. Reverse(int) Decimal }
Scale describes a component that can scale decimal values to terminal grid.
type ScaleLinear ¶
type ScaleLinear struct {
// contains filtered or unexported fields
}
Linear represents a linear scale.
func NewScaleLinear ¶
func NewScaleLinear(factory DecimalFactory) *ScaleLinear
NewLinear constructs a new linear scale.
func (*ScaleLinear) Copy ¶
func (a *ScaleLinear) Copy() Scale
func (*ScaleLinear) NumDecimals ¶
func (a *ScaleLinear) NumDecimals() int
func (*ScaleLinear) Range ¶
func (a *ScaleLinear) Range() Range
func (*ScaleLinear) Reverse ¶
func (a *ScaleLinear) Reverse(i int) Decimal
func (*ScaleLinear) SetRange ¶
func (a *ScaleLinear) SetRange(rng Range)
SetRange sets the scale range.
func (*ScaleLinear) Value ¶
func (a *ScaleLinear) Value(v Decimal) int
Value returns a scaled value from decimal.
type SliceMethod ¶
type SliceMethod int
SliceMethod describes the slicing method when the number of items in the slice is too large to be rendered on the screen.
const ( // Last means only the last items will be kept in the slice. Last SliceMethod = iota // First means only the first items will be kept in the slice. First )
type Ticks ¶
type Ticks struct {
// contains filtered or unexported fields
}
func NewTicks ¶
func NewTicks(factory DecimalFactory) *Ticks
func (Ticks) DataSlice ¶
func (b Ticks) DataSlice() []Decimal
DataSlice returns data, but only the items that fit on the screen.
func (Ticks) SetSliceMethod ¶
func (b Ticks) SetSliceMethod(method SliceMethod)
func (Ticks) SetSpacing ¶
func (b Ticks) SetSpacing(spacing int)
func (Ticks) SliceMethod ¶
func (b Ticks) SliceMethod() SliceMethod
type Tile ¶
type Tile struct { *Flex // contains filtered or unexported fields }
Tile is a wrapper around Flex that allows the user to dynamically create and remove splits, and navigate thorugh them, similar to a tiling window manager. See DefaultBlockBindings for default keybindings.
After calling NewTile, the user should call SetFactory.
func (*Tile) InputHandler ¶
func (*Tile) SetBindings ¶
func (t *Tile) SetBindings(bindings *BlockBindings)