verso-reader 0.1.0

A terminal EPUB reader with vim navigation, a Kindle-style library, and Markdown highlight export
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#[derive(Debug, Clone, Copy)]
pub enum SearchDirection {
    Forward,
    Backward,
}

pub fn find_matches(text: &str, needle: &str, _dir: SearchDirection) -> Vec<usize> {
    if needle.is_empty() {
        return vec![];
    }
    let hay = text.to_lowercase();
    let nee = needle.to_lowercase();
    hay.match_indices(&nee)
        .map(|(i, _)| text[..i].chars().count())
        .collect()
}