MCPcopy
hub / github.com/pterm/pterm / updateArea

Method updateArea

interactive_textinput_printer.go:274–306  ·  view source on GitHub ↗
(area *cursor.Area)

Source from the content-addressed store, hash-verified

272}
273
274func (p InteractiveTextInputPrinter) updateArea(area *cursor.Area) string {
275 if !p.MultiLine {
276 p.cursorYPos = 0
277 }
278 areaText := p.text
279
280 for i, s := range p.input {
281 if i < len(p.input)-1 {
282 areaText += s + "\n"
283 } else {
284 areaText += s
285 }
286 }
287
288 if p.Mask != "" {
289 areaText = p.text + strings.Repeat(p.Mask, internal.GetStringMaxWidth(areaText)-internal.GetStringMaxWidth(p.text))
290 }
291
292 if p.cursorXPos+internal.GetStringMaxWidth(p.input[p.cursorYPos]) < 1 {
293 p.cursorXPos = -internal.GetStringMaxWidth(p.input[p.cursorYPos])
294 }
295
296 area.Update(areaText)
297 area.Top()
298 area.Down(p.cursorYPos + 1)
299 area.StartOfLine()
300 if p.MultiLine {
301 cursor.Right(internal.GetStringMaxWidth(p.input[p.cursorYPos]) + p.cursorXPos)
302 } else {
303 cursor.Right(internal.GetStringMaxWidth(areaText) + p.cursorXPos)
304 }
305 return areaText
306}

Callers 1

ShowMethod · 0.95

Calls 2

GetStringMaxWidthFunction · 0.92
UpdateMethod · 0.80

Tested by

no test coverage detected