From 086653d646df7d2e4fc63d0195c71bb8b8e0b83b Mon Sep 17 00:00:00 2001 From: Alfred Godoy Date: Mon, 14 Oct 2024 16:30:50 +0200 Subject: [PATCH 1/3] fixes broken scrolling on pageup and pagedown --- cursive/src/main.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cursive/src/main.rs b/cursive/src/main.rs index 0953fb0..a197eba 100644 --- a/cursive/src/main.rs +++ b/cursive/src/main.rs @@ -106,10 +106,10 @@ fn up(ui: &mut Cursive) { } fn page_down(ui: &mut Cursive) { - let mut l = ui - .find_name::>("results") - .unwrap(); - l.select_down(screen_height(ui)); + let rows = screen_height(&ui); + ui.call_on_name("results", |l: &mut SelectView| { + l.select_down(rows); + }); ui.call_on_name( "scroll_results", |l: &mut ScrollView>>>| { @@ -119,10 +119,10 @@ fn page_down(ui: &mut Cursive) { } fn page_up(ui: &mut Cursive) { - let mut l = ui - .find_name::>("results") - .unwrap(); - l.select_up(screen_height(ui)); + let rows = screen_height(&ui); + ui.call_on_name("results", |l: &mut SelectView| { + l.select_up(rows); + }); ui.call_on_name( "scroll_results", |l: &mut ScrollView>>>| { From 3008f4296db47ea3d54fc0a8c9a60795d00c670a Mon Sep 17 00:00:00 2001 From: Alfred Godoy Date: Mon, 14 Oct 2024 16:49:42 +0200 Subject: [PATCH 2/3] dont scroll too far on pageup/pagedown, margins for UI --- cursive/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cursive/src/main.rs b/cursive/src/main.rs index a197eba..44154b3 100644 --- a/cursive/src/main.rs +++ b/cursive/src/main.rs @@ -106,7 +106,7 @@ fn up(ui: &mut Cursive) { } fn page_down(ui: &mut Cursive) { - let rows = screen_height(&ui); + let rows = screen_height(&ui) - 6; ui.call_on_name("results", |l: &mut SelectView| { l.select_down(rows); }); @@ -119,7 +119,7 @@ fn page_down(ui: &mut Cursive) { } fn page_up(ui: &mut Cursive) { - let rows = screen_height(&ui); + let rows = screen_height(&ui) - 6; ui.call_on_name("results", |l: &mut SelectView| { l.select_up(rows); }); From 91f8c627006e02f67ea682d94215fe5aca197963 Mon Sep 17 00:00:00 2001 From: Alfred Godoy Date: Mon, 14 Oct 2024 17:31:27 +0200 Subject: [PATCH 3/3] nicer distance on pageup/pagedown, from first to last line in the same page --- cursive/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cursive/src/main.rs b/cursive/src/main.rs index 44154b3..f9a3bbf 100644 --- a/cursive/src/main.rs +++ b/cursive/src/main.rs @@ -106,7 +106,7 @@ fn up(ui: &mut Cursive) { } fn page_down(ui: &mut Cursive) { - let rows = screen_height(&ui) - 6; + let rows = screen_height(&ui) - 7; ui.call_on_name("results", |l: &mut SelectView| { l.select_down(rows); }); @@ -119,7 +119,7 @@ fn page_down(ui: &mut Cursive) { } fn page_up(ui: &mut Cursive) { - let rows = screen_height(&ui) - 6; + let rows = screen_height(&ui) - 7; ui.call_on_name("results", |l: &mut SelectView| { l.select_up(rows); });