From 67dfd7d5bb810f9c22cbab52e819f6ab645ac6ba Mon Sep 17 00:00:00 2001 From: Caleb Foust Date: Mon, 23 Oct 2023 18:57:00 -0400 Subject: [PATCH] feat: show play/pause state --- pkg/mux/screen/replay/screen.go | 15 ++++++++++----- pkg/mux/screen/replay/view.go | 6 +++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pkg/mux/screen/replay/screen.go b/pkg/mux/screen/replay/screen.go index 002d0863..57afa82e 100644 --- a/pkg/mux/screen/replay/screen.go +++ b/pkg/mux/screen/replay/screen.go @@ -563,6 +563,14 @@ func (r *Replay) setTimeDelta(delta time.Duration) { r.currentTime = newTime } +func (r *Replay) exitSelectionMode() { + r.isSelectionMode = false + termCursor := r.getTerminalCursor() + r.center(termCursor) + r.cursor = r.termToViewport(termCursor) + r.desiredCol = r.cursor.C +} + func (r *Replay) Init() tea.Cmd { return textinput.Blink } @@ -691,6 +699,7 @@ func (r *Replay) Update(msg tea.Msg) (taro.Model, tea.Cmd) { r.isPlaying = !r.isPlaying if r.isPlaying { + r.exitSelectionMode() return r.scheduleUpdate() } @@ -721,11 +730,7 @@ func (r *Replay) Update(msg tea.Msg) (taro.Model, tea.Cmd) { switch msg.Type { case ActionQuit: if r.isSelectionMode { - r.isSelectionMode = false - termCursor := r.getTerminalCursor() - r.center(termCursor) - r.cursor = r.termToViewport(termCursor) - r.desiredCol = r.cursor.C + r.exitSelectionMode() return r, nil } diff --git a/pkg/mux/screen/replay/view.go b/pkg/mux/screen/replay/view.go index 7d7d2612..571c4af8 100644 --- a/pkg/mux/screen/replay/view.go +++ b/pkg/mux/screen/replay/view.go @@ -52,12 +52,16 @@ func (r *Replay) drawStatusBar(state *tty.State) { Foreground(lipgloss.Color("0")). Background(lipgloss.Color("8")) - statusText := "TIME" + statusText := "⏵" statusBG := lipgloss.Color("6") if r.isSelectionMode { statusText = "SELECT" statusBG = lipgloss.Color("3") } + if r.isPlaying { + statusText = "⏸" + statusBG = lipgloss.Color("5") + } statusStyle := r.render.NewStyle(). Inherit(statusBarStyle).