Skip to content

Commit 60716ea

Browse files
committed
Document the behaviour of move_cursor_{left,right,up,down} when called with a larger value than possible.
Since that behaviour (moving the cursor as far as possible) is relatively benign, only documenting this and not changing e.g. the function signature seems reasonable.
1 parent 9ccc05d commit 60716ea

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/term.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,25 +402,37 @@ impl Term {
402402
move_cursor_to(self, x, y)
403403
}
404404

405-
/// Move the cursor up `n` lines.
405+
/// Move the cursor up by `n` lines, if possible.
406+
///
407+
/// If there are less than `n` lines above the current cursor position,
408+
/// the cursor is moved to the top line of the terminal (i.e., as far up as possible).
406409
#[inline]
407410
pub fn move_cursor_up(&self, n: usize) -> io::Result<()> {
408411
move_cursor_up(self, n)
409412
}
410413

411-
/// Move the cursor down `n` lines
414+
/// Move the cursor down by `n` lines, if possible.
415+
///
416+
/// If there are less than `n` lines below the current cursor position,
417+
/// the cursor is moved to the bottom line of the terminal (i.e., as far down as possible).
412418
#[inline]
413419
pub fn move_cursor_down(&self, n: usize) -> io::Result<()> {
414420
move_cursor_down(self, n)
415421
}
416422

417-
/// Move the cursor `n` characters to the left.
423+
/// Move the cursor `n` characters to the left, if possible.
424+
///
425+
/// If there are fewer than `n` characters to the left of the current cursor position,
426+
/// the cursor is moved to the beginning of the line (i.e., as far to the left as possible).
418427
#[inline]
419428
pub fn move_cursor_left(&self, n: usize) -> io::Result<()> {
420429
move_cursor_left(self, n)
421430
}
422431

423432
/// Move the cursor `n` characters to the right.
433+
///
434+
/// If there are fewer than `n` characters to the right of the current cursor position,
435+
/// the cursor is moved to the end of the current line (i.e., as far to the right as possible).
424436
#[inline]
425437
pub fn move_cursor_right(&self, n: usize) -> io::Result<()> {
426438
move_cursor_right(self, n)

0 commit comments

Comments
 (0)