@@ -53,6 +53,7 @@ pub struct Revlog {
5353 first_open_done : bool ,
5454 scroll_state : ( Instant , f32 ) ,
5555 tags : Tags ,
56+ current_height : u16 ,
5657}
5758
5859impl Revlog {
@@ -67,9 +68,15 @@ impl Revlog {
6768 first_open_done : false ,
6869 scroll_state : ( Instant :: now ( ) , 0_f32 ) ,
6970 tags : Tags :: new ( ) ,
71+ current_height : 0 ,
7072 }
7173 }
7274
75+ ///
76+ pub fn prepare_draw ( & mut self , area : Rect ) {
77+ self . current_height = area. height . saturating_sub ( 2 ) ;
78+ }
79+
7380 ///
7481 pub fn draw < B : Backend > ( & self , f : & mut Frame < B > , area : Rect ) {
7582 let height = area. height as usize ;
@@ -155,6 +162,12 @@ impl Revlog {
155162 ScrollType :: Down => {
156163 self . selection . saturating_add ( speed_int)
157164 }
165+ ScrollType :: PageUp => self . selection . saturating_sub (
166+ usize:: from ( self . current_height ) . saturating_sub ( 1 ) ,
167+ ) ,
168+ ScrollType :: PageDown => self . selection . saturating_add (
169+ usize:: from ( self . current_height ) . saturating_sub ( 1 ) ,
170+ ) ,
158171 ScrollType :: Home => 0 ,
159172 ScrollType :: End => self . selection_max ,
160173 } ;
@@ -281,6 +294,14 @@ impl Component for Revlog {
281294 self . move_selection ( ScrollType :: End ) ;
282295 true
283296 }
297+ keys:: PAGE_UP => {
298+ self . move_selection ( ScrollType :: PageUp ) ;
299+ true
300+ }
301+ keys:: PAGE_DOWN => {
302+ self . move_selection ( ScrollType :: PageDown ) ;
303+ true
304+ }
284305 _ => false ,
285306 } ;
286307 }
0 commit comments