x int
y int
+ // Last cursor x position
+ lastVisualX int
+
// The current selection as a range of character numbers (inclusive)
curSelection [2]int
// The original selection as a range of character numbers
c.y--
runes := []rune(c.v.buf.lines[c.y])
+ c.x = c.GetCharPosInLine(c.y, c.lastVisualX)
if c.x > len(runes) {
c.x = len(runes)
}
c.y++
runes := []rune(c.v.buf.lines[c.y])
+ c.x = c.GetCharPosInLine(c.y, c.lastVisualX)
if c.x > len(runes) {
c.x = len(runes)
}
c.Up()
c.End()
}
+ c.lastVisualX = c.GetVisualX()
}
// Right moves the cursor right one cell (if possible) or to the next line if it is at the end
c.Down()
c.Start()
}
+ c.lastVisualX = c.GetVisualX()
}
// End moves the cursor to the end of the line it is on
func (c *Cursor) End() {
c.x = Count(c.v.buf.lines[c.y])
+ c.lastVisualX = c.GetVisualX()
}
// Start moves the cursor to the start of the line it is on
func (c *Cursor) Start() {
c.x = 0
+ c.lastVisualX = c.GetVisualX()
}
// GetCharPosInLine gets the char position of a visual x y coordinate (this is necessary because tabs are 1 char but 4 visual spaces)