-
Notifications
You must be signed in to change notification settings - Fork 301
/
components.go
62 lines (46 loc) · 1.24 KB
/
components.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package rty
import (
"math"
"github.com/gdamore/tcell"
)
// Components are able to render themselves onto a screen
type RTY interface {
Render(c Component) error
// 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 ElementScroller interface {
Up()
Down()
Top()
Bottom()
GetSelectedIndex() int
}
type TextScroller interface {
Up()
Down()
Top()
Bottom()
ToggleFollow()
SetFollow(following bool)
}
// Component renders onto a canvas
type Component interface {
Size(availWidth, availHeight int) (int, int, error)
Render(w Writer, width, height int) error
}
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
Fill() (Writer, error)
RenderChild(c Component) int
RenderChildInTemp(c Component) Canvas
Embed(src Canvas, srcY, srcHeight int) error
RenderStateful(c StatefulComponent, name string)
}
const GROW = math.MaxInt32