28 lines
437 B
Go
28 lines
437 B
Go
package tea_programe
|
|
|
|
import tea "github.com/charmbracelet/bubbletea"
|
|
|
|
type Readline struct {
|
|
Line string
|
|
}
|
|
|
|
func (m Readline) Init() tea.Cmd {
|
|
return nil
|
|
}
|
|
|
|
func (m Readline) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
switch msg := msg.(type) {
|
|
case tea.KeyMsg:
|
|
if msg.String() == "enter" {
|
|
return m, tea.Quit
|
|
}
|
|
m.Line += msg.String()
|
|
return m, nil
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
func (m Readline) View() string {
|
|
return m.Line
|
|
}
|