Support window size and resize
This commit is contained in:
@@ -73,6 +73,7 @@ func initialModel() model {
|
||||
ti.SetVirtualCursor(false)
|
||||
ti.SetStyles(textarea.DefaultStyles(true)) // default to dark styles.
|
||||
ti.Focus()
|
||||
|
||||
ti.SetHeight(20)
|
||||
ti.SetWidth(80)
|
||||
|
||||
@@ -106,6 +107,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.transientMsgs = newMsgs
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case tea.WindowSizeMsg:
|
||||
m.textarea.SetHeight(msg.Height - 5)
|
||||
m.textarea.SetWidth(msg.Width - 6)
|
||||
case tea.BackgroundColorMsg:
|
||||
// Update styling now that we know the background color.
|
||||
m.textarea.SetStyles(textarea.DefaultStyles(msg.IsDark()))
|
||||
@@ -180,7 +184,7 @@ func (m model) writeFile() error {
|
||||
|
||||
func (m model) View() tea.View {
|
||||
footer1 := "(ctrl+c to quit)"
|
||||
footer2 := ""
|
||||
footer2 := ":-)"
|
||||
|
||||
for _, message := range m.transientMsgs {
|
||||
footer2 += message.msg + ", "
|
||||
|
||||
Reference in New Issue
Block a user