From 60716ea6d02b71de2f594d5784a810ca5c649746 Mon Sep 17 00:00:00 2001 From: Mike Grunweg Date: Thu, 17 Feb 2022 14:15:22 +0100 Subject: [PATCH] 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. --- src/term.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/term.rs b/src/term.rs index ae3c2718..350a7894 100644 --- a/src/term.rs +++ b/src/term.rs @@ -402,25 +402,37 @@ impl Term { move_cursor_to(self, x, y) } - /// Move the cursor up `n` lines. + /// Move the cursor up by `n` lines, if possible. + /// + /// If there are less than `n` lines above the current cursor position, + /// the cursor is moved to the top line of the terminal (i.e., as far up as possible). #[inline] pub fn move_cursor_up(&self, n: usize) -> io::Result<()> { move_cursor_up(self, n) } - /// Move the cursor down `n` lines + /// Move the cursor down by `n` lines, if possible. + /// + /// If there are less than `n` lines below the current cursor position, + /// the cursor is moved to the bottom line of the terminal (i.e., as far down as possible). #[inline] pub fn move_cursor_down(&self, n: usize) -> io::Result<()> { move_cursor_down(self, n) } - /// Move the cursor `n` characters to the left. + /// Move the cursor `n` characters to the left, if possible. + /// + /// If there are fewer than `n` characters to the left of the current cursor position, + /// the cursor is moved to the beginning of the line (i.e., as far to the left as possible). #[inline] pub fn move_cursor_left(&self, n: usize) -> io::Result<()> { move_cursor_left(self, n) } /// Move the cursor `n` characters to the right. + /// + /// If there are fewer than `n` characters to the right of the current cursor position, + /// the cursor is moved to the end of the current line (i.e., as far to the right as possible). #[inline] pub fn move_cursor_right(&self, n: usize) -> io::Result<()> { move_cursor_right(self, n)