mirror of
https://github.com/charmbracelet/gum
synced 2024-06-19 22:15:09 +02:00
25 lines
541 B
Go
25 lines
541 B
Go
|
package write
|
||
|
|
||
|
import (
|
||
|
"github.com/charmbracelet/bubbles/textarea"
|
||
|
tea "github.com/charmbracelet/bubbletea"
|
||
|
)
|
||
|
|
||
|
type model struct{ textarea textarea.Model }
|
||
|
|
||
|
func (m model) Init() tea.Cmd { return textarea.Blink }
|
||
|
func (m model) View() string { return m.textarea.View() }
|
||
|
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||
|
switch msg := msg.(type) {
|
||
|
case tea.KeyMsg:
|
||
|
switch msg.Type {
|
||
|
case tea.KeyEscape, tea.KeyCtrlC:
|
||
|
return m, tea.Quit
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var cmd tea.Cmd
|
||
|
m.textarea, cmd = m.textarea.Update(msg)
|
||
|
return m, cmd
|
||
|
}
|