Skip to main content

UP_SCRL

Constant UP_SCRL 

Source
pub const UP_SCRL: &'static str;
Expand description

Moves cursor one line up, ‘scrolling’ if needed.

Equivalent to ESC M, known as RI.

THIS MAY NOT DO WHAT YOU EXPECT read precise description below:

Moves cursor one line up. If the cursor is already on top of the screen, insert one line at the top of the screen. The line at the bottom of the screen is discarded.

§Example

use std::io::Write;
use termal_core::{codes, raw::Terminal};

println!("{}", codes::CLEAR);

for i in 0..100 {
    print!("\n{i}");
}

// Move to the second line on screen.
let mut buf = codes::MOVE_HOME.to_string();
buf += codes::move_down!(1);
// Move up, scrolling is not necesary so it is just move up
buf += codes::UP_SCRL;
// Move up, cursor is already on top of the screen, so empty line is
// inserted. Line at the bottom of the screen is discarded.
buf += codes::UP_SCRL;

print!("{buf}");

_ = Terminal::stdio().flush();

// Wait for enter. Screenshot is taken before enter is pressed.
_ = Terminal::stdio().read();

§Result in terminal