Commit 5531d965 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Fix margins on resize

parent 81314ede
......@@ -634,7 +634,7 @@ impl State {
'r' => {
let top = params.get(0).map(|v| *v).unwrap_or(1);
let bottom = params.get(1).map(|v| *v).unwrap_or(self.h as i64);
self.top_margin = cmp::max(0, top as isize - 1) as usize;
self.top_margin = cmp::max(0, cmp::min(self.h as isize - 1, top as isize - 1)) as usize;
self.bottom_margin = cmp::max(self.top_margin as isize, cmp::min(self.h as isize - 1, bottom as isize - 1)) as usize;
},
's' => {
......@@ -840,6 +840,16 @@ impl Console {
}
}
pub fn resize(&mut self, w: usize, h: usize) {
let state = &mut self.state;
state.top_margin = cmp::max(0, cmp::min(h as isize - 1, state.top_margin as isize)) as usize;
state.bottom_margin = cmp::max(state.top_margin as isize, cmp::min(h as isize - 1, state.bottom_margin as isize + h as isize - state.h as isize)) as usize;
state.w = w;
state.h = h;
}
pub fn write<F: FnMut(Event)>(&mut self, bytes: &[u8], mut callback: F) {
for byte in bytes.iter() {
self.parser.advance(&mut Performer {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment