51 lines
1013 B
Go
51 lines
1013 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:
|
|
// BUG: for use in debugging, until we have command mode
|
|
if msg.String() == "ctrl+c" {
|
|
return m, tea.Quit
|
|
}
|
|
|
|
cmd = m.input.Handle(&m, msg.String())
|
|
|
|
// switch m.mode {
|
|
// case action.NormalMode,
|
|
// action.InsertMode,
|
|
// action.VisualMode,
|
|
// action.VisualBlockMode,
|
|
// action.VisualLineMode:
|
|
// cmd = m.input.Handle(&m, msg.String())
|
|
//
|
|
// // The only one left to migrate!
|
|
// case action.CommandMode:
|
|
// switch msg.String() {
|
|
// case "esc":
|
|
// m.mode = action.NormalMode
|
|
// m.command = ""
|
|
//
|
|
// default:
|
|
// m.command += msg.String()
|
|
// m.SetCommandCursor(len(m.command))
|
|
// }
|
|
// }
|
|
}
|
|
|
|
// Keep cursor in view after any update
|
|
m.AdjustScroll()
|
|
|
|
return m, cmd
|
|
}
|