Fixed off by one error with scrolling.

This commit is contained in:
ClementTsang 2019-09-16 20:33:25 -04:00
parent 266c281024
commit 1b777d27e5
3 changed files with 11 additions and 9 deletions

View File

@ -16,6 +16,8 @@
* Keybindings * Keybindings
* Legend gets in the way at too small of a height... maybe modify tui a bit more to fix this.
## After making public ## After making public
* Tests * Tests

View File

@ -150,13 +150,13 @@ pub fn draw_data<B : tui::backend::Backend>(terminal : &mut Terminal<B>, app_sta
.block(Block::default().title("Disk Usage").borders(Borders::ALL).border_style(border_style)) .block(Block::default().title("Disk Usage").borders(Borders::ALL).border_style(border_style))
.header_style(Style::default().fg(Color::LightBlue).modifier(Modifier::BOLD)) .header_style(Style::default().fg(Color::LightBlue).modifier(Modifier::BOLD))
.widths(&[ .widths(&[
(width * 0.18) as u16, (width * 0.18).floor() as u16,
(width * 0.14) as u16, (width * 0.14).floor() as u16,
(width * 0.13) as u16, (width * 0.11).floor() as u16,
(width * 0.13) as u16, (width * 0.11).floor() as u16,
(width * 0.13) as u16, (width * 0.11).floor() as u16,
(width * 0.13) as u16, (width * 0.11).floor() as u16,
(width * 0.13) as u16, (width * 0.11).floor() as u16,
]) ])
.render(&mut f, middle_divided_chunk_2[1]); .render(&mut f, middle_divided_chunk_2[1]);
} }
@ -202,7 +202,7 @@ pub fn draw_data<B : tui::backend::Backend>(terminal : &mut Terminal<B>, app_sta
if app_state.currently_selected_process_position < num_rows { if app_state.currently_selected_process_position < num_rows {
0 0
} }
else if app_state.currently_selected_process_position - num_rows < app_state.previous_process_position { else if app_state.currently_selected_process_position - num_rows <= app_state.previous_process_position {
app_state.previous_process_position app_state.previous_process_position
} }
else { else {

View File

@ -67,7 +67,7 @@ pub fn update_disk_row(app_data : &data_collection::Data) -> Vec<Vec<String>> {
disk_vector.push(vec![ disk_vector.push(vec![
disk.name.to_string(), disk.name.to_string(),
disk.mount_point.to_string(), disk.mount_point.to_string(),
format!("{:.1}%", disk.used_space as f64 / disk.total_space as f64 * 100_f64), format!("{:.0}%", disk.used_space as f64 / disk.total_space as f64 * 100_f64),
if disk.free_space < 1024 { if disk.free_space < 1024 {
disk.free_space.to_string() + "MB" disk.free_space.to_string() + "MB"
} }