Skip to content

Commit

Permalink
feat: show play/pause state
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Oct 23, 2023
1 parent 2075155 commit 67dfd7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 10 additions & 5 deletions pkg/mux/screen/replay/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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()
}

Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/mux/screen/replay/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 67dfd7d

Please sign in to comment.