@@ -2,7 +2,7 @@ use std::io::Result;
22
33use ratatui:: crossterm:: event:: { KeyCode , KeyEvent } ;
44
5- use crate :: app:: App ;
5+ use crate :: { app:: App , editor :: AppView } ;
66
77const NUMBER_OF_TABS : usize = 4 ;
88
@@ -79,7 +79,7 @@ fn tab_program_headers_events(app: &mut App, key: KeyEvent) -> Result<bool> {
7979 app. header_view
8080 . elf_state
8181 . program_header_table_state
82- . select_cell ( Some ( ( 0 , 1 ) ) ) ;
82+ . select_cell ( Some ( ( 0 , 5 ) ) ) ;
8383 } else {
8484 app. header_view
8585 . elf_state
@@ -107,8 +107,52 @@ fn tab_program_headers_events(app: &mut App, key: KeyEvent) -> Result<bool> {
107107 }
108108 }
109109 }
110- KeyCode :: Char ( 'G' ) => {
111- // goto
110+ KeyCode :: Left | KeyCode :: Char ( 'h' ) => {
111+ if app
112+ . header_view
113+ . elf_state
114+ . program_header_table_state
115+ . selected ( )
116+ . is_none ( )
117+ {
118+ tab_prev ( app) ;
119+ } else {
120+ app. header_view
121+ . elf_state
122+ . program_header_table_state
123+ . select_previous_column ( ) ;
124+ }
125+ }
126+ KeyCode :: Right | KeyCode :: Char ( 'l' ) => {
127+ if app
128+ . header_view
129+ . elf_state
130+ . program_header_table_state
131+ . selected ( )
132+ . is_none ( )
133+ {
134+ tab_next ( app) ;
135+ } else {
136+ app. header_view
137+ . elf_state
138+ . program_header_table_state
139+ . select_next_column ( ) ;
140+ }
141+ }
142+ // follow
143+ // TODO: follow only when a PhysAddr field is selected
144+ KeyCode :: Char ( 'f' ) => {
145+ let idx = app
146+ . header_view
147+ . elf_state
148+ . program_header_table_state
149+ . selected ( )
150+ . unwrap ( ) ;
151+ let elf = app. header_view . elf . as_ref ( ) . unwrap ( ) ;
152+ let phdr = elf. phdrs . get ( idx) . unwrap ( ) ;
153+ let ofs = phdr. p_offset ;
154+ app. goto ( ofs as usize ) ;
155+ app. editor_view = AppView :: Hex ;
112156 }
113157 _ => { }
114158 }
@@ -193,10 +237,10 @@ fn tab_symbols_events(app: &mut App, key: KeyEvent) -> Result<bool> {
193237
194238pub fn view_header_elf_events ( app : & mut App , key : KeyEvent ) -> Result < bool > {
195239 match key. code {
196- KeyCode :: Tab | KeyCode :: Right | KeyCode :: Char ( 'l' ) => {
240+ KeyCode :: Tab => {
197241 tab_next ( app) ;
198242 }
199- KeyCode :: BackTab | KeyCode :: Left | KeyCode :: Char ( 'h' ) => {
243+ KeyCode :: BackTab => {
200244 tab_prev ( app) ;
201245 }
202246 _ => ( ) ,
0 commit comments