charEndPos returns the ending (bottom right) render coords for the given position -- makes no attempt to rationalize that pos (i.e., if not in visible range, position will be out of range too)
(pos lexer.Pos)
| 130 | // position -- makes no attempt to rationalize that pos (i.e., if not in |
| 131 | // visible range, position will be out of range too) |
| 132 | func (ed *Editor) charEndPos(pos lexer.Pos) math32.Vector2 { |
| 133 | spos := ed.renderStartPos() |
| 134 | pos.Ln = min(pos.Ln, ed.NumLines-1) |
| 135 | if pos.Ln < 0 { |
| 136 | spos.Y += float32(ed.linesSize.Y) |
| 137 | spos.X += ed.LineNumberOffset |
| 138 | return spos |
| 139 | } |
| 140 | if pos.Ln >= len(ed.offsets) { |
| 141 | spos.Y += float32(ed.linesSize.Y) |
| 142 | spos.X += ed.LineNumberOffset |
| 143 | return spos |
| 144 | } |
| 145 | spos.Y += ed.offsets[pos.Ln] |
| 146 | spos.X += ed.LineNumberOffset |
| 147 | r := ed.renders[pos.Ln] |
| 148 | if len(r.Spans) > 0 { |
| 149 | // note: Y from rune pos is baseline |
| 150 | rrp, _, _, _ := r.RuneEndPos(pos.Ch) |
| 151 | spos.X += rrp.X |
| 152 | spos.Y += rrp.Y - r.Spans[0].RelPos.Y // relative |
| 153 | } |
| 154 | spos.Y += ed.lineHeight // end of that line |
| 155 | return spos |
| 156 | } |
| 157 | |
| 158 | // lineBBox returns the bounding box for given line |
| 159 | func (ed *Editor) lineBBox(ln int) math32.Box2 { |
no test coverage detected