This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
/
properties.go
145 lines (114 loc) 路 2.68 KB
/
properties.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package box
import "github.com/gdamore/tcell"
// Properties are passed along with box.Box tocreate and configure a Box element
//
// Contents
//
// The contents of the Box is not rendered by this component
//
//
// Box Sizing
//
// Box Sizing is Border Box only
// Border and padding is accounted for inside the width and height, meaning
// the Box can never be bigger than the width or height.
type Properties struct {
// ZIndex is the layer this Box is rendered on, with larger numbers appearing
// on top.
ZIndex int
Align Align
// Content Box
// If neither Width,Height or Rows,Columns are set, it will be calculated
// automatically When set this is the percentage width and height.
// Ignored when Rows,Columns is not 0
Width, Height int // 0 = auto
// Set the size fixed in rows and columns.
// Ignored if 0
// If both Rows and Width are set Rows with be used.
Rows, Columns int
Grow int
// Padding Box
Padding Padding
Margin Margin
Direction Direction
// Border
Border Border
Background tcell.Color
Foreground tcell.Color
Overflow Overflow
MinHeight int
MinWidth int
// TODO: maybe expand labels to allow them to be top/bottom left, center, right
// Title is a Label placed on the top border
Title Label
// Footer is a Label place on the bottom border
Footer Label
}
// [ BoxModel Types ]-----------------------------------------------------------
type Padding struct {
Top int
Right int
Bottom int
Left int
}
type Margin struct {
Top int
Right int
Bottom int
Left int
}
type Direction int
const (
DirectionRow Direction = iota
DirectionRowReverse
DirectionColumn
DirectionColumnReverse
)
type Border struct {
Style BorderStyle
Background tcell.Color
Foreground tcell.Color
}
type BorderStyle int
const (
BorderStyleNone BorderStyle = iota
BorderStyleSingle
BorderStyleDouble
BorderStyleBox // Box drawing characters
)
type Overflow int
const (
OverflowScroll Overflow = iota
OverflowNone
OverflowScrollX
OverflowScrollY
)
type Align int
const (
AlignAuto Align = iota
AlignStart
AlignCenter
AlignEnd
)
// [ Labels ]-------------------------------------------------------------------
type LabelWrap int
const (
LabelWrapNone LabelWrap = iota
LabelWrapBracket
LabelWrapBrace
LabelWrapChevron
LabelWrapSquareBracket
)
// Label is a decorative string that can be added to the top or bottom border
//
// Margin allows you to move the whole label around, while Padding allows you
// to define the gap between the Wrap and Value.
// If no Padding is specified a single column is still added to each side of the
// Value.
type Label struct {
Value string
Wrap LabelWrap
Align Align
Margin Margin
Padding Padding
}