25 lines
386 B
Go
25 lines
386 B
Go
package editor
|
|
|
|
import (
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
)
|
|
|
|
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
var cmd tea.Cmd
|
|
|
|
switch msg := msg.(type) {
|
|
|
|
case tea.WindowSizeMsg:
|
|
m.win_h = msg.Height
|
|
m.win_w = msg.Width
|
|
|
|
case tea.KeyMsg:
|
|
cmd = m.input.Handle(&m, msg.String())
|
|
}
|
|
|
|
// Keep cursor in view after any update
|
|
m.AdjustScroll()
|
|
|
|
return m, cmd
|
|
}
|