ted 0.7.0

Core text editor functionality.
Documentation
extern crate frappe;
extern crate ropey;
extern crate unicode_segmentation;

pub mod buffer;
pub mod history;
pub mod cursor;
pub mod trie;
mod command;
mod cache;

pub use buffer::Buffer;
pub use history::History;
pub use cursor::Cursor;
pub use trie::TrieState;
pub use command::CursorCmd;
pub use cache::LineCache;

pub(crate) trait Ropey {
    fn starts_with(&self, prefix: &str) -> bool;
}

impl Ropey for ropey::Rope {
    fn starts_with(&self, prefix: &str) -> bool {
        Ropey::starts_with(&self.slice(..), prefix)
    }
}

impl<'a> Ropey for ropey::RopeSlice<'a> {
    fn starts_with(&self, prefix: &str) -> bool {
        let prefix_num_chars = prefix.chars().count();

        if self.len_chars() < prefix_num_chars {
            return false
        }

        prefix.chars()
            .enumerate()
            .take_while(|&(i, char)| self.char(i) == char)
            .map(|(i, _)| i)
            .max()
        ==
        prefix_num_chars.checked_sub(1)
    }
}