Skip to content
Myr

fix(split-editors): resize issue

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Maas Lalani · committed by Maas Lalani · parent 4e9a56f · Browse files · 1 file+5 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−2 removed

  • other:+5 added−2 removed

1 file+5 added−2 removed

modified:examples/split-editors/main.go+5 added-2 removed
13 unmodified lines
14const (15 initialInputs = 216 maxInputs = 617 minInputs = 118 helpHeight = 519)2021var (22 cursorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("212"))
21 unmodified lines
44}4546func newTextarea() textarea.Model {47 t := textarea.New()47 t.SetHeight(20)48 t.Prompt = ""49 t.Placeholder = "Type something"50 t.ShowLineNumbers = true51 t.Cursor.Style = cursorStyle
10 unmodified lines
62}6364type model struct {65 width int66 height int67 keymap keymap68 help help.Model69 inputs []textarea.Model70 focus int
73 unmodified lines
144 m.focus = len(m.inputs) - 1145 }146 }147 case tea.WindowSizeMsg:148 m.height = msg.Height149 m.width = msg.Width150 }151152 m.updateKeybindings()
11 unmodified lines
164165func (m *model) sizeInputs() {166 for i := range m.inputs {167 m.inputs[i].SetWidth(m.width / len(m.inputs))168 m.inputs[i].SetHeight(m.height - helpHeight)169 }170}171172func (m *model) updateKeybindings() {
18 unmodified lines
191 return lipgloss.JoinHorizontal(lipgloss.Top, views...) + "\n\n" + help192}193194func main() {192 if err := tea.NewProgram(newModel()).Start(); err != nil {195 if err := tea.NewProgram(newModel(), tea.WithAltScreen()).Start(); err != nil {196 fmt.Println("Error while running program:", err)197 os.Exit(1)198 }199}