Skip to content

Commit 294cbfe

Browse files
authored
UI tweaks (#394)
* Add `tea.ShowCursor`. * Fix inconsistent progress bar size. * Use simple colour for progress bar. * Reduce overall FPS. Possibly fixes #393
1 parent c29f421 commit 294cbfe

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

cli/ui.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ func tickCmd() tea.Cmd {
6060
}
6161

6262
func (u *ui) Init() tea.Cmd {
63-
u.progress = progress.New(progress.WithScaledGradient("#c72e49", "#edf7f7"), progress.WithSolidFill("#c72e49"))
63+
u.progress = progress.New(progress.WithSolidFill("#c72e49"), progress.WithWidth(maxWidth-padding))
6464
u.quitCh = make(chan struct{})
6565
return tea.Batch(tickCmd())
6666
}
6767

6868
func (u *ui) Run() {
6969
runtime.LockOSThread()
7070
ctx, cancel := context.WithCancel(context.Background())
71-
p := tea.NewProgram(u, tea.WithContext(ctx))
71+
p := tea.NewProgram(u, tea.WithContext(ctx), tea.WithFPS(4))
7272
u.uiCancel.Store(&cancel)
7373
defer cancel()
7474
if _, err := p.Run(); err != nil {
@@ -99,19 +99,19 @@ const (
9999

100100
func (u *ui) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
101101
if u.quitPls.Load() {
102-
return u, tea.Quit
102+
return u, tea.Batch(tea.ShowCursor, tea.Quit)
103103
}
104104
switch msg := msg.(type) {
105105
case tea.KeyMsg:
106106
switch msg.String() {
107107
case "esc":
108108
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
109109
case "ctrl+c", "q":
110-
return u, tea.Quit
110+
return u, tea.Batch(tea.ShowCursor, tea.Quit)
111111
}
112112
case tea.QuitMsg:
113113
u.quitPls.Store(true)
114-
return u, tea.Quit
114+
return u, tea.Batch(tea.ShowCursor, tea.Quit)
115115
case tea.WindowSizeMsg:
116116
u.progress.Width = msg.Width - 4
117117
if u.progress.Width > maxWidth-padding {
@@ -140,7 +140,7 @@ func (u *ui) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
140140
}
141141
}
142142
if u.quitPls.Load() {
143-
batch = append(batch, tea.Quit)
143+
batch = append(batch, tea.ShowCursor, tea.Quit)
144144
}
145145

146146
return u, tea.Batch(batch...)
@@ -164,11 +164,11 @@ func (u *ui) View() string {
164164
if ph := u.phaseTxt.Load(); ph != nil {
165165
status += ": " + *ph
166166
}
167-
status += "...\n\n"
167+
status += "...\n"
168168
res += statusStyle.Render(status)
169169
}
170170

171-
res += defaultStyle.Render("\r λ ")
171+
res += defaultStyle.Render("\n λ ")
172172
if u.showProgress {
173173
res += u.progress.View() + "\n"
174174
} else {

0 commit comments

Comments
 (0)