-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
size.go
43 lines (37 loc) · 780 Bytes
/
size.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
package cointop
// Size returns window width and height
func (ct *Cointop) size() (int, int) {
ct.debuglog("size()")
return ct.g.Size()
}
// Width returns window width
func (ct *Cointop) width() int {
ct.debuglog("width()")
w, _ := ct.size()
return w
}
// Height returns window height
func (ct *Cointop) height() int {
ct.debuglog("height()")
_, h := ct.size()
return h
}
// viewWidth returns view width
func (ct *Cointop) viewWidth(view string) int {
ct.debuglog("viewWidth()")
v, err := ct.g.View(view)
if err != nil {
return 0
}
w, _ := v.Size()
return w
}
// ClampedWidth returns the clamped width
func (ct *Cointop) ClampedWidth() int {
ct.debuglog("clampedWidth()")
w := ct.width()
if w > ct.maxTableWidth {
return ct.maxTableWidth
}
return w
}