Documentation ¶
Index ¶
- func IsInBounds(x, y int, origin Coord, size Size) bool
- type AttrFlags
- type Attrs
- func (tt *Attrs) GetAttrs() *Attrs
- func (tt *Attrs) GetIsCursor() bool
- func (tt *Attrs) GetIsDirty() bool
- func (tt *Attrs) GetIsOccluded() bool
- func (tt *Attrs) GetParent() Elem
- func (tt *Attrs) Merge(ot *Attrs)
- func (tt *Attrs) SetIsCursor(ic bool)
- func (tt *Attrs) SetIsDirty(id bool)
- func (tt *Attrs) SetIsOccluded(ic bool)
- func (tt *Attrs) SetParent(p Elem)
- type Border
- func (br *Border) BLCorner() string
- func (br *Border) BRCorner() string
- func (br *Border) BottomBorder(x int) string
- func (br *Border) GetCorner(i int) string
- func (br *Border) LeftBorder(y int) string
- func (br *Border) RightBorder(y int) string
- func (br *Border) TLCorner() string
- func (br *Border) TRCorner() string
- func (br *Border) TopBorder(x int) string
- type Buffer
- type BufferedElemView
- func (bpv *BufferedElemView) Draw(offset Coord, view View)
- func (bpv *BufferedElemView) Measure() Size
- func (bpv *BufferedElemView) ProcessEventKey(ev *EventKey) bool
- func (bpv *BufferedElemView) Render() (updated bool)
- func (bpv *BufferedElemView) Scroll(dir Coord)
- func (bpv *BufferedElemView) SetIsCursor(ic bool)
- func (bpv *BufferedElemView) SetSize(size Size)
- func (bpv *BufferedElemView) SetStyle(style *Style)
- func (bpv *BufferedElemView) String() string
- func (bpv *BufferedElemView) StringIndented(indent string) string
- type Cell
- type Color
- type Coord
- type Elem
- type EventKey
- type KVPair
- type Padding
- type Page
- func (pg *Page) AppendElem(elem Elem)
- func (pg *Page) DecCursor(isVertical bool)
- func (pg *Page) Draw(offset Coord, view View)
- func (pg *Page) IncCursor(isVertical bool)
- func (pg *Page) Measure() Size
- func (pg *Page) NextCoord() Coord
- func (pg *Page) ProcessEventKey(ev *EventKey) bool
- func (pg *Page) Render() (updated bool)
- func (pg *Page) SetStyle(style *Style)
- func (pg *Page) String() string
- func (pg *Page) StringIndented(indent string) string
- type Size
- type Stack
- type Style
- func (st *Style) Copy() *Style
- func (st *Style) GetBackground() Color
- func (st *Style) GetBorder() *Border
- func (st *Style) GetCursorStyle() *Style
- func (st *Style) GetForeground() Color
- func (st *Style) GetPadding() Padding
- func (st *Style) GetStyle() *Style
- func (st Style) GetTStyle() (tst tcell.Style)
- func (st *Style) WithAttrs(attrs *Attrs) (res Style)
- type StyleFlags
- type TextElem
- func (tel *TextElem) Draw(offset Coord, view View)
- func (tel *TextElem) Measure() Size
- func (tel *TextElem) ProcessEventKey(ev *EventKey) bool
- func (tel *TextElem) Render() (updated bool)
- func (tel *TextElem) SetStyle(style *Style)
- func (tel *TextElem) String() string
- func (tel *TextElem) StringIndented(indent string) string
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AttrFlags ¶
type AttrFlags uint32
NOTE: AttrFlags are merged with a simple or-assign op.
const AttrFlagNone AttrFlags = 0
func (AttrFlags) GetAttrFlags ¶
type Attrs ¶
Attrs have side effects in the Logos system; for example, the lone cursor element (one with AttrFlagIsCursor set) is where most key events are sent to.
func (*Attrs) GetIsCursor ¶
func (*Attrs) GetIsDirty ¶
func (*Attrs) GetIsOccluded ¶
func (*Attrs) SetIsCursor ¶
func (*Attrs) SetIsDirty ¶
func (*Attrs) SetIsOccluded ¶
type Border ¶
type Border struct { Corners [4]string // starts upper-left and clockwise, "" draws no corner. TopLine []string // nil if no top border. BotLine []string // nil if no bottom border. LeftLine []string // nil if no left border. RightLine []string // nil if no right border. }
A border can only have width 0 or 1, and is part of the padding. Each string should represent a character of width 1.
func DefaultBorder ¶
func DefaultBorder() Border
func LeftBorder ¶
func LeftBorder() Border
func (*Border) BottomBorder ¶
func (*Border) LeftBorder ¶
func (*Border) RightBorder ¶
type Buffer ¶
A Buffer is a buffer area in which to draw.
func (*Buffer) DrawToScreen ¶
func (bb *Buffer) DrawToScreen(s tcell.Screen)
type BufferedElemView ¶
type BufferedElemView struct { Coord Size *Style Attrs // e.g. to focus on a scrollbar Base Elem // the underlying elem Offset Coord // within elem for pagination *Buffer // view's internal draw screen }
A view onto an element. Somewhat like a slice onto an array (as a view is onto an elem), except cells are allocated here.
func NewBufferedElemView ¶
func NewBufferedElemView(elem Elem, size Size) *BufferedElemView
Returns a new *BufferedElemView that spans the whole elem. If size is zero, the elem is measured first to get the full buffer size. The result must still be rendered before drawing. The *BufferedElemView inherits the style and coordinates of the elem, and the elem's coord is set to zero.
func (*BufferedElemView) Draw ¶
func (bpv *BufferedElemView) Draw(offset Coord, view View)
func (*BufferedElemView) Measure ¶
func (bpv *BufferedElemView) Measure() Size
BufferedElemView's size is simply defined by .Size.
func (*BufferedElemView) ProcessEventKey ¶
func (bpv *BufferedElemView) ProcessEventKey(ev *EventKey) bool
func (*BufferedElemView) Render ¶
func (bpv *BufferedElemView) Render() (updated bool)
Renders the elem onto the internal buffer. Assumes buffered elem view's elem was already rendered. TODO: this function could be optimized to reduce redundant background cell modifications.
func (*BufferedElemView) Scroll ¶
func (bpv *BufferedElemView) Scroll(dir Coord)
func (*BufferedElemView) SetIsCursor ¶
func (bpv *BufferedElemView) SetIsCursor(ic bool)
Cursor status pierces the buffered elem view; but a few key events are still consumed before the base.
func (*BufferedElemView) SetSize ¶
func (bpv *BufferedElemView) SetSize(size Size)
func (*BufferedElemView) SetStyle ¶
func (bpv *BufferedElemView) SetStyle(style *Style)
Pass on style to the base elem.
func (*BufferedElemView) String ¶
func (bpv *BufferedElemView) String() string
func (*BufferedElemView) StringIndented ¶
func (bpv *BufferedElemView) StringIndented(indent string) string
type Cell ¶
type Cell struct { Character string // 1 unicode character, or " ". Width int *Style Attrs Ref Elem // reference to element }
A terminal character cell.
func (*Cell) GetTCellContent ¶
This is where a bit of dynamic logic is performed, namely where the attr is used to derive the final style.
func (*Cell) SetValueFromCell ¶
NOTE: there is a difference in behavior from SetValue(...,c2) when c2 has attributes not present in c2.Ref, so the two are not equivalent.
type Coord ¶
func (Coord) IsNonNegative ¶
type Elem ¶
type Elem interface { GetParent() Elem SetParent(Elem) GetCoord() Coord SetCoord(Coord) GetStyle() *Style SetStyle(*Style) GetAttrs() *Attrs GetIsCursor() bool SetIsCursor(bool) GetIsDirty() bool SetIsDirty(bool) GetIsOccluded() bool SetIsOccluded(bool) GetSize() Size Measure() Size Render() bool Draw(offset Coord, dst View) ProcessEventKey(*EventKey) bool String() string StringIndented(indent string) string }
An elem is something that can draw a portion of itself onto a view. It has a relative coord and a size. Before it is drawn, it is rendered. Measure will update its size, while GetSize() returns the cached size. ProcessEventKey() returns true if event was consumed.
type Padding ¶
func (Padding) GetPadding ¶
type Page ¶
type Page struct { Coord // used by parent only. TODO document. Size *Style Attrs Elems []Elem Cursor int // selected cursor element index, or -1. }
A Page has renderable Elem(ents).
func NewPage ¶
produces a page from a string. width is the width of the page. if isCode, width is ignored.
func (*Page) AppendElem ¶
Measures the size of elem and appends to page below the last element, or if empty, the top-leftmost coordinate exclusive of padding cells.
func (*Page) ProcessEventKey ¶
func (*Page) Render ¶
Unlike TextElem or BufferedElemView, a Page doesn't keep its own buffer. Its render function calls the elements' render functions, and the element buffers are combined during Draw(). There is a need for distinction because Draw() can't be too slow, so Render() is about optimizing Draw() calls. The distinction between *Page and BufferedElemView gives the user more flexibility.
func (*Page) StringIndented ¶
type Size ¶
func (Size) IsPositive ¶
type Stack ¶
type Stack struct {
Page // a Stack has the same fields as a page.
}
A Stack is like a Page, but it only highlights the top element, and dims, occludes, or hides lower elements. A Stack is therefore ideal for showing modal views. NOTE: While most applications shouldn't, it's perfectly fine to embed Stacks within Stacks, or layer them on top within a stack.
func StackOf ¶
Traverses the inclusive ancestors of elem and returns the first *Stack encountered. The purpose of this function is to find where to push new layers and modal elements for drawing.
func (*Stack) Draw ¶
Draw the rendered layers onto the view. Any dimming of occluded layers must actually stretch in all directions infinitely (since we can scroll beyond the bounds of any view and we expect the dimming effect to carry while we scroll), so the entire view is dimmed first, and then the upper-most layer is drawn.
func (*Stack) ProcessEventKey ¶
func (*Stack) Render ¶
A Stack's render function behaves the same as a Page's; it renders its elements (here, its layers).
func (*Stack) StringIndented ¶
type Style ¶
type Style struct { Foreground Color Background Color Padding Padding Border Border StyleFlags Other []KVPair CursorStyle *Style }
Style is purely visual and has no side effects. It is generally referred to by pointer; you may need to copy before modifying.
func DefaultStyle ¶
func DefaultStyle() *Style
func (*Style) GetBackground ¶
func (*Style) GetCursorStyle ¶
func (*Style) GetForeground ¶
func (*Style) GetPadding ¶
type StyleFlags ¶
type StyleFlags uint32
const ( StyleFlagBold StyleFlags = 1 << iota StyleFlagDim StyleFlagShaded StyleFlagBlink StyleFlagUnderline StyleFlagItalic StyleFlagStrikeThrough )
const StyleFlagNone StyleFlags = 0
func (StyleFlags) GetIsDim ¶
func (sf StyleFlags) GetIsDim() bool
func (StyleFlags) GetIsShaded ¶
func (sf StyleFlags) GetIsShaded() bool
func (*StyleFlags) SetIsDim ¶
func (sf *StyleFlags) SetIsDim(id bool)
func (*StyleFlags) SetIsShaded ¶
func (sf *StyleFlags) SetIsShaded(id bool)