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

Method charStartPos

texteditor/render.go:91–114  ·  view source on GitHub ↗

charStartPos returns the starting (top left) 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)

Source from the content-addressed store, hash-verified

89// position -- makes no attempt to rationalize that pos (i.e., if not in
90// visible range, position will be out of range too)
91func (ed *Editor) charStartPos(pos lexer.Pos) math32.Vector2 {
92 spos := ed.renderStartPos()
93 spos.X += ed.LineNumberOffset
94 if pos.Ln >= len(ed.offsets) {
95 if len(ed.offsets) > 0 {
96 pos.Ln = len(ed.offsets) - 1
97 } else {
98 return spos
99 }
100 } else {
101 spos.Y += ed.offsets[pos.Ln]
102 }
103 if pos.Ln >= len(ed.renders) {
104 return spos
105 }
106 rp := &ed.renders[pos.Ln]
107 if len(rp.Spans) > 0 {
108 // note: Y from rune pos is baseline
109 rrp, _, _, _ := ed.renders[pos.Ln].RuneRelPos(pos.Ch)
110 spos.X += rrp.X
111 spos.Y += rrp.Y - ed.renders[pos.Ln].Spans[0].RelPos.Y // relative
112 }
113 return spos
114}
115
116// charStartPosVisible returns the starting pos for given position
117// that is currently visible, based on bounding boxes.

Callers 12

offerCompleteMethod · 0.95
LookupMethod · 0.95
offerCorrectMethod · 0.95
charStartPosVisibleMethod · 0.95
renderDepthBackgroundMethod · 0.95
renderLineNumberMethod · 0.95
firstVisibleLineMethod · 0.95
lastVisibleLineMethod · 0.95
PixelToCursorMethod · 0.95
linkAtMethod · 0.95
cursorBBoxMethod · 0.95
renderCursorMethod · 0.95

Calls 2

renderStartPosMethod · 0.95
RuneRelPosMethod · 0.45

Tested by

no test coverage detected