aboutsummaryrefslogtreecommitdiff
path: root/src/term/cell.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/term/cell.rs')
-rw-r--r--src/term/cell.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/term/cell.rs b/src/term/cell.rs
index a95875bf..db0cebcc 100644
--- a/src/term/cell.rs
+++ b/src/term/cell.rs
@@ -24,6 +24,7 @@ bitflags! {
const BOLD = 0b00000010,
const ITALIC = 0b00000100,
const UNDERLINE = 0b00001000,
+ const WRAPLINE = 0b00010000,
}
}
@@ -45,6 +46,10 @@ impl LineLength for grid::Row<Cell> {
fn line_length(&self) -> Column {
let mut length = Column(0);
+ if self[Column(self.len() - 1)].flags.contains(WRAPLINE) {
+ return Column(self.len());
+ }
+
for (index, cell) in self[..].iter().rev().enumerate() {
if cell.c != ' ' {
length = Column(self.len() - index);
@@ -105,4 +110,13 @@ mod tests {
assert_eq!(row.line_length(), Column(6));
}
+
+ #[test]
+ fn line_length_works_with_wrapline() {
+ let template = Cell::new(' ', Color::Indexed(0), Color::Indexed(0));
+ let mut row = Row::new(Column(10), &template);
+ row[Column(9)].flags.insert(super::WRAPLINE);
+
+ assert_eq!(row.line_length(), Column(10));
+ }
}