diff --git a/src/highlight.rs b/src/highlight.rs new file mode 100644 index 0000000..8fac916 --- /dev/null +++ b/src/highlight.rs @@ -0,0 +1,166 @@ +use crate::util::{num_digits, spaces}; +use std::borrow::Cow; +use std::cmp::Ordering; +use tui::style::Style; +use tui::text::{Span, Spans}; + +enum Boundary { + Cursor(Style), + #[cfg(feature = "search")] + Search(Style), + End, +} + +impl Boundary { + fn cmp(&self, other: &Boundary) -> Ordering { + fn rank(b: &Boundary) -> u8 { + match b { + Boundary::Cursor(_) => 2, + #[cfg(feature = "search")] + Boundary::Search(_) => 1, + Boundary::End => 0, + } + } + rank(self).cmp(&rank(other)) + } + + fn style(&self) -> Option