1
0

update.go 860 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package editor
  2. import (
  3. //"fmt"
  4. //"github.com/gdamore/tcell"
  5. )
  6. /*func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
  7. switch msg := msg.(type) {
  8. case tea.WindowSizeMsg:
  9. m.Width = msg.Width
  10. m.Height = msg.Height
  11. m.Viewport.SetWidth(msg.Width)
  12. h := msg.Height - 2
  13. if h < 0 {
  14. h = 0
  15. }
  16. m.Viewport.SetHeight(h)
  17. return m, nil
  18. case tea.MouseWheelMsg:
  19. return m, nil
  20. case tea.KeyPressMsg:
  21. for i := range m.Actions {
  22. action := m.Actions[i]
  23. if key.Matches(msg, action.Binding) {
  24. //fmt.Println(msg, action.Binding)
  25. cmd := action.Callback(&m, []string{})
  26. m.Viewport.SetContent(m.renderedContent())
  27. return m, cmd
  28. }
  29. }
  30. key := msg.Key()
  31. if key.Text != "" {
  32. for _, r := range key.Text {
  33. m.Buffer.Insert(r)
  34. }
  35. }
  36. m.Viewport.SetContent(m.renderedContent())
  37. return m, nil
  38. }
  39. return m, nil
  40. }
  41. */