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

Method renderAllLines

texteditor/render.go:355–415  ·  view source on GitHub ↗

renderAllLines displays all the visible lines on the screen, after PushBounds has already been called.

()

Source from the content-addressed store, hash-verified

353// renderAllLines displays all the visible lines on the screen,
354// after PushBounds has already been called.
355func (ed *Editor) renderAllLines() {
356 ed.RenderStandardBox()
357 pc := &ed.Scene.PaintContext
358 bb := ed.renderBBox()
359 pos := ed.renderStartPos()
360 stln := -1
361 edln := -1
362 for ln := 0; ln < ed.NumLines; ln++ {
363 if ln >= len(ed.offsets) || ln >= len(ed.renders) {
364 break
365 }
366 lst := pos.Y + ed.offsets[ln]
367 led := lst + math32.Max(ed.renders[ln].BBox.Size().Y, ed.lineHeight)
368 if int(math32.Ceil(led)) < bb.Min.Y {
369 continue
370 }
371 if int(math32.Floor(lst)) > bb.Max.Y {
372 continue
373 }
374 if stln < 0 {
375 stln = ln
376 }
377 edln = ln
378 }
379
380 if stln < 0 || edln < 0 { // shouldn't happen.
381 return
382 }
383 pc.PushBounds(bb)
384
385 if ed.hasLineNumbers {
386 ed.renderLineNumbersBoxAll()
387 for ln := stln; ln <= edln; ln++ {
388 ed.renderLineNumber(ln, false) // don't re-render std fill boxes
389 }
390 }
391
392 ed.renderDepthBackground(stln, edln)
393 ed.renderHighlights(stln, edln)
394 ed.renderScopelights(stln, edln)
395 ed.renderSelect()
396 if ed.hasLineNumbers {
397 tbb := bb
398 tbb.Min.X += int(ed.LineNumberOffset)
399 pc.PushBounds(tbb)
400 }
401 for ln := stln; ln <= edln; ln++ {
402 lst := pos.Y + ed.offsets[ln]
403 lp := pos
404 lp.Y = lst
405 lp.X += ed.LineNumberOffset
406 if lp.Y+ed.fontAscent > float32(bb.Max.Y) {
407 break
408 }
409 ed.renders[ln].Render(pc, lp) // not top pos; already has baseline offset
410 }
411 if ed.hasLineNumbers {
412 pc.PopBounds()

Callers 1

RenderWidgetMethod · 0.95

Calls 15

renderBBoxMethod · 0.95
renderStartPosMethod · 0.95
renderLineNumberMethod · 0.95
renderDepthBackgroundMethod · 0.95
renderHighlightsMethod · 0.95
renderScopelightsMethod · 0.95
renderSelectMethod · 0.95
MaxFunction · 0.92
CeilFunction · 0.92
FloorFunction · 0.92
RenderStandardBoxMethod · 0.80

Tested by

no test coverage detected