MCPcopy Create free account
hub / github.com/cogentcore/core / linesInserted

Method linesInserted

texteditor/editor.go:354–377  ·  view source on GitHub ↗

linesInserted inserts new lines of text and reformats them

(tbe *text.Edit)

Source from the content-addressed store, hash-verified

352
353// linesInserted inserts new lines of text and reformats them
354func (ed *Editor) linesInserted(tbe *text.Edit) {
355 stln := tbe.Reg.Start.Ln + 1
356 nsz := (tbe.Reg.End.Ln - tbe.Reg.Start.Ln)
357 if stln > len(ed.renders) { // invalid
358 return
359 }
360 ed.renders = slices.Insert(ed.renders, stln, make([]paint.Text, nsz)...)
361
362 // Offs
363 tmpof := make([]float32, nsz)
364 ov := float32(0)
365 if stln < len(ed.offsets) {
366 ov = ed.offsets[stln]
367 } else {
368 ov = ed.offsets[len(ed.offsets)-1]
369 }
370 for i := range tmpof {
371 tmpof[i] = ov
372 }
373 ed.offsets = slices.Insert(ed.offsets, stln, tmpof...)
374
375 ed.NumLines += nsz
376 ed.NeedsLayout()
377}
378
379// linesDeleted deletes lines of text and reformats remaining one
380func (ed *Editor) linesDeleted(tbe *text.Edit) {

Callers 1

bufferSignalMethod · 0.95

Calls 2

NeedsLayoutMethod · 0.95
InsertMethod · 0.45

Tested by

no test coverage detected