pub fn update_status(stdout: &mut Stdout, mut message: String) {
    // It could be useful to calculate this each time because the user might resize their terminal while it's searching through the paths.
    let max_length = size().expect("No terminal active?!").0 as usize;

    // If the message exceeds the terminal's width, turn the last 3 characters into "..." to let the user know that it continues on.
    // This will throw an out of bounds error if the terminal is less than 3 characters for whatever reason.
    // But at that point, you have a lot more things to worry about than just the program crashing.
    if message.len() > max_length {
        message.drain(max_length - 3..);
        message.push_str("...");
    }

    stdout.queue(cursor::SavePosition).unwrap();
    // I will note that it will break if the file name is long enough to go to the next line. Can't think of a fix unfortunately.
    stdout
        .queue(terminal::Clear(ClearType::CurrentLine))
        .unwrap();
    stdout.write_all(message.as_bytes()).unwrap();
    stdout.queue(cursor::RestorePosition).unwrap();
    stdout.flush().unwrap();
}
// In order for this to work, all output MUST go through this output stream and not through print! or println!
// Note: This function completely breaks when lots of long file names are involved, so it'll cap out a string based on the terminal's width.
In order for this to work, all output MUST go through this output stream and not through print. or println.
Note: This function completely breaks when lots of long file names are involved, so it'll cap out a string based on the terminal's width.
In order for this to work all output MUST go through this output stream and not through print . or println . Note : This function completely breaks when lots of long file names are involved so it ' ll cap out a string based on the terminal ' s width .
pub fn update_status(stdout: &mut Stdout, mut message: String) {
    // It could be useful to calculate this each time because the user might resize their terminal while it's searching through the paths.
    let max_length = size().expect("No terminal active?!").0 as usize;
    // If the message exceeds the terminal's width, turn the last 3 characters into "..." to let the user know that it continues on.
    // This will throw an out of bounds error if the terminal is less than 3 characters for whatever reason.
    // But at that point, you have a lot more things to worry about than just the program crashing.
    if message.len() > max_length {
        message.drain(max_length - 3..);
        message.push_str("...");
    }
    stdout.queue(cursor::SavePosition).unwrap();
    // I will note that it will break if the file name is long enough to go to the next line. Can't think of a fix unfortunately.
    stdout
        .queue(terminal::Clear(ClearType::CurrentLine))
        .unwrap();
    stdout.write_all(message.as_bytes()).unwrap();
    stdout.queue(cursor::RestorePosition).unwrap();
    stdout.flush().unwrap();
}
pub fn update_status ( stdout : & mut Stdout , mut message : String ) { // It could be useful to calculate this each time because the user might resize their terminal while it's searching through the paths. let max_length = size ( ) . expect ( " " ) . 0 as usize ; // If the message exceeds the terminal's width, turn the last 3 characters into "..." to let the user know that it continues on. // This will throw an out of bounds error if the terminal is less than 3 characters for whatever reason. // But at that point, you have a lot more things to worry about than just the program crashing. if message . len ( ) > max_length { message . drain ( max_length - 3 .. ) ; message . push_str ( " " ) ; } stdout . queue ( cursor :: SavePosition ) . unwrap ( ) ; // I will note that it will break if the file name is long enough to go to the next line. Can't think of a fix unfortunately. stdout . queue ( terminal :: Clear ( ClearType :: CurrentLine ) ) . unwrap ( ) ; stdout . write_all ( message . as_bytes ( ) ) . unwrap ( ) ; stdout . queue ( cursor :: RestorePosition ) . unwrap ( ) ; stdout . flush ( ) . unwrap ( ) ; }
In order for this to work, all output MUST go through this output stream and not through print!
In order for this to work all output MUST go through this output stream and not through print!
stdout
&mut Stdout
message
String
stdout
&mut Stdout
message
String