Skip to content

Commit d82ef0e

Browse files
committed
Fix cursor hiding and row highlighting
- Use tea.HideCursor directly as a Cmd (was incorrectly wrapped) - Remove manual ANSI escape sequences for cursor hiding - Use explicit background color (236) instead of Reverse for row highlighting, which composes better with colored text
1 parent 476539b commit d82ef0e

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

tui.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var (
1919
styleDim = lipgloss.NewStyle().Faint(true)
2020
styleWhite = lipgloss.NewStyle().Foreground(lipgloss.Color("7"))
2121

22-
selLine = lipgloss.NewStyle().Bold(true).Reverse(true)
22+
selLine = lipgloss.NewStyle().Bold(true).Background(lipgloss.Color("236"))
2323
helpStyle = lipgloss.NewStyle().Faint(true)
2424

2525
// Palette of distinguishable ANSI-256 colors for repo/author hashing.
@@ -169,12 +169,8 @@ func (m *model) reclassify() {
169169
m.cols = computeColumns(m.items)
170170
}
171171

172-
func hideCursorCmd() tea.Msg {
173-
return tea.HideCursor()
174-
}
175-
176172
func (m model) Init() tea.Cmd {
177-
cmds := []tea.Cmd{hideCursorCmd}
173+
cmds := []tea.Cmd{tea.HideCursor}
178174
if m.loading {
179175
cmds = append(cmds, fetchDataCmd(m.org, m.limit))
180176
}
@@ -276,34 +272,31 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
276272
return m, nil
277273
}
278274

279-
const hideCursor = "\033[?25l"
280-
281275
func (m model) View() string {
282276
if m.loading {
283-
return hideCursor + "Fetching PRs...\n"
277+
return "Fetching PRs...\n"
284278
}
285279
if m.errMsg != "" {
286280
msg := strings.ReplaceAll(m.errMsg, "\n", " ")
287281
if len(msg) > 200 {
288282
msg = msg[:200] + "..."
289283
}
290-
return hideCursor + fmt.Sprintf("Error: %s\n\nPress r to retry, q to quit.\n", msg)
284+
return fmt.Sprintf("Error: %s\n\nPress r to retry, q to quit.\n", msg)
291285
}
292286

293287
if m.showHelp {
294-
return hideCursor + m.renderLegend()
288+
return m.renderLegend()
295289
}
296290

297291
vis := m.visibleItems()
298292
if len(vis) == 0 {
299293
if m.showAuthor {
300-
return hideCursor + "No open PRs authored by you. Press a to switch to reviewer mode.\n"
294+
return "No open PRs authored by you. Press a to switch to reviewer mode.\n"
301295
}
302-
return hideCursor + "No PRs match current filters. Press s/m to adjust, or a for author mode.\n"
296+
return "No PRs match current filters. Press s/m to adjust, or a for author mode.\n"
303297
}
304298

305299
var b strings.Builder
306-
b.WriteString(hideCursor)
307300
maxLines := m.height - 3 // reserve for header + help bar
308301
if maxLines <= 0 {
309302
maxLines = len(vis)

0 commit comments

Comments
 (0)