Function gstuff::status_line

source ·
pub fn status_line(file: &str, line: u32, status: String)
Expand description

Clears the line to the right, prints the given text, moves the caret all the way to the left.

Will only work if the terminal isatty.

Repeating this call will keep updating the same line (effectively a status line).

And it’s kind of compatible with the normal stdout logging because the latter will overwrite the status line.

One can also call status_line_clear() to clear the line before the normal output comes forth in order to avoid leaving stray characters on the screen.

Skips spewing the output if the hash of the generated status line is identical to the existing one.

The function is intended to be used with a macros, for example:

use gstuff::{status_line, ISATTY};
macro_rules! status_line {($($args: tt)+) => {if *ISATTY {
  status_line (file!(), line!(), fomat! ($($args)+))}}}