Skip to main content

cut

Function cut 

Source
pub fn cut(text: &str, w: usize, widths: &CellWidths) -> String
Expand description

text in at most w cells, measured with widths: cut, its last cell a …, if it is longer. A wide character that would reach that cell goes too.

use shuyi_assets::font::CellWidths;
use shuyi_ui::frame::draw::cut;
let narrow = &CellWidths::NARROW;
assert_eq!(cut("Backspace", 5, narrow), "Back…");
assert_eq!(cut("Enter", 5, narrow), "Enter");
assert_eq!(cut("あいう", 5, &CellWidths::wide(['あ', 'い', 'う'])), "あい…");