minimo 0.5.42

terminal ui library combining alot of things from here and there and making it slightly easier to play with
Documentation
pub use super::*;


/// Chops a string into multiple lines if it is longer than the given width
/// if the string is shorter than the width, it will be returned as is
pub fn chop( text: &str, width: usize) -> Vec<String> {
    let mut lines = Vec::new();
    let mut line = String::new();
    let mut line_width = 0;

    for word in text.split_whitespace() {
        let word_width = word.chars().count();
        if line_width + word_width + 1 > width {
            if !line.is_empty() {
                lines.push(line);
                line = String::new();
                line_width = 0;
            }
            if word_width > width {
                for (i, c) in word.chars().enumerate() {
                    if i > 0 && i % width == 0 {
                        lines.push(line);
                        line = String::new();
                    }
                    line.push(c);
                }
                lines.push(line);
                line = String::new();
                line_width = 0;
            } else {
                line = word.to_string();
                line_width = word_width;
            }
        } else {
            if !line.is_empty() {
                line.push(' ');
                line_width += 1;
            }
            line.push_str(word);
            line_width += word_width;
        }
    }
    if !line.is_empty() {
        lines.push(line);
    }
    lines
}

pub fn wrap(text: &str, width: usize) -> String {
    let mut lines = chop(text, width);
    lines.join("\n")
}

/// Fills a string to a given width with provided filler
pub fn fill(text: &str, width: usize, filler: char) -> String {
    let mut line = text.to_string();
    while line.len() < width {
        line.push(filler);
    }
    line
}

/// Centers a string to a given width with provided filler
pub fn center(text: &str, width: usize, filler: char) -> String {
    let mut line = text.to_string();
    let spaces = width - line.len();
    let left_spaces = spaces / 2;
    let right_spaces = spaces - left_spaces;
    line.insert(0, filler);
    line
}



pub fn random_char() -> char {
  random::random_char()
}

pub fn random_word(length:usize) -> String {
    random::random_ascii_string(length)
}

pub fn random_sentence(length:usize) -> String {
    let mut sentence = String::new();
    for _ in 0..length {
        sentence.push(random_char());
    }
    sentence
}