on main help sign in
chore(ui): add comments to internal/ui/model/ui.go
8d5226dAyman Bagabas
internal/ui/model/ui.go+7
@@ -14,13 +14,16 @@ import (
14 uv "github.com/charmbracelet/ultraviolet"
14 uv "github.com/charmbracelet/ultraviolet"
15)
15)
16
16
17+// uiState represents the current focus state of the UI.
17type uiState uint8
18type uiState uint8
18
19
20+// Possible uiState values.
19const (
21const (
20 uiChat uiState = iota
22 uiChat uiState = iota
21 uiEdit
23 uiEdit
22)
24)
23
25
26+// UI represents the main user interface model.
24type UI struct {
27type UI struct {
25 app *app.App
28 app *app.App
26 com *common.Common
29 com *common.Common
@@ -37,6 +40,7 @@ type UI struct {
37 layout layout
40 layout layout
38}
41}
39
42
43+// New creates a new instance of the [UI] model.
40func New(com *common.Common, app *app.App) *UI {
44func New(com *common.Common, app *app.App) *UI {
41 return &UI{
45 return &UI{
42 app: app,
46 app: app,
@@ -48,10 +52,12 @@ func New(com *common.Common, app *app.App) *UI {
48 }
52 }
49}
53}
50
54
55+// Init initializes the UI model.
51func (m *UI) Init() tea.Cmd {
56func (m *UI) Init() tea.Cmd {
52 return nil
57 return nil
53}
58}
54
59
60+// Update handles updates to the UI model.
55func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
61func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
56 var cmds []tea.Cmd
62 var cmds []tea.Cmd
57 switch msg := msg.(type) {
63 switch msg := msg.(type) {
@@ -89,6 +95,7 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
89 return m, tea.Batch(cmds...)
95 return m, tea.Batch(cmds...)
90}
96}
91
97
98+// View renders the UI model's view.
92func (m *UI) View() tea.View {
99func (m *UI) View() tea.View {
93 var v tea.View
100 var v tea.View
94 v.AltScreen = true
101 v.AltScreen = true