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

Method RuneUnder

internal/buffer/cursor.go:603–622  ·  view source on GitHub ↗

RuneUnder returns the rune under the given x position

(x int)

Source from the content-addressed store, hash-verified

601
602// RuneUnder returns the rune under the given x position
603func (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
624func (c *Cursor) StoreVisualX() {
625 c.LastVisualX = c.GetVisualX(false)

Callers 10

StartOfTextMethod · 0.95
IsStartOfTextMethod · 0.95
SelectWordMethod · 0.95
AddWordToSelectionMethod · 0.95
WordRightMethod · 0.95
WordLeftMethod · 0.95
SubWordRightMethod · 0.95
SubWordLeftMethod · 0.95
RelocateMethod · 0.80
AutocompleteMethod · 0.80

Calls 3

CharacterCountFunction · 0.92
DecodeCharacterFunction · 0.92
LineBytesMethod · 0.65

Tested by

no test coverage detected