GetVisualX returns the x value of the cursor in visual spaces
(wrap bool)
| 81 | |
| 82 | // GetVisualX returns the x value of the cursor in visual spaces |
| 83 | func (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 |
no test coverage detected