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

Method lineBBox

texteditor/render.go:159–183  ·  view source on GitHub ↗

lineBBox returns the bounding box for given line

(ln int)

Source from the content-addressed store, hash-verified

157
158// lineBBox returns the bounding box for given line
159func (ed *Editor) lineBBox(ln int) math32.Box2 {
160 tbb := ed.renderBBox()
161 var bb math32.Box2
162 bb.Min = ed.renderStartPos()
163 bb.Min.X += ed.LineNumberOffset
164 bb.Max = bb.Min
165 bb.Max.Y += ed.lineHeight
166 bb.Max.X = float32(tbb.Max.X)
167 if ln >= len(ed.offsets) {
168 if len(ed.offsets) > 0 {
169 ln = len(ed.offsets) - 1
170 } else {
171 return bb
172 }
173 } else {
174 bb.Min.Y += ed.offsets[ln]
175 bb.Max.Y += ed.offsets[ln]
176 }
177 if ln >= len(ed.renders) {
178 return bb
179 }
180 rp := &ed.renders[ln]
181 bb.Max = bb.Min.Add(rp.BBox.Size())
182 return bb
183}
184
185// TODO: make viewDepthColors HCT based?
186

Callers 1

firstVisibleLineMethod · 0.95

Calls 4

renderBBoxMethod · 0.95
renderStartPosMethod · 0.95
AddMethod · 0.65
SizeMethod · 0.65

Tested by

no test coverage detected