mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-25 22:55:06 +02:00
Added scrolling in processes.
This commit is contained in:
parent
43ac5c3399
commit
a5306c6692
2
TODO.md
2
TODO.md
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
## After making public
|
## After making public
|
||||||
|
|
||||||
|
* Mouse + key events conflict? Make it so that some events don't clog up the loop if they are not valid keys!
|
||||||
|
|
||||||
* Header should be clear on current sorting direction!
|
* Header should be clear on current sorting direction!
|
||||||
|
|
||||||
* Scaling in and out (zoom), may need to show zoom levels
|
* Scaling in and out (zoom), may need to show zoom levels
|
||||||
|
@ -197,34 +197,38 @@ pub fn draw_data<B : tui::backend::Backend>(terminal : &mut Terminal<B>, app_sta
|
|||||||
let mut process_counter = 0;
|
let mut process_counter = 0;
|
||||||
|
|
||||||
//TODO: Fix this!
|
//TODO: Fix this!
|
||||||
let start_position = if num_rows <= app_state.currently_selected_process_position {
|
let start_position = match app_state.scroll_direction {
|
||||||
match app_state.scroll_direction {
|
app::ScrollDirection::DOWN => {
|
||||||
app::ScrollDirection::UP => {
|
if app_state.currently_selected_process_position < num_rows {
|
||||||
if app_state.previous_process_position - app_state.currently_selected_process_position <= num_rows {
|
0
|
||||||
// We don't need to scroll up yet...
|
|
||||||
debug!("No need to scroll up yet...");
|
|
||||||
app_state.previous_process_position
|
|
||||||
}
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
app::ScrollDirection::DOWN => {
|
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_state.currently_selected_process_position - num_rows + 1;
|
||||||
(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 {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
app_state.previous_process_position
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
app_state.previous_process_position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
"START POSN: {}, CURRENT SELECTED POSN: {}, NUM ROWS: {}",
|
"START POSN: {}, PREV POSN: {}, CURRENT SELECTED POSN: {}, NUM ROWS: {}",
|
||||||
start_position, app_state.currently_selected_process_position, 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();
|
let sliced_vec : Vec<Vec<String>> = (&canvas_data.process_data[start_position as usize..]).to_vec();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user