use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;
#[inline(always)]
pub fn measure_text_width(s: &str) -> usize {
s.width()
}
pub fn split_line_by_delimiter(line: &str, delimiter: char) -> Vec<String> {
line.split(delimiter)
.map(ToString::to_string)
.collect::<Vec<String>>()
}
pub fn split_long_word(allowed_width: usize, word: &str) -> (String, String) {
let mut current_width = 0;
let mut parts = String::new();
let mut graphmes = word.graphemes(true).peekable();
while let Some(c) = graphmes.peek() {
if (current_width + c.width()) > allowed_width {
break;
}
let c = graphmes.next().unwrap();
let character_width = c.width();
current_width += character_width;
parts.push_str(c);
}
let remaining = graphmes.collect();
(parts, remaining)
}