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

Method renderRegionBoxStyle

texteditor/render.go:298–338  ·  view source on GitHub ↗

renderRegionBoxStyle renders a region in given style and background

(reg text.Region, sty *styles.Style, bg image.Image, fullWidth bool)

Source from the content-addressed store, hash-verified

296
297// renderRegionBoxStyle renders a region in given style and background
298func (ed *Editor) renderRegionBoxStyle(reg text.Region, sty *styles.Style, bg image.Image, fullWidth bool) {
299 st := reg.Start
300 end := reg.End
301 spos := ed.charStartPosVisible(st)
302 epos := ed.charStartPosVisible(end)
303 epos.Y += ed.lineHeight
304 bb := ed.renderBBox()
305 stx := math32.Ceil(float32(bb.Min.X) + ed.LineNumberOffset)
306 if int(math32.Ceil(epos.Y)) < bb.Min.Y || int(math32.Floor(spos.Y)) > bb.Max.Y {
307 return
308 }
309 ex := float32(bb.Max.X)
310 if fullWidth {
311 epos.X = ex
312 }
313
314 pc := &ed.Scene.PaintContext
315 stsi, _, _ := ed.wrappedLineNumber(st)
316 edsi, _, _ := ed.wrappedLineNumber(end)
317 if st.Ln == end.Ln && stsi == edsi {
318 pc.FillBox(spos, epos.Sub(spos), bg) // same line, done
319 return
320 }
321 // on diff lines: fill to end of stln
322 seb := spos
323 seb.Y += ed.lineHeight
324 seb.X = ex
325 pc.FillBox(spos, seb.Sub(spos), bg)
326 sfb := seb
327 sfb.X = stx
328 if sfb.Y < epos.Y { // has some full box
329 efb := epos
330 efb.Y -= ed.lineHeight
331 efb.X = ex
332 pc.FillBox(sfb, efb.Sub(sfb), bg)
333 }
334 sed := epos
335 sed.Y -= ed.lineHeight
336 sed.X = stx
337 pc.FillBox(sed, epos.Sub(sed), bg)
338}
339
340// renderRegionToEnd renders a region in given style and background, to end of line from start
341func (ed *Editor) renderRegionToEnd(st lexer.Pos, sty *styles.Style, bg image.Image) {

Callers 2

renderDepthBackgroundMethod · 0.95
renderRegionBoxMethod · 0.95

Calls 7

charStartPosVisibleMethod · 0.95
renderBBoxMethod · 0.95
wrappedLineNumberMethod · 0.95
CeilFunction · 0.92
FloorFunction · 0.92
FillBoxMethod · 0.80
SubMethod · 0.45

Tested by

no test coverage detected