💄 fix(ui): add newline when quitting
This commit is contained in:
parent
82e585c5a5
commit
b543e458b3
1 changed files with 13 additions and 5 deletions
18
main.go
18
main.go
|
@ -24,6 +24,7 @@ type menu struct {
|
||||||
help help.Model
|
help help.Model
|
||||||
inputStyle gloss.Style
|
inputStyle gloss.Style
|
||||||
spinner spinner.Model
|
spinner spinner.Model
|
||||||
|
quitting bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func initialModel() menu {
|
func initialModel() menu {
|
||||||
|
@ -32,10 +33,11 @@ func initialModel() menu {
|
||||||
s.Style = gloss.NewStyle().Foreground(gloss.Color("3"))
|
s.Style = gloss.NewStyle().Foreground(gloss.Color("3"))
|
||||||
|
|
||||||
return menu{
|
return menu{
|
||||||
current: 3,
|
current: 3,
|
||||||
keys: keys,
|
keys: keys,
|
||||||
help: help.New(),
|
help: help.New(),
|
||||||
spinner: s,
|
spinner: s,
|
||||||
|
quitting: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +167,7 @@ func (m menu) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
case tea.KeyMsg:
|
case tea.KeyMsg:
|
||||||
switch msg.String() {
|
switch msg.String() {
|
||||||
case "ctrl+c", "q":
|
case "ctrl+c", "q":
|
||||||
|
m.quitting = true
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +223,12 @@ func (m menu) View() string {
|
||||||
|
|
||||||
helpView := m.help.View(m.keys)
|
helpView := m.help.View(m.keys)
|
||||||
|
|
||||||
page := gloss.JoinVertical(gloss.Left, content, helpView)
|
last := ""
|
||||||
|
if m.quitting {
|
||||||
|
last = "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
page := gloss.JoinVertical(gloss.Left, content, helpView, last)
|
||||||
|
|
||||||
return gloss.PlaceHorizontal(width, gloss.Center, page)
|
return gloss.PlaceHorizontal(width, gloss.Center, page)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue