MCPcopy
hub / github.com/micro-editor/micro / GetVisualX

Method GetVisualX

internal/buffer/cursor.go:83–97  ·  view source on GitHub ↗

GetVisualX returns the x value of the cursor in visual spaces

(wrap bool)

Source from the content-addressed store, hash-verified

81
82// GetVisualX returns the x value of the cursor in visual spaces
83func (c *Cursor) GetVisualX(wrap bool) int {
84 if wrap && c.buf.GetVisualX != nil {
85 return c.buf.GetVisualX(c.Loc)
86 }
87
88 if c.X <= 0 {
89 c.X = 0
90 return 0
91 }
92
93 bytes := c.buf.LineBytes(c.Y)
94 tabsize := int(c.buf.Settings["tabsize"].(float64))
95
96 return util.StringWidth(bytes, c.X, tabsize)
97}
98
99// GetCharPosInLine gets the char position of a visual x y
100// coordinate (this is necessary because tabs are 1 char but

Callers 5

StoreVisualXMethod · 0.95
SetBufferMethod · 0.80
updateDisplayInfoMethod · 0.80
RelocateMethod · 0.80
InsertTabMethod · 0.80

Calls 2

StringWidthFunction · 0.92
LineBytesMethod · 0.65

Tested by

no test coverage detected