Skip to content

Commit

Permalink
fix simple and debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Miller committed Feb 20, 2024
1 parent 9b1d03c commit 6f8fd8e
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"debugAdapter": "dlv-dap",
"request": "attach",
"mode": "remote",
"remotePath": "${workspaceFolder}/examples/simple",
"remotePath": "${workspaceFolder}/examples/simple/",
"port": 2345,
"host": "127.0.0.1",
"preLaunchTask": "Run simple headless dlv" // Here !
Expand All @@ -21,7 +21,7 @@
"debugAdapter": "dlv-dap",
"request": "attach",
"mode": "remote",
"remotePath": "${workspaceFolder}/examples/deeper",
"remotePath": "${workspaceFolder}/examples/deeper/",
"port": 2345,
"host": "127.0.0.1",
"preLaunchTask": "Run deeper headless dlv" // Here !
Expand Down
21 changes: 13 additions & 8 deletions examples/simple/color/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ func (m Model) Init() tea.Cmd {
}

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

switch msg.(tea.KeyMsg).String() {
case "esc":
pop := cmdize(navstack.PopNavigation{})
selected := cmdize(ColorSelected{m.RGB})
return m, tea.Sequence(pop, selected)
case "ctrl+c":
return m, tea.Quit
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "esc":
pop := cmdize(navstack.PopNavigation{})
return m, pop
case "enter":
pop := cmdize(navstack.PopNavigation{})
selected := cmdize(ColorSelected{m.RGB})
return m, tea.Sequence(pop, selected)
case "ctrl+c":
return m, tea.Quit
}
}

return m, nil
Expand Down
37 changes: 37 additions & 0 deletions examples/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,43 @@ import (

var docStyle = lipgloss.NewStyle()

type model struct {
SelectedColor string
menu menu.Model
window *window.Model
}

func (m model) Init() tea.Cmd {
return nil
}

func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case color.ColorSelected:
m.SelectedColor = msg.RGB
return m, tea.Quit
case tea.KeyMsg:
if msg.String() == "ctrl+c" {
return m, tea.Quit
}
case tea.WindowSizeMsg:
h, v := docStyle.GetFrameSize()
m.window.Height = msg.Height
m.window.Width = msg.Width - h
m.window.TopOffset = v
m.menu.SetSize(m.window)
return m, nil
}

updatedmenu, cmd := m.menu.Update(msg)
m.menu = updatedmenu.(menu.Model)
return m, cmd
}

func (m model) View() string {
return docStyle.Render(m.menu.View())
}

func main() {
red := menu.Choice{
Title: "Red Envy",
Expand Down
45 changes: 0 additions & 45 deletions examples/simple/model.go

This file was deleted.

0 comments on commit 6f8fd8e

Please sign in to comment.