Maintain history; use state

This commit is contained in:
Madison Rye Progress
2025-09-13 20:58:36 -07:00
parent bef9cd248e
commit f3b3803535
7 changed files with 63 additions and 12 deletions

63
tea.go Normal file
View File

@ -0,0 +1,63 @@
package main
import tea "github.com/charmbracelet/bubbletea"
func (m model) Init() tea.Cmd {
return nil
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
// Quitting
case "ctrl+c":
return m, tea.Quit
// Movement by cell
case "up", "w":
m.state.CursorCellUp()
case "down", "s":
m.state.CursorCellDown()
case "right", "d":
m.state.CursorCellRight()
case "left", "a":
m.state.CursorCellLeft()
// Movement by section
case "ctrl+up", "ctrl+w", "shift+up", "shift+w":
m.state.CursorSectionUp()
case "ctrl+down", "ctrl+s", "shift+down", "shift+s":
m.state.CursorSectionDown()
case "ctrl+right", "ctrl+d", "shift+right", "shift+d":
m.state.CursorSectionRight()
case "ctrl+left", "ctrl+a", "shift+left", "shift+a":
m.state.CursorSectionRight()
// Marking/flagging
case " ", "enter":
m.state.Mark()
case "x":
m.state.Flag()
case "delete", "backspace":
m.state.Clear()
}
}
return m, nil
}
func (m model) View() string {
return ""
}