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)
| 219 | // lines (e.g., from word-wrap) is different, then NeedsLayout is called |
| 220 | // and it returns true. |
| 221 | func (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 | } |
no test coverage detected