renderRegionBoxStyle renders a region in given style and background
(reg text.Region, sty *styles.Style, bg image.Image, fullWidth bool)
| 296 | |
| 297 | // renderRegionBoxStyle renders a region in given style and background |
| 298 | func (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 |
| 341 | func (ed *Editor) renderRegionToEnd(st lexer.Pos, sty *styles.Style, bg image.Image) { |
no test coverage detected