From b543e458b314b6248e7d31a868c757543bfe6024 Mon Sep 17 00:00:00 2001 From: punkfairie <23287005+punkfairie@users.noreply.github.com> Date: Sat, 7 Sep 2024 16:34:18 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20fix(ui):=20add=20newline=20when?= =?UTF-8?q?=20quitting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 7ba2827..bd45d2c 100644 --- a/main.go +++ b/main.go @@ -24,6 +24,7 @@ type menu struct { help help.Model inputStyle gloss.Style spinner spinner.Model + quitting bool } func initialModel() menu { @@ -32,10 +33,11 @@ func initialModel() menu { s.Style = gloss.NewStyle().Foreground(gloss.Color("3")) return menu{ - current: 3, - keys: keys, - help: help.New(), - spinner: s, + current: 3, + keys: keys, + help: help.New(), + spinner: s, + quitting: false, } } @@ -165,6 +167,7 @@ func (m menu) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeyMsg: switch msg.String() { case "ctrl+c", "q": + m.quitting = true return m, tea.Quit } @@ -220,7 +223,12 @@ func (m menu) View() string { 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) }