mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 06:04:18 +00:00
feat: add 'r' to refresh list and document (#624)
* feat: add 'r' to refresh list closes #416 Co-authored-by: Dieter Eickstaedt <eickstaedt@deicon.de> * feat: refresh document Closes #501 Co-authored-by: fedeztk <federicoserranexus@gmail.com> --------- Co-authored-by: Dieter Eickstaedt <eickstaedt@deicon.de> Co-authored-by: fedeztk <federicoserranexus@gmail.com>
This commit is contained in:
parent
0a7db86725
commit
b1d377237d
4 changed files with 12 additions and 8 deletions
|
@ -205,6 +205,9 @@ func (m pagerModel) update(msg tea.Msg) (pagerModel, tea.Cmd) {
|
|||
_ = clipboard.WriteAll(m.currentDocument.Body)
|
||||
cmds = append(cmds, m.showStatusMessage(pagerStatusMessage{"Copied contents", false}))
|
||||
|
||||
case "r":
|
||||
return m, loadLocalMarkdown(&m.currentDocument)
|
||||
|
||||
case "?":
|
||||
m.toggleHelp()
|
||||
if m.viewport.HighPerformanceRendering {
|
||||
|
@ -330,13 +333,12 @@ func (m pagerModel) statusBarView(b *strings.Builder) {
|
|||
}
|
||||
|
||||
func (m pagerModel) helpView() (s string) {
|
||||
edit := "e edit this document"
|
||||
|
||||
col1 := []string{
|
||||
"g/home go to top",
|
||||
"G/end go to bottom",
|
||||
"c copy contents",
|
||||
edit,
|
||||
"e edit this document",
|
||||
"r reload this document",
|
||||
"esc back to files",
|
||||
"q quit",
|
||||
}
|
||||
|
|
|
@ -888,7 +888,3 @@ func filterMarkdowns(m stashModel) tea.Cmd {
|
|||
return filteredMarkdownMsg(filtered)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *stashModel) loadDocs() tea.Cmd {
|
||||
return findLocalFiles(*m.common)
|
||||
}
|
||||
|
|
|
@ -144,6 +144,7 @@ func (m stashModel) helpView() (string, int) {
|
|||
appHelp = append(appHelp, "!", "errors")
|
||||
}
|
||||
|
||||
appHelp = append(appHelp, "r", "refresh")
|
||||
appHelp = append(appHelp, "q", "quit")
|
||||
|
||||
// Detailed help
|
||||
|
|
7
ui/ui.go
7
ui/ui.go
|
@ -164,7 +164,7 @@ func newModel(cfg Config) tea.Model {
|
|||
|
||||
func (m model) Init() tea.Cmd {
|
||||
cmds := []tea.Cmd{m.stash.spinner.Tick}
|
||||
cmds = append(cmds, m.stash.loadDocs())
|
||||
cmds = append(cmds, findLocalFiles(*m.common))
|
||||
return tea.Batch(cmds...)
|
||||
}
|
||||
|
||||
|
@ -186,6 +186,11 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
batch := m.unloadDocument()
|
||||
return m, tea.Batch(batch...)
|
||||
}
|
||||
case "r":
|
||||
if m.state == stateShowStash {
|
||||
m.stash.markdowns = nil
|
||||
return m, m.Init()
|
||||
}
|
||||
|
||||
case "q":
|
||||
var cmd tea.Cmd
|
||||
|
|
Loading…
Reference in a new issue