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

Method layoutLine

texteditor/layout.go:221–254  ·  view source on GitHub ↗

layoutLine generates render of given line (including highlighting). If the line with exceeds the current maximum, or the number of effective lines (e.g., from word-wrap) is different, then NeedsLayout is called and it returns true.

(ln int)

Source from the content-addressed store, hash-verified

219// lines (e.g., from word-wrap) is different, then NeedsLayout is called
220// and it returns true.
221func (ed *Editor) layoutLine(ln int) bool {
222 if ed.Buffer == nil || ed.Buffer.NumLines() == 0 || ln >= len(ed.renders) {
223 return false
224 }
225 sty := &ed.Styles
226 fst := sty.FontRender()
227 fst.Background = nil
228 mxwd := float32(ed.linesSize.X)
229 needLay := false
230
231 rn := &ed.renders[ln]
232 curspans := len(rn.Spans)
233 ed.Buffer.Lock()
234 rn.SetHTMLPre(ed.Buffer.Markup[ln], fst, &sty.Text, &sty.UnitContext, ed.textStyleProperties())
235 ed.Buffer.Unlock()
236 rn.Layout(&sty.Text, sty.FontRender(), &sty.UnitContext, ed.lineLayoutSize)
237 if !ed.hasLinks && len(rn.Links) > 0 {
238 ed.hasLinks = true
239 }
240 nwspans := len(rn.Spans)
241 if nwspans != curspans && (nwspans > 1 || curspans > 1) {
242 needLay = true
243 }
244 if rn.BBox.Size().X > mxwd {
245 needLay = true
246 }
247
248 if needLay {
249 ed.NeedsLayout()
250 } else {
251 ed.NeedsRender()
252 }
253 return needLay
254}

Callers 1

bufferSignalMethod · 0.95

Calls 10

textStylePropertiesMethod · 0.95
NeedsLayoutMethod · 0.95
NumLinesMethod · 0.80
FontRenderMethod · 0.80
SetHTMLPreMethod · 0.80
LayoutMethod · 0.80
NeedsRenderMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
SizeMethod · 0.65

Tested by

no test coverage detected