UpN moves the cursor up N lines (if possible)
(amount int)
| 245 | |
| 246 | // UpN moves the cursor up N lines (if possible) |
| 247 | func (c *Cursor) UpN(amount int) { |
| 248 | proposedY := c.Y - amount |
| 249 | if proposedY < 0 { |
| 250 | proposedY = 0 |
| 251 | } else if proposedY >= len(c.buf.lines) { |
| 252 | proposedY = len(c.buf.lines) - 1 |
| 253 | } |
| 254 | |
| 255 | bytes := c.buf.LineBytes(proposedY) |
| 256 | c.X = c.GetCharPosInLine(bytes, c.LastVisualX) |
| 257 | |
| 258 | if c.X > util.CharacterCount(bytes) || (amount < 0 && proposedY == c.Y) { |
| 259 | c.X = util.CharacterCount(bytes) |
| 260 | c.StoreVisualX() |
| 261 | } |
| 262 | |
| 263 | if c.X < 0 || (amount > 0 && proposedY == c.Y) { |
| 264 | c.X = 0 |
| 265 | c.StoreVisualX() |
| 266 | } |
| 267 | |
| 268 | c.Y = proposedY |
| 269 | } |
| 270 | |
| 271 | // DownN moves the cursor down N lines (if possible) |
| 272 | func (c *Cursor) DownN(amount int) { |
no test coverage detected