Skip to content

Commit 556cd98

Browse files
philpennockdlvhdr
authored andcommitted
feat: add redraw builtin key-binding, unbound
When opening a browser, GNOME things have a tendency to spew messages to stderr which corrupts the gh-dash display. Nothing made it possible to get a display which then restored the output, the entry area, etc. A screen redraw command is useful for "something has happened, it shouldn't have, we know it shouldn't have, but that's life, go ahead and redraw please". This has traditionally been bound to Ctrl-L; but unlike #565 it is not bound in this commit, leaving folks to opt-in via local configuration. The bubbletea internals appear to have a `repaintMsg{}` but I couldn't figure out how to just send that. The lightest-weight option I found was to batch together `ExitAltScreen` and `EnterAltScreen`. This causes a very brief flicker which ... is also traditional and I'm accepting it as "shows positive feedback that the keystroke was acted upon" rather than a bug. With this, `gh-dash` can be safely used to `o`pen issues in a browser without then needing to quit and restart, because it offers a recovery mechanism.
1 parent 7bb2f79 commit 556cd98

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

ui/keys/keys.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type KeyMap struct {
2020
OpenGithub key.Binding
2121
Refresh key.Binding
2222
RefreshAll key.Binding
23+
Redraw key.Binding
2324
PageDown key.Binding
2425
PageUp key.Binding
2526
NextSection key.Binding
@@ -247,6 +248,8 @@ func rebindUniversal(universal []config.Keybinding) error {
247248
key = &Keys.Refresh
248249
case "refreshAll":
249250
key = &Keys.RefreshAll
251+
case "redraw":
252+
key = &Keys.Redraw
250253
case "pageDown":
251254
key = &Keys.PageDown
252255
case "pageUp":

ui/ui.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
246246
m.setCurrentViewSections(newSections)
247247
cmds = append(cmds, fetchSectionsCmds)
248248

249+
case key.Matches(msg, m.keys.Redraw):
250+
// can't find a way to just ask to send bubbletea's internal repaintMsg{},
251+
// so this seems like the lightest-weight alternative
252+
return m, tea.Batch(tea.ExitAltScreen, tea.EnterAltScreen)
253+
249254
case key.Matches(msg, m.keys.Search):
250255
if currSection != nil {
251256
cmd = currSection.SetIsSearching(true)

0 commit comments

Comments
 (0)