linesInserted inserts new lines of text and reformats them
(tbe *text.Edit)
| 352 | |
| 353 | // linesInserted inserts new lines of text and reformats them |
| 354 | func (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 |
| 380 | func (ed *Editor) linesDeleted(tbe *text.Edit) { |
no test coverage detected