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
use super::TextLine;
impl TextLine {
pub fn add_char(&mut self, text_cursor: &mut usize, c: char) {
self.insert(*text_cursor, c);
*text_cursor += 1;
}
pub fn remove_forward(&mut self, text_cursor: usize) -> bool {
let remove = text_cursor < self.len();
if remove {
self.remove(text_cursor);
}
remove
}
pub fn remove_forward_skip(&mut self, text_cursor: usize) -> bool {
let mut end_cursor = text_cursor;
self.skip_forward(&mut end_cursor);
let range = text_cursor..end_cursor;
let moved = !range.is_empty();
if moved {
self.remove_range(range);
}
moved
}
pub fn remove_back(&mut self, text_cursor: &mut usize) -> bool {
let remove = *text_cursor > 0;
if remove {
*text_cursor -= 1;
self.remove(*text_cursor);
}
remove
}
pub fn remove_back_skip(&mut self, text_cursor: &mut usize) -> bool {
let end_cursor = *text_cursor;
self.skip_back(text_cursor);
let range = *text_cursor..end_cursor;
let moved = !range.is_empty();
if moved {
self.remove_range(range);
}
moved
}
}