1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! ascii, color, or button views
use *;
use Write;
// pub mod button;
// pub(crate) mod interaction;
pub
// /// Replace or insert a [TextSection] at a particular index.
// pub fn replace_or_insert(text: &mut Text, index: usize, replacement: &str) {
// let len = text.sections.len();
// if len <= index {
// for _ in len.saturating_sub(1)..index {
// text.sections.push(TextSection::default());
// }
// text.sections.push(TextSection::from(replacement));
// } else {
// text.sections[index].value.replace_range(.., replacement);
// }
// }
//
pub
// /// Replace or insert a [TextSection] at a particular index with a repeating string.
// pub fn replace_or_insert_rep(text: &mut Text, index: usize, replacement: &str, repetition: usize) {
// let len = text.sections.len();
// if len <= index {
// for _ in len.saturating_sub(1)..index {
// text.sections.push(TextSection::default());
// }
// // This allocates a string, which is fine because TextSection needs one.
// text.sections
// .push(TextSection::from(replacement.repeat(repetition)));
// } else {
// text.sections[index].value.clear();
// for _ in 0..repetition {
// // This doesn't allocate a string.
// text.sections[index].value.push_str(replacement);
// }
// }
// }