Support window size and resize

This commit is contained in:
2026-07-22 15:44:49 +09:30
parent 4b55b93285
commit b483ea2b26
+5 -1
View File
@@ -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 + ", "