@@ -143,7 +143,7 @@ impl Term {
143
143
term
144
144
}
145
145
146
- /// Return a new unbuffered terminal
146
+ /// Return a new unbuffered terminal.
147
147
#[ inline]
148
148
pub fn stdout ( ) -> Term {
149
149
Term :: with_inner ( TermInner {
@@ -152,7 +152,7 @@ impl Term {
152
152
} )
153
153
}
154
154
155
- /// Return a new unbuffered terminal to stderr
155
+ /// Return a new unbuffered terminal to stderr.
156
156
#[ inline]
157
157
pub fn stderr ( ) -> Term {
158
158
Term :: with_inner ( TermInner {
@@ -161,23 +161,23 @@ impl Term {
161
161
} )
162
162
}
163
163
164
- /// Return a new buffered terminal
164
+ /// Return a new buffered terminal.
165
165
pub fn buffered_stdout ( ) -> Term {
166
166
Term :: with_inner ( TermInner {
167
167
target : TermTarget :: Stdout ,
168
168
buffer : Some ( Mutex :: new ( vec ! [ ] ) ) ,
169
169
} )
170
170
}
171
171
172
- /// Return a new buffered terminal to stderr
172
+ /// Return a new buffered terminal to stderr.
173
173
pub fn buffered_stderr ( ) -> Term {
174
174
Term :: with_inner ( TermInner {
175
175
target : TermTarget :: Stderr ,
176
176
buffer : Some ( Mutex :: new ( vec ! [ ] ) ) ,
177
177
} )
178
178
}
179
179
180
- /// Return a terminal for the given Read/Write pair styled- like Stderr .
180
+ /// Return a terminal for the given Read/Write pair styled like stderr .
181
181
#[ cfg( unix) ]
182
182
pub fn read_write_pair < R , W > ( read : R , write : W ) -> Term
183
183
where
@@ -204,7 +204,7 @@ impl Term {
204
204
} )
205
205
}
206
206
207
- /// Return the style for this terminal
207
+ /// Return the style for this terminal.
208
208
#[ inline]
209
209
pub fn style ( & self ) -> Style {
210
210
match self . inner . target {
@@ -215,7 +215,7 @@ impl Term {
215
215
}
216
216
}
217
217
218
- /// Return the target of this terminal
218
+ /// Return the target of this terminal.
219
219
#[ inline]
220
220
pub fn target ( & self ) -> TermTarget {
221
221
self . inner . target . clone ( )
@@ -396,48 +396,59 @@ impl Term {
396
396
terminal_size ( self )
397
397
}
398
398
399
- /// Move the cursor to row `x` and column `y`.
399
+ /// Move the cursor to row `x` and column `y`. Values are 0-based.
400
400
#[ inline]
401
401
pub fn move_cursor_to ( & self , x : usize , y : usize ) -> io:: Result < ( ) > {
402
402
move_cursor_to ( self , x, y)
403
403
}
404
404
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).
406
409
#[ inline]
407
410
pub fn move_cursor_up ( & self , n : usize ) -> io:: Result < ( ) > {
408
411
move_cursor_up ( self , n)
409
412
}
410
413
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).
412
418
#[ inline]
413
419
pub fn move_cursor_down ( & self , n : usize ) -> io:: Result < ( ) > {
414
420
move_cursor_down ( self , n)
415
421
}
416
422
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).
418
427
#[ inline]
419
428
pub fn move_cursor_left ( & self , n : usize ) -> io:: Result < ( ) > {
420
429
move_cursor_left ( self , n)
421
430
}
422
431
423
- /// Move the cursor `n` characters to the right
432
+ /// 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).
424
436
#[ inline]
425
437
pub fn move_cursor_right ( & self , n : usize ) -> io:: Result < ( ) > {
426
438
move_cursor_right ( self , n)
427
439
}
428
440
429
441
/// Clear the current line.
430
442
///
431
- /// This positions the cursor at the beginning of the current line.
443
+ /// Position the cursor at the beginning of the current line.
432
444
#[ inline]
433
445
pub fn clear_line ( & self ) -> io:: Result < ( ) > {
434
446
clear_line ( self )
435
447
}
436
448
437
449
/// Clear the last `n` lines before the current line.
438
450
///
439
- /// This positions the cursor at the beginning of the first line
440
- /// that was cleared.
451
+ /// Position the cursor at the beginning of the first line that was cleared.
441
452
pub fn clear_last_lines ( & self , n : usize ) -> io:: Result < ( ) > {
442
453
self . move_cursor_up ( n) ?;
443
454
for _ in 0 ..n {
@@ -449,38 +460,41 @@ impl Term {
449
460
}
450
461
451
462
/// Clear the entire screen.
463
+ ///
464
+ /// Move the cursor to the upper left corner of the screen.
452
465
#[ inline]
453
466
pub fn clear_screen ( & self ) -> io:: Result < ( ) > {
454
467
clear_screen ( self )
455
468
}
456
469
457
- /// Clear the entire screen.
470
+ /// Clear everything from the current cursor position to the end of the screen.
471
+ /// The cursor stays in its position.
458
472
#[ inline]
459
473
pub fn clear_to_end_of_screen ( & self ) -> io:: Result < ( ) > {
460
474
clear_to_end_of_screen ( self )
461
475
}
462
476
463
- /// Clear the last `n` chars of the current line.
477
+ /// Clear the last `n` characters of the current line.
464
478
#[ inline]
465
479
pub fn clear_chars ( & self , n : usize ) -> io:: Result < ( ) > {
466
480
clear_chars ( self , n)
467
481
}
468
482
469
- /// Set the terminal title
483
+ /// Set the terminal title.
470
484
pub fn set_title < T : Display > ( & self , title : T ) {
471
485
if !self . is_tty {
472
486
return ;
473
487
}
474
488
set_title ( title) ;
475
489
}
476
490
477
- /// Make the cursor visible again
491
+ /// Make the cursor visible again.
478
492
#[ inline]
479
493
pub fn show_cursor ( & self ) -> io:: Result < ( ) > {
480
494
show_cursor ( self )
481
495
}
482
496
483
- /// Hide the cursor
497
+ /// Hide the cursor.
484
498
#[ inline]
485
499
pub fn hide_cursor ( & self ) -> io:: Result < ( ) > {
486
500
hide_cursor ( self )
0 commit comments