summaryrefslogtreecommitdiffstats
path: root/src/ui/reflow.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/reflow.rs')
-rw-r--r--src/ui/reflow.rs18
1 files changed, 1 insertions, 17 deletions
diff --git a/src/ui/reflow.rs b/src/ui/reflow.rs
index a9937361..81de4b84 100644
--- a/src/ui/reflow.rs
+++ b/src/ui/reflow.rs
@@ -1,6 +1,6 @@
+use crate::string_utils::trim_offset;
use easy_cast::Cast;
use tui::text::StyledGrapheme;
-use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;
const NBSP: &str = "\u{00a0}";
@@ -233,22 +233,6 @@ impl<'a, 'b> LineComposer<'a> for LineTruncator<'a, 'b> {
}
}
-/// This function will return a str slice which start at specified offset.
-/// As src is a unicode str, start offset has to be calculated with each character.
-fn trim_offset(src: &str, mut offset: usize) -> &str {
- let mut start = 0;
- for c in UnicodeSegmentation::graphemes(src, true) {
- let w = c.width();
- if w <= offset {
- offset -= w;
- start += c.len();
- } else {
- break;
- }
- }
- &src[start..]
-}
-
#[cfg(test)]
mod test {
use super::*;