A beautiful TUI for browsing files and reading markdown/code: - Two-pane layout with file tree and content viewer - Markdown rendering via Glamour - Syntax highlighting via Chroma - Auto-detects light/dark terminal theme - Arrow key navigation, Esc to go back - Page Up/Down, Home/End for scrolling Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
71 lines
1.1 KiB
Go
71 lines
1.1 KiB
Go
package main
|
|
|
|
import "github.com/charmbracelet/bubbletea"
|
|
|
|
// Key represents a key binding
|
|
type Key struct {
|
|
Keys []string
|
|
Help string
|
|
}
|
|
|
|
func (k Key) Matches(msg tea.KeyMsg) bool {
|
|
for _, key := range k.Keys {
|
|
if msg.String() == key {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// Keybindings for the application
|
|
var (
|
|
keyUp = Key{
|
|
Keys: []string{"up"},
|
|
Help: "move up",
|
|
}
|
|
keyDown = Key{
|
|
Keys: []string{"down"},
|
|
Help: "move down",
|
|
}
|
|
keyLeft = Key{
|
|
Keys: []string{"left"},
|
|
Help: "collapse/parent",
|
|
}
|
|
keyRight = Key{
|
|
Keys: []string{"right"},
|
|
Help: "expand/open",
|
|
}
|
|
keyEnter = Key{
|
|
Keys: []string{"enter"},
|
|
Help: "open/toggle",
|
|
}
|
|
keyEscape = Key{
|
|
Keys: []string{"esc"},
|
|
Help: "back to files",
|
|
}
|
|
keyPageDown = Key{
|
|
Keys: []string{"pgdown"},
|
|
Help: "page down",
|
|
}
|
|
keyPageUp = Key{
|
|
Keys: []string{"pgup"},
|
|
Help: "page up",
|
|
}
|
|
keyHome = Key{
|
|
Keys: []string{"home"},
|
|
Help: "go to top",
|
|
}
|
|
keyEnd = Key{
|
|
Keys: []string{"end"},
|
|
Help: "go to bottom",
|
|
}
|
|
keyHelp = Key{
|
|
Keys: []string{"?"},
|
|
Help: "toggle help",
|
|
}
|
|
keyQuit = Key{
|
|
Keys: []string{"q", "ctrl+c"},
|
|
Help: "quit",
|
|
}
|
|
)
|