mirror of
https://github.com/charmbracelet/gum
synced 2024-05-23 16:42:22 +02:00
32 lines
718 B
Go
32 lines
718 B
Go
|
package write
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
|
||
|
"github.com/charmbracelet/bubbles/textarea"
|
||
|
tea "github.com/charmbracelet/bubbletea"
|
||
|
"github.com/charmbracelet/lipgloss"
|
||
|
)
|
||
|
|
||
|
// Run provides a shell script interface for the text area bubble.
|
||
|
// https://github.com/charmbracelet/bubbles/textarea
|
||
|
func (o Options) Run() {
|
||
|
a := textarea.New()
|
||
|
a.Focus()
|
||
|
|
||
|
a.Prompt = o.Prompt
|
||
|
a.Placeholder = o.Placeholder
|
||
|
a.ShowLineNumbers = o.ShowLineNumbers
|
||
|
if !o.ShowCursorLine {
|
||
|
a.FocusedStyle.CursorLine = lipgloss.NewStyle()
|
||
|
a.BlurredStyle.CursorLine = lipgloss.NewStyle()
|
||
|
}
|
||
|
|
||
|
a.SetWidth(o.Width)
|
||
|
|
||
|
p := tea.NewProgram(model{a}, tea.WithOutput(os.Stderr))
|
||
|
m, _ := p.StartReturningModel()
|
||
|
fmt.Println(m.(model).textarea.Value())
|
||
|
}
|