summaryrefslogtreecommitdiffstats
path: root/src/canvas.rs
diff options
context:
space:
mode:
authorClementTsang <clementjhtsang@gmail.com>2019-09-16 18:47:49 -0400
committerClementTsang <clementjhtsang@gmail.com>2019-09-16 18:47:49 -0400
commita5306c6692705aa93326224cd50e47f3a1b94ca6 (patch)
treea19681e5c9fed073c76f9eb8ad1376e6d42689f7 /src/canvas.rs
parent43ac5c339971e27261f87aea79b56d7ac4159cea (diff)
Added scrolling in processes.
Diffstat (limited to 'src/canvas.rs')
-rw-r--r--src/canvas.rs44
1 files changed, 24 insertions, 20 deletions
diff --git a/src/canvas.rs b/src/canvas.rs
index 2233c37f..91544e96 100644
--- a/src/canvas.rs
+++ b/src/canvas.rs
@@ -197,34 +197,38 @@ pub fn draw_data<B : tui::backend::Backend>(terminal : &mut Terminal<B>, app_sta
let mut process_counter = 0;
//TODO: Fix this!
- let start_position = if num_rows <= app_state.currently_selected_process_position {
- match app_state.scroll_direction {
- app::ScrollDirection::UP => {
- if app_state.previous_process_position - app_state.currently_selected_process_position <= num_rows {
- // We don't need to scroll up yet...
- debug!("No need to scroll up yet...");
- app_state.previous_process_position
+ let start_position = match app_state.scroll_direction {
+ app::ScrollDirection::DOWN => {
+ if app_state.currently_selected_process_position < num_rows {
+ 0
+ }
+ else if app_state.currently_selected_process_position - num_rows < app_state.previous_process_position {
+ app_state.previous_process_position
+ }
+ else {
+ app_state.previous_process_position = app_state.currently_selected_process_position - num_rows + 1;
+ app_state.previous_process_position
+ }
+ }
+ app::ScrollDirection::UP => {
+ if app_state.currently_selected_process_position == app_state.previous_process_position - 1 {
+ app_state.previous_process_position = if app_state.previous_process_position > 0 {
+ app_state.previous_process_position - 1
}
else {
- // We need to scroll up!
- debug!("Scroll up! Scroll up!");
- app_state.previous_process_position = app_state.currently_selected_process_position;
- app_state.currently_selected_process_position
- }
+ 0
+ };
+ app_state.previous_process_position
}
- app::ScrollDirection::DOWN => {
- app_state.previous_process_position = app_state.currently_selected_process_position - num_rows + 1;
- (app_state.currently_selected_process_position - num_rows + 1)
+ else {
+ app_state.previous_process_position
}
}
- }
- else {
- 0
};
debug!(
- "START POSN: {}, CURRENT SELECTED POSN: {}, NUM ROWS: {}",
- start_position, app_state.currently_selected_process_position, num_rows
+ "START POSN: {}, PREV POSN: {}, CURRENT SELECTED POSN: {}, NUM ROWS: {}",
+ start_position, app_state.previous_process_position, app_state.currently_selected_process_position, num_rows
);
let sliced_vec : Vec<Vec<String>> = (&canvas_data.process_data[start_position as usize..]).to_vec();