@@ -3,6 +3,7 @@ use super::source::SourceComponent;
33use super :: stack:: StackComponent ;
44use super :: ComponentType ;
55use super :: Pane ;
6+ use super :: Scroll ;
67use super :: View ;
78use crate :: app:: App ;
89use crate :: app:: CurrentView ;
@@ -29,10 +30,14 @@ impl View for SessionView {
2930 KeyCode :: Tab => return Some ( AppEvent :: NextPane ) ,
3031 KeyCode :: Enter => return Some ( AppEvent :: ToggleFullscreen ) ,
3132 KeyCode :: Char ( char) => match char {
32- 'j' => return Some ( AppEvent :: ScrollDown ( 1 ) ) ,
33- 'k' => return Some ( AppEvent :: ScrollUp ( 1 ) ) ,
34- 'J' => return Some ( AppEvent :: ScrollDown ( 10 ) ) ,
35- 'K' => return Some ( AppEvent :: ScrollUp ( 10 ) ) ,
33+ 'j' => return Some ( AppEvent :: Scroll ( ( 1 , 0 ) ) ) ,
34+ 'k' => return Some ( AppEvent :: Scroll ( ( -1 , 0 ) ) ) ,
35+ 'J' => return Some ( AppEvent :: Scroll ( ( 10 , 0 ) ) ) ,
36+ 'K' => return Some ( AppEvent :: Scroll ( ( -10 , 0 ) ) ) ,
37+ 'l' => return Some ( AppEvent :: Scroll ( ( 0 , 1 ) ) ) ,
38+ 'L' => return Some ( AppEvent :: Scroll ( ( 0 , 10 ) ) ) ,
39+ 'h' => return Some ( AppEvent :: Scroll ( ( 0 , -1 ) ) ) ,
40+ 'H' => return Some ( AppEvent :: Scroll ( ( 0 , -10 ) ) ) ,
3641 '0' ..='9' => return Some ( AppEvent :: PushInputPlurality ( char) ) ,
3742 _ => ( ) ,
3843 } ,
@@ -74,7 +79,13 @@ impl View for SessionView {
7479
7580 fn draw ( app : & App , frame : & mut Frame , area : ratatui:: prelude:: Rect ) {
7681 if app. session_view . full_screen {
77- build_pane_widget ( frame, app, app. session_view . current_pane ( ) , area, app. session_view . current_pane ) ;
82+ build_pane_widget (
83+ frame,
84+ app,
85+ app. session_view . current_pane ( ) ,
86+ area,
87+ app. session_view . current_pane ,
88+ ) ;
7889 return ;
7990 }
8091
@@ -122,12 +133,10 @@ fn build_pane_widget(frame: &mut Frame, app: &App, pane: &Pane, area: Rect, inde
122133 ComponentType :: Context => format ! ( "Context({})" , app. context_depth) ,
123134 ComponentType :: Stack => "Stack" . to_string ( ) ,
124135 } )
125- . style (
126- match index == app. session_view . current_pane {
127- true => app. theme ( ) . pane_border_active ,
128- false => app. theme ( ) . pane_border_inactive ,
129- }
130- ) ;
136+ . style ( match index == app. session_view . current_pane {
137+ true => app. theme ( ) . pane_border_active ,
138+ false => app. theme ( ) . pane_border_inactive ,
139+ } ) ;
131140
132141 frame. render_widget ( & block, area) ;
133142
@@ -146,9 +155,9 @@ fn build_pane_widget(frame: &mut Frame, app: &App, pane: &Pane, area: Rect, inde
146155
147156pub struct SessionViewState {
148157 pub full_screen : bool ,
149- pub source_scroll : Option < i16 > ,
150- pub context_scroll : u16 ,
151- pub stack_scroll : u16 ,
158+ pub source_scroll : ( u16 , u16 ) ,
159+ pub context_scroll : ( u16 , u16 ) ,
160+ pub stack_scroll : ( u16 , u16 ) ,
152161 pub mode : SessionViewMode ,
153162 pub panes : Vec < Pane > ,
154163 pub current_pane : usize ,
@@ -164,9 +173,9 @@ impl SessionViewState {
164173 pub fn new ( ) -> Self {
165174 Self {
166175 full_screen : false ,
167- source_scroll : None ,
168- context_scroll : 0 ,
169- stack_scroll : 0 ,
176+ source_scroll : ( 0 , 0 ) ,
177+ context_scroll : ( 0 , 0 ) ,
178+ stack_scroll : ( 0 , 0 ) ,
170179 current_pane : 0 ,
171180 mode : SessionViewMode :: Current ,
172181 panes : vec ! [
@@ -196,8 +205,9 @@ impl SessionViewState {
196205 }
197206
198207 pub ( crate ) fn reset ( & mut self ) {
199- self . context_scroll = 0 ;
200- self . source_scroll = None ;
208+ self . context_scroll = ( 0 , 0 ) ;
209+ self . stack_scroll = ( 0 , 0 ) ;
210+ self . source_scroll = ( 0 , 0 ) ;
201211 }
202212}
203213
0 commit comments