Documentation ¶
Index ¶
- Constants
- Variables
- func ANSIWriter() *ansi
- func InitScreenAndRun(m *testing.M, screen *tcell.Screen)
- func IsEmpty(l Component) bool
- type Align
- type Box
- type Canvas
- type ColorLayout
- type Component
- func Bg(del Component, color tcell.Color) Component
- func BgColoredString(s string, fg tcell.Color, bg tcell.Color) Component
- func ColoredString(s string, fg tcell.Color) Component
- func Fg(del Component, color tcell.Color) Component
- func NewScrollingWrappingTextArea(name string, text string) Component
- func TextString(s string) Component
- type ConcatLayout
- type Dir
- type ElementScrollController
- type ElementScrollLayout
- func (l *ElementScrollLayout) Add(c Component)
- func (l *ElementScrollLayout) Render(w Writer, width, height int) error
- func (l *ElementScrollLayout) RenderStateful(w Writer, prevState interface{}, width, height int) (state interface{}, err error)
- func (l *ElementScrollLayout) Size(width int, height int) (int, int, error)
- type ElementScrollState
- type ElementScroller
- type ErrorHandler
- type ErrorReporter
- type FillerString
- type FixedSizeLayout
- type FlexLayout
- type InteractiveTester
- type Line
- type MaxLengthLayout
- type MinLengthLayout
- type ModalLayout
- type RTY
- type ScreenCanvas
- type SkipErrorHandler
- type StatefulComponent
- type StringBuilder
- type StringLayout
- type SubCanvas
- type TailLayout
- type TempCanvas
- type TextScrollController
- type TextScrollLayout
- func (l *TextScrollLayout) Add(c Component)
- func (l *TextScrollLayout) Render(w Writer, width, height int) error
- func (l *TextScrollLayout) RenderStateful(w Writer, prevState interface{}, width, height int) (state interface{}, err error)
- func (l *TextScrollLayout) Size(width int, height int) (int, int, error)
- type TextScrollState
- type TextScroller
- type Tokenizer
- type Writer
Constants ¶
const GROW = math.MaxInt32
Variables ¶
var EmptyLayout = NewConcatLayout(DirVert)
Functions ¶
func ANSIWriter ¶
func ANSIWriter() *ansi
ANSIWriter returns an io.Writer which translates any ANSI escape codes written to it into tview color tags. Other escape codes don't have an effect and are simply removed. The translated text is written to the provided writer.
func InitScreenAndRun ¶ added in v0.1.0
unfortunately, tcell misbehaves if we try to make a new Screen for every test this function is intended for use from a `TestMain`, so that we can have a global Screen across all tests in the package
Types ¶
type Box ¶
type Box struct {
// contains filtered or unexported fields
}
func NewGrowingBox ¶ added in v0.2.0
func NewGrowingBox() *Box
makes a box that will grow to fill its canvas
func NewGrowingWindow ¶ added in v0.7.11
func NewGrowingWindow() *Box
type ColorLayout ¶
type ColorLayout struct {
// contains filtered or unexported fields
}
type Component ¶
type Component interface { Size(availWidth, availHeight int) (int, int, error) Render(w Writer, width, height int) error }
Component renders onto a canvas
func TextString ¶
type ConcatLayout ¶
type ConcatLayout struct {
// contains filtered or unexported fields
}
func NewConcatLayout ¶
func NewConcatLayout(dir Dir) *ConcatLayout
func NewLines ¶
func NewLines() *ConcatLayout
func (*ConcatLayout) Add ¶
func (l *ConcatLayout) Add(c Component) *ConcatLayout
func (*ConcatLayout) AddDynamic ¶ added in v0.2.0
func (l *ConcatLayout) AddDynamic(c Component) *ConcatLayout
A ConcatLayout element can be either fixed or dynamic. Fixed components are all given a chance at the full canvas. If they ask for too much in sum, things will break. Dynamic components get equal shares of whatever is left after the fixed components get theirs. NB: There is currently a bit of a murky line between ConcatLayout and FlexLayout.
type ElementScrollController ¶
type ElementScrollController struct {
// contains filtered or unexported fields
}
func (*ElementScrollController) Bottom ¶ added in v0.1.0
func (s *ElementScrollController) Bottom()
func (*ElementScrollController) Down ¶ added in v0.1.0
func (s *ElementScrollController) Down()
func (*ElementScrollController) GetSelectedChild ¶
func (s *ElementScrollController) GetSelectedChild() string
func (*ElementScrollController) GetSelectedIndex ¶
func (s *ElementScrollController) GetSelectedIndex() int
func (*ElementScrollController) Top ¶ added in v0.1.0
func (s *ElementScrollController) Top()
func (*ElementScrollController) Up ¶ added in v0.1.0
func (s *ElementScrollController) Up()
type ElementScrollLayout ¶
type ElementScrollLayout struct {
// contains filtered or unexported fields
}
func NewElementScrollLayout ¶
func NewElementScrollLayout(name string) *ElementScrollLayout
func (*ElementScrollLayout) Add ¶
func (l *ElementScrollLayout) Add(c Component)
func (*ElementScrollLayout) Render ¶
func (l *ElementScrollLayout) Render(w Writer, width, height int) error
func (*ElementScrollLayout) RenderStateful ¶
func (l *ElementScrollLayout) RenderStateful(w Writer, prevState interface{}, width, height int) (state interface{}, err error)
type ElementScrollState ¶
type ElementScrollState struct {
// contains filtered or unexported fields
}
type ElementScroller ¶
type ElementScroller interface { Up() Down() Top() Bottom() GetSelectedIndex() int }
type ErrorHandler ¶ added in v0.14.0
type ErrorHandler interface {
Errorf(format string, args ...interface{})
}
We want our tests to be able to handle errors.
But we don't want errors in RTY rendering to stop the rendering pipeline.
So we need a way to accumulate errors. By design, testing.T implements this interface.
type ErrorReporter ¶ added in v0.7.11
type FillerString ¶ added in v0.2.0
type FillerString struct {
// contains filtered or unexported fields
}
Fills a space by repeating a string
func NewFillerString ¶ added in v0.2.0
func NewFillerString(ch rune) *FillerString
type FixedSizeLayout ¶
type FixedSizeLayout struct {
// contains filtered or unexported fields
}
FixedSizeLayout fixes a component to a size
func NewFixedSize ¶
func NewFixedSize(del Component, width int, height int) *FixedSizeLayout
type FlexLayout ¶
type FlexLayout struct {
// contains filtered or unexported fields
}
FlexLayout lays out its sub-components.
func NewFlexLayout ¶
func NewFlexLayout(dir Dir) *FlexLayout
func (*FlexLayout) Add ¶
func (l *FlexLayout) Add(c Component) *FlexLayout
type InteractiveTester ¶ added in v0.1.0
type InteractiveTester struct {
// contains filtered or unexported fields
}
func NewInteractiveTester ¶ added in v0.1.0
func NewInteractiveTester(t ErrorReporter, screen tcell.Screen) InteractiveTester
func (*InteractiveTester) Run ¶ added in v0.1.0
func (i *InteractiveTester) Run(name string, width int, height int, c Component)
func (*InteractiveTester) T ¶ added in v0.7.11
func (i *InteractiveTester) T() ErrorReporter
type MaxLengthLayout ¶ added in v0.7.12
type MaxLengthLayout struct {
// contains filtered or unexported fields
}
func NewMaxLengthLayout ¶ added in v0.7.12
func NewMaxLengthLayout(del Component, dir Dir, max int) MaxLengthLayout
type MinLengthLayout ¶ added in v0.4.1
type MinLengthLayout struct {
// contains filtered or unexported fields
}
func NewMinLengthLayout ¶ added in v0.4.1
func NewMinLengthLayout(len int, dir Dir) *MinLengthLayout
func (*MinLengthLayout) Add ¶ added in v0.4.1
func (l *MinLengthLayout) Add(c Component) *MinLengthLayout
func (*MinLengthLayout) Render ¶ added in v0.4.1
func (ml *MinLengthLayout) Render(writer Writer, width int, height int) error
func (*MinLengthLayout) SetAlign ¶ added in v0.4.1
func (l *MinLengthLayout) SetAlign(val Align) *MinLengthLayout
type ModalLayout ¶ added in v0.1.0
type ModalLayout struct {
// contains filtered or unexported fields
}
func NewModalLayout ¶ added in v0.1.0
func NewModalLayout(bg Component, fg Component, fraction float64, fixed bool) *ModalLayout
fg will be rendered on top of bg if fixed is true, it will use using fraction/1 of the height and width of the screen if fixed is false, it will use whatever `fg` asks for, up to fraction/1 of width and height
type RTY ¶
type RTY interface { Render(c Component) // Register must be called before Render RegisterElementScroll(name string, children []string) (l *ElementScrollLayout, selectedChild string) // *Scroller must be called after Render (each call to Render invalidates previous Crollers) ElementScroller(name string) ElementScroller TextScroller(name string) TextScroller }
type ScreenCanvas ¶
type ScreenCanvas struct {
// contains filtered or unexported fields
}
func (*ScreenCanvas) Close ¶
func (c *ScreenCanvas) Close() (int, int)
func (*ScreenCanvas) GetContent ¶
func (*ScreenCanvas) SetContent ¶
func (*ScreenCanvas) Size ¶
func (c *ScreenCanvas) Size() (int, int)
type SkipErrorHandler ¶ added in v0.14.0
type SkipErrorHandler struct{}
func (SkipErrorHandler) Errorf ¶ added in v0.14.0
func (SkipErrorHandler) Errorf(format string, args ...interface{})
type StatefulComponent ¶
type StringBuilder ¶
type StringBuilder interface { Text(string) StringBuilder Textf(string, ...interface{}) StringBuilder Fg(tcell.Color) StringBuilder Bg(tcell.Color) StringBuilder Build() Component }
func NewStringBuilder ¶
func NewStringBuilder() StringBuilder
type StringLayout ¶
type StringLayout struct {
// contains filtered or unexported fields
}
type SubCanvas ¶
type SubCanvas struct {
// contains filtered or unexported fields
}
func (*SubCanvas) GetContent ¶
func (*SubCanvas) SetContent ¶
type TailLayout ¶ added in v0.7.12
type TailLayout struct {
// contains filtered or unexported fields
}
A tail layout renders the "end" of its contents rather than the beginning when the contents overflow the box.
func NewTailLayout ¶ added in v0.7.12
func NewTailLayout(del Component) TailLayout
type TempCanvas ¶
type TempCanvas struct {
// contains filtered or unexported fields
}
func (*TempCanvas) Close ¶
func (c *TempCanvas) Close() (int, int)
func (*TempCanvas) GetContent ¶
func (*TempCanvas) SetContent ¶
func (*TempCanvas) Size ¶
func (c *TempCanvas) Size() (int, int)
type TextScrollController ¶
type TextScrollController struct {
// contains filtered or unexported fields
}
func (*TextScrollController) Bottom ¶ added in v0.1.0
func (s *TextScrollController) Bottom()
func (*TextScrollController) Down ¶
func (s *TextScrollController) Down()
func (*TextScrollController) SetFollow ¶ added in v0.1.0
func (s *TextScrollController) SetFollow(follow bool)
func (*TextScrollController) ToggleFollow ¶
func (s *TextScrollController) ToggleFollow()
func (*TextScrollController) Top ¶ added in v0.1.0
func (s *TextScrollController) Top()
func (*TextScrollController) Up ¶
func (s *TextScrollController) Up()
type TextScrollLayout ¶
type TextScrollLayout struct {
// contains filtered or unexported fields
}
func NewTextScrollLayout ¶
func NewTextScrollLayout(name string) *TextScrollLayout
func (*TextScrollLayout) Add ¶
func (l *TextScrollLayout) Add(c Component)
func (*TextScrollLayout) Render ¶
func (l *TextScrollLayout) Render(w Writer, width, height int) error
func (*TextScrollLayout) RenderStateful ¶
func (l *TextScrollLayout) RenderStateful(w Writer, prevState interface{}, width, height int) (state interface{}, err error)
type TextScrollState ¶
type TextScrollState struct {
// contains filtered or unexported fields
}
type TextScroller ¶
type TextScroller interface { Up() Down() Top() Bottom() ToggleFollow() SetFollow(following bool) }
type Tokenizer ¶ added in v0.2.0
type Tokenizer struct {
// contains filtered or unexported fields
}
A tokenizer that breaks a string up by spaces.
Ideally, we'd use the table-based algorithm defined in: http://www.unicode.org/reports/tr14/ like this package does: https://godoc.org/github.com/gorilla/i18n/linebreak but I didn't find a good implementation of that algorithm in Go (the one above is half-implemented and doesn't work for the most basic things).
This is a half-assed implementation that should have a similar interface to a "real" implementation.
func NewTokenizer ¶ added in v0.2.0
type Writer ¶
type Writer interface { SetContent(x int, y int, mainc rune, combc []rune) Divide(x, y, width, height int) (Writer, error) Foreground(c tcell.Color) Writer Background(c tcell.Color) Writer Invert() Writer Fill() (Writer, error) RenderChild(c Component) int RenderChildInTemp(c Component) Canvas Embed(src Canvas, srcY, srcHeight int) error RenderStateful(c StatefulComponent, name string) }