@@ -24,8 +24,7 @@ struct State {
2424impl State {
2525 fn run ( & mut self , mut terminal : DefaultTerminal ) -> io:: Result < ( ) > {
2626 loop {
27- self . status_text = format ! ( "Line {}, Column {}" , self . cursor. y, self . cursor. x) ;
28- terminal. draw ( |x| self . render ( x) ) ?;
27+ self . render ( & mut terminal) ?;
2928
3029 let event = event:: read ( ) ?;
3130 if !self . handle_event ( event) {
@@ -34,6 +33,15 @@ impl State {
3433 }
3534 }
3635
36+ fn render (
37+ & mut self ,
38+ terminal : & mut ratatui:: Terminal < ratatui:: prelude:: CrosstermBackend < io:: Stdout > > ,
39+ ) -> Result < ( ) , io:: Error > {
40+ self . status_text = format ! ( "Line {}, Column {}" , self . cursor. y, self . cursor. x) ;
41+ terminal. draw ( |x| self . draw_frame ( x) ) ?;
42+ Ok ( ( ) )
43+ }
44+
3745 fn handle_event ( & mut self , event : Event ) -> bool {
3846 match event {
3947 Event :: Key ( KeyEvent {
@@ -181,7 +189,7 @@ impl State {
181189 self . lines . insert ( self . cursor . y as usize , new_line) ;
182190 }
183191
184- fn render ( & self , frame : & mut Frame ) {
192+ fn draw_frame ( & self , frame : & mut Frame ) {
185193 let window_area = frame. area ( ) ;
186194 let text_area = Rect :: new ( 0 , 0 , window_area. width , window_area. height - 1 ) ;
187195 let status_area = Rect :: new ( 0 , window_area. height - 1 , window_area. width , 1 ) ;
0 commit comments