Use styled chunks of text instead of plain strings
This commit is contained in:
parent
761519c1a7
commit
9b0d80873f
8 changed files with 209 additions and 66 deletions
18
src/wrap.rs
18
src/wrap.rs
|
|
@ -75,21 +75,3 @@ pub fn wrap(text: &str, width: usize, widthdb: &mut WidthDB) -> Vec<usize> {
|
|||
|
||||
breaks
|
||||
}
|
||||
|
||||
pub fn split_at_indices<'a>(s: &'a str, indices: &[usize]) -> Vec<&'a str> {
|
||||
let mut slices = vec![];
|
||||
|
||||
let mut rest = s;
|
||||
let mut offset = 0;
|
||||
|
||||
for i in indices {
|
||||
let (left, right) = rest.split_at(i - offset);
|
||||
slices.push(left);
|
||||
rest = right;
|
||||
offset = *i;
|
||||
}
|
||||
|
||||
slices.push(rest);
|
||||
|
||||
slices
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue