-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (46 loc) · 1.57 KB
/
main.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
package main
import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"examples/util"
bl "github.com/winder/bubblelayout"
)
func New() tea.Model {
// -------------------------
// | | NORTH | |
// | |---------------- |
// | W | 0 | 1 | E |
// | E |---------------- A |
// | S | - | S |
// | T | - - 2 - - | T |
// | | - | |
// | |---------------- |
// | | SOUTH | |
// -------------------------
layout := bl.New()
var models []tea.Model
models = append(models, util.NewSimpleModel("9", layout.Add("")))
models = append(models, util.NewSimpleModel("10", layout.Add("wrap")))
models = append(models, util.NewSimpleModel("11", layout.Add("span 2 2")))
models = append(models, util.NewSimpleModel("12", layout.Add("dock north 1!")))
models = append(models, util.NewSimpleModel("13", layout.Add("dock south 1!")))
models = append(models, util.NewSimpleModel("14", layout.Add("dock west 1:10")))
models = append(models, util.NewSimpleModel("15", layout.Add("dock east 1:10")))
view := func(models []tea.Model) string {
// Note: docks should be joined in the order they are defined.
center := lipgloss.JoinVertical(0,
models[3].View(), // north
lipgloss.JoinHorizontal(0, models[0].View(), models[1].View()),
models[2].View(),
models[4].View()) // south
return lipgloss.JoinHorizontal(0,
models[5].View(), // west
center,
models[6].View()) // east
}
return util.NewLayoutModel(models, layout, view)
}
func main() {
p := tea.NewProgram(New())
p.Run()
}