aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-03 13:54:23 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-03 13:55:17 -0500
commit732589c4f0a5dbecc33f8ec4f7626a1cc93a03a8 (patch)
tree4e8a57f61d207665b923621a8a2fea7ade6e31b3 /src
parent222c3c4aa13508920a626dd427b1a2aca3c9f2a6 (diff)
downloadvt100-rust-732589c4f0a5dbecc33f8ec4f7626a1cc93a03a8.tar.gz
vt100-rust-732589c4f0a5dbecc33f8ec4f7626a1cc93a03a8.zip
handle scrolling outside of a scroll region
it shouldn't scroll the scroll region if you wrap off the end of the whole terminal outside of the scroll region. also, that kind of non-wrap shouldn't set the wrap flag
Diffstat (limited to 'src')
-rw-r--r--src/grid.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/grid.rs b/src/grid.rs
index 173910a..785b3cb 100644
--- a/src/grid.rs
+++ b/src/grid.rs
@@ -549,11 +549,16 @@ impl Grid {
self.row_clamp_bottom(in_scroll_region);
}
- pub fn row_inc_scroll(&mut self, count: u16) {
+ pub fn row_inc_scroll(&mut self, count: u16) -> u16 {
let in_scroll_region = self.in_scroll_region();
self.pos.row = self.pos.row.saturating_add(count);
let lines = self.row_clamp_bottom(in_scroll_region);
- self.scroll_up(lines);
+ if in_scroll_region {
+ self.scroll_up(lines);
+ lines
+ } else {
+ 0
+ }
}
pub fn row_dec_clamp(&mut self, count: u16) {
@@ -607,9 +612,13 @@ impl Grid {
pub fn col_wrap(&mut self, width: u16, wrap: bool) {
if self.pos.col > self.size.cols - width {
- self.current_row_mut().wrap(wrap);
+ let prev_pos = self.pos;
self.pos.col = 0;
- self.row_inc_scroll(1);
+ let scrolled = self.row_inc_scroll(1);
+ let new_pos = self.pos;
+ self.drawing_row_mut(prev_pos).unwrap().wrap(
+ wrap && (prev_pos.row + 1 == new_pos.row || scrolled == 1),
+ );
}
}