yet another tui rfc reader
olexsmir.xyz/rfcr
1package main
2
3import (
4 "github.com/charmbracelet/bubbles/key"
5 "github.com/charmbracelet/lipgloss"
6)
7
8// todo: user should be able to change default keys
9
10const (
11 quitKey = "q"
12 toggleCachedKey = "c"
13)
14
15type keyMap struct {
16 Quit key.Binding
17 ToggleCached key.Binding
18}
19
20func (k keyMap) ShortHelp() []key.Binding {
21 return []key.Binding{k.ToggleCached, k.Quit}
22}
23
24func (k keyMap) FullHelp() [][]key.Binding {
25 return [][]key.Binding{
26 {k.ToggleCached, k.Quit},
27 }
28}
29
30var keys = keyMap{
31 Quit: key.NewBinding(
32 key.WithKeys(quitKey),
33 key.WithHelp(quitKey, "quit"),
34 ),
35 // todo: add TOC toggler
36 // todo: toggle full keymaps help with '?'
37 ToggleCached: key.NewBinding(
38 key.WithKeys(toggleCachedKey),
39 key.WithHelp(toggleCachedKey, "toggle cached"),
40 ),
41}
42
43func (m *Model) helpView() string {
44 help := m.help.View(m.keys)
45 style := lipgloss.NewStyle().
46 Width(m.help.Width).
47 Align(lipgloss.Center)
48
49 return "\n" + style.Render(help)
50}