Scroll bar fix v2, electric boogaloo
This commit is contained in:
parent
e4597730bd
commit
bbd475cfdb
|
@ -71,33 +71,39 @@ pub fn get_variable_intrinsic_widths(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_start_position(
|
pub fn get_start_position(
|
||||||
num_rows: u64, scroll_direction: &app::ScrollDirection, previously_scrolled_position: &mut u64,
|
num_rows: u64, scroll_direction: &app::ScrollDirection, scroll_position_bar: &mut u64,
|
||||||
currently_selected_position: u64,
|
currently_selected_position: u64,
|
||||||
) -> u64 {
|
) -> u64 {
|
||||||
|
if currently_selected_position >= *scroll_position_bar
|
||||||
|
&& num_rows > (currently_selected_position - *scroll_position_bar + 1)
|
||||||
|
{
|
||||||
|
*scroll_position_bar =
|
||||||
|
std::cmp::max(0, currently_selected_position as i64 - num_rows as i64 + 1) as u64;
|
||||||
|
}
|
||||||
match scroll_direction {
|
match scroll_direction {
|
||||||
app::ScrollDirection::DOWN => {
|
app::ScrollDirection::DOWN => {
|
||||||
if currently_selected_position < *previously_scrolled_position + num_rows {
|
if currently_selected_position < *scroll_position_bar + num_rows {
|
||||||
// If, using previous_scrolled_position, we can see the element
|
// If, using previous_scrolled_position, we can see the element
|
||||||
// (so within that and + num_rows) just reuse the current previously scrolled position
|
// (so within that and + num_rows) just reuse the current previously scrolled position
|
||||||
*previously_scrolled_position
|
*scroll_position_bar
|
||||||
} else if currently_selected_position >= num_rows {
|
} else if currently_selected_position >= num_rows {
|
||||||
// Else if the current position past the last element visible in the list, omit
|
// Else if the current position past the last element visible in the list, omit
|
||||||
// until we can see that element
|
// until we can see that element
|
||||||
*previously_scrolled_position = currently_selected_position - num_rows;
|
*scroll_position_bar = currently_selected_position - num_rows;
|
||||||
currently_selected_position - num_rows
|
*scroll_position_bar
|
||||||
} else {
|
} else {
|
||||||
// Else, if it is not past the last element visible, do not omit anything
|
// Else, if it is not past the last element visible, do not omit anything
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
app::ScrollDirection::UP => {
|
app::ScrollDirection::UP => {
|
||||||
if currently_selected_position <= *previously_scrolled_position {
|
if currently_selected_position <= *scroll_position_bar {
|
||||||
// If it's past the first element, then show from that element downwards
|
// If it's past the first element, then show from that element downwards
|
||||||
*previously_scrolled_position = currently_selected_position;
|
*scroll_position_bar = currently_selected_position;
|
||||||
*previously_scrolled_position
|
*scroll_position_bar
|
||||||
} else {
|
} else {
|
||||||
// Else, don't change what our start position is from whatever it is set to!
|
// Else, don't change what our start position is from whatever it is set to!
|
||||||
*previously_scrolled_position
|
*scroll_position_bar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
40
src/main.rs
40
src/main.rs
|
@ -735,32 +735,30 @@ fn generate_config_colours(config: &Config, painter: &mut canvas::Painter) -> er
|
||||||
fn panic_hook(panic_info: &PanicInfo<'_>) {
|
fn panic_hook(panic_info: &PanicInfo<'_>) {
|
||||||
let mut stdout = stdout();
|
let mut stdout = stdout();
|
||||||
|
|
||||||
if cfg!(debug_assertions) {
|
let msg = match panic_info.payload().downcast_ref::<&'static str>() {
|
||||||
let msg = match panic_info.payload().downcast_ref::<&'static str>() {
|
Some(s) => *s,
|
||||||
Some(s) => *s,
|
None => match panic_info.payload().downcast_ref::<String>() {
|
||||||
None => match panic_info.payload().downcast_ref::<String>() {
|
Some(s) => &s[..],
|
||||||
Some(s) => &s[..],
|
None => "Box<Any>",
|
||||||
None => "Box<Any>",
|
},
|
||||||
},
|
};
|
||||||
};
|
|
||||||
|
|
||||||
let stacktrace: String = format!("{:?}", backtrace::Backtrace::new());
|
let stacktrace: String = format!("{:?}", backtrace::Backtrace::new());
|
||||||
|
|
||||||
execute!(
|
|
||||||
stdout,
|
|
||||||
Print(format!(
|
|
||||||
"thread '<unnamed>' panicked at '{}', {}\n\r{}",
|
|
||||||
msg,
|
|
||||||
panic_info.location().unwrap(),
|
|
||||||
stacktrace
|
|
||||||
)),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
disable_raw_mode().unwrap();
|
disable_raw_mode().unwrap();
|
||||||
execute!(stdout, LeaveAlternateScreen).unwrap();
|
execute!(stdout, LeaveAlternateScreen).unwrap();
|
||||||
execute!(stdout, DisableMouseCapture).unwrap();
|
execute!(stdout, DisableMouseCapture).unwrap();
|
||||||
|
|
||||||
|
execute!(
|
||||||
|
stdout,
|
||||||
|
Print(format!(
|
||||||
|
"thread '<unnamed>' panicked at '{}', {}\n\r{}",
|
||||||
|
msg,
|
||||||
|
panic_info.location().unwrap(),
|
||||||
|
stacktrace
|
||||||
|
)),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_final_process_list(app: &mut app::App) {
|
fn update_final_process_list(app: &mut app::App) {
|
||||||
|
|
Loading…
Reference in New Issue