mirror of
https://github.com/charmbracelet/gum
synced 2024-05-23 16:42:22 +02:00
02e925ea57
This commit uses the embedded style struct for styling in all components. The most notable example is `gum write` where there are many styles that are used and composed for each component of the command.
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package write
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/charmbracelet/bubbles/textarea"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
)
|
|
|
|
// 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
|
|
|
|
style := textarea.Style{
|
|
Base: o.BaseStyle.ToLipgloss(),
|
|
Placeholder: o.PlaceholderStyle.ToLipgloss(),
|
|
CursorLine: o.CursorLineStyle.ToLipgloss(),
|
|
CursorLineNumber: o.CursorLineNumberStyle.ToLipgloss(),
|
|
EndOfBuffer: o.EndOfBufferStyle.ToLipgloss(),
|
|
LineNumber: o.LineNumberStyle.ToLipgloss(),
|
|
Prompt: o.PromptStyle.ToLipgloss(),
|
|
}
|
|
|
|
a.BlurredStyle = style
|
|
a.FocusedStyle = style
|
|
a.Cursor.Style = o.CursorStyle.ToLipgloss()
|
|
|
|
a.SetWidth(o.Width)
|
|
a.SetHeight(o.Height)
|
|
a.SetValue(o.Value)
|
|
|
|
p := tea.NewProgram(model{textarea: a}, tea.WithOutput(os.Stderr))
|
|
m, _ := p.StartReturningModel()
|
|
fmt.Println(m.(model).textarea.Value())
|
|
}
|