MCPcopy Create free account
hub / github.com/codehamr/codehamr / visualPromptLines

Method visualPromptLines

internal/tui/render.go:165–178  ·  view source on GitHub ↗

visualPromptLines counts the *visual* rows the textarea needs (a line that wraps to three screen rows wants a three-row textarea), via wrapRows which mirrors bubbles/textarea's wrap() (see there for the grapheme-cluster caveat). Reads DisplayValue so a chip counts as one line, not the hundreds its e

()

Source from the content-addressed store, hash-verified

163 m.ta.SetHeight(cap)
164 }
165}
166
167// visualPromptLines counts the *visual* rows the textarea needs (a line that
168// wraps to three screen rows wants a three-row textarea), via wrapRows which
169// mirrors bubbles/textarea's wrap() (see there for the grapheme-cluster
170// caveat). Reads DisplayValue so a chip counts as one line, not the hundreds
171// its expanded content would.
172func (m *Model) visualPromptLines() int {
173 w := m.width - 4 // -2 for ta.SetWidth offset, -2 for "▌ " prompt
174 if w < 1 {
175 return 1
176 }
177 total := 0
178 for line := range strings.SplitSeq(m.ta.DisplayValue(), "\n") {
179 total += wrapRows(line, w)
180 }
181 if total < 1 {

Calls 2

wrapRowsFunction · 0.85
DisplayValueMethod · 0.80