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

Calls 2

wrapRowsFunction · 0.85
DisplayValueMethod · 0.80