From 49807ec9fed50b6a33b9dab3fe3a82c5f062d9b0 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Fri, 12 Mar 2021 17:46:31 -0500 Subject: [PATCH] Naive number highlighting --- src/row.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/row.rs b/src/row.rs index 9a4b70e..c9c0ca0 100644 --- a/src/row.rs +++ b/src/row.rs @@ -1,5 +1,6 @@ use crate::SearchDirection; use std::cmp; +use termion::color; use unicode_segmentation::UnicodeSegmentation; #[derive(Default)] @@ -30,10 +31,21 @@ impl Row { .skip(start) .take(end - start) { - if grapheme == "\t" { - result.push_str(" "); - } else { - result.push_str(grapheme); + if let Some(c) = grapheme.chars().next() { + if c == '\t' { + result.push_str(" "); + } else if c.is_ascii_digit() { + result.push_str( + &format!( + "{}{}{}", + color::Fg(color::Rgb(220, 163, 163)), + c, + color::Fg(color::Reset) + )[..], + ); + } else { + result.push(c); + } } }