RuneUnder returns the rune under the given x position
(x int)
| 601 | |
| 602 | // RuneUnder returns the rune under the given x position |
| 603 | func (c *Cursor) RuneUnder(x int) rune { |
| 604 | line := c.buf.LineBytes(c.Y) |
| 605 | if len(line) == 0 || x >= util.CharacterCount(line) { |
| 606 | return '\n' |
| 607 | } else if x < 0 { |
| 608 | x = 0 |
| 609 | } |
| 610 | i := 0 |
| 611 | for len(line) > 0 { |
| 612 | r, _, size := util.DecodeCharacter(line) |
| 613 | line = line[size:] |
| 614 | |
| 615 | if i == x { |
| 616 | return r |
| 617 | } |
| 618 | |
| 619 | i++ |
| 620 | } |
| 621 | return '\n' |
| 622 | } |
| 623 | |
| 624 | func (c *Cursor) StoreVisualX() { |
| 625 | c.LastVisualX = c.GetVisualX(false) |
no test coverage detected