diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-11-08 10:29:31 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-11-08 10:29:31 -0500 |
commit | 25831eb0dbe5a9e222f3e31669f6c0c921d7e911 (patch) | |
tree | 09dd00e36ea23219c4a0489fcf845861f4be7519 /src/cell.rs | |
parent | dbeb15e1104d682c118ff3916af797279d080405 (diff) | |
download | vt100-rust-25831eb0dbe5a9e222f3e31669f6c0c921d7e911.tar.gz vt100-rust-25831eb0dbe5a9e222f3e31669f6c0c921d7e911.zip |
stop treating soft hyphen specially
Diffstat (limited to 'src/cell.rs')
-rw-r--r-- | src/cell.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cell.rs b/src/cell.rs index 54f433d..8d7e32f 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -1,4 +1,5 @@ use unicode_normalization::UnicodeNormalization as _; +use unicode_width::UnicodeWidthChar as _; /// Represents a single terminal cell. #[derive(Clone, Debug, Default, Eq, PartialEq)] @@ -45,7 +46,15 @@ impl Cell { /// Returns whether the text data in the cell represents a wide character. pub fn is_wide(&self) -> bool { - crate::unicode::str_width(&self.contents) > 1 + // strings in this context should always be an arbitrary character + // followed by zero or more zero-width characters, so we should only + // have to look at the first character + let width = self + .contents + .chars() + .next() + .map_or(0, |c| c.width().unwrap_or(0)); + width > 1 } pub(crate) fn attrs(&self) -> &crate::attrs::Attrs { |