-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathviewport.go
47 lines (37 loc) · 1.04 KB
/
viewport.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
package skeleton
import (
"github.com/charmbracelet/bubbles/viewport"
"sync"
)
// --------------------------------------------
var (
onceViewport sync.Once
vp *viewport.Model
)
func newTerminalViewport() *viewport.Model {
onceViewport.Do(func() {
vp = &viewport.Model{Width: 80, Height: 24} // Question: Is it best to use 80x24 as default?
})
return vp
}
// --------------------------------------------
// GetTerminalViewport returns the viewport.
func (s *Skeleton) GetTerminalViewport() *viewport.Model {
return vp
}
// SetTerminalViewportWidth sets the width of the viewport.
func (s *Skeleton) SetTerminalViewportWidth(width int) {
vp.Width = width
}
// SetTerminalViewportHeight sets the height of the viewport.
func (s *Skeleton) SetTerminalViewportHeight(height int) {
vp.Height = height
}
// GetTerminalWidth returns the width of the terminal.
func (s *Skeleton) GetTerminalWidth() int {
return vp.Width
}
// GetTerminalHeight returns the height of the terminal.
func (s *Skeleton) GetTerminalHeight() int {
return vp.Height
}