@@ -41,9 +41,12 @@ impl State {
4141
4242 Event :: Key ( KeyEvent {
4343 code : KeyCode :: Char ( c) ,
44- modifiers : KeyModifiers :: NONE ,
44+ modifiers,
4545 ..
46- } ) => self . overwrite_or_insert_char ( c) ,
46+ } ) if modifiers == KeyModifiers :: NONE || modifiers == KeyModifiers :: SHIFT => {
47+ self . overwrite_or_insert_char ( c)
48+ }
49+
4750 Event :: Key ( KeyEvent {
4851 code : KeyCode :: Backspace ,
4952 modifiers : KeyModifiers :: NONE ,
@@ -55,16 +58,19 @@ impl State {
5558 modifiers : KeyModifiers :: NONE ,
5659 ..
5760 } ) => self . delete_next_char ( ) ,
61+
5862 Event :: Key ( KeyEvent {
5963 code : KeyCode :: Enter ,
6064 modifiers : KeyModifiers :: NONE ,
6165 ..
6266 } ) => self . insert_line ( ) ,
67+
6368 Event :: Key ( KeyEvent {
6469 code : KeyCode :: Left ,
6570 modifiers : KeyModifiers :: NONE ,
6671 ..
6772 } ) => self . move_left ( ) ,
73+
6874 Event :: Key ( KeyEvent {
6975 code : KeyCode :: Right ,
7076 modifiers : KeyModifiers :: NONE ,
@@ -83,6 +89,18 @@ impl State {
8389 ..
8490 } ) => self . move_up ( ) ,
8591
92+ Event :: Key ( KeyEvent {
93+ code : KeyCode :: PageDown ,
94+ modifiers : KeyModifiers :: NONE ,
95+ ..
96+ } ) => self . move_page_down ( ) ,
97+
98+ Event :: Key ( KeyEvent {
99+ code : KeyCode :: PageUp ,
100+ modifiers : KeyModifiers :: NONE ,
101+ ..
102+ } ) => self . move_page_up ( ) ,
103+
86104 _ => { }
87105 }
88106 }
@@ -200,6 +218,7 @@ impl State {
200218 let line = self . lines . get ( self . cursor . y as usize ) . unwrap ( ) ;
201219 self . cursor . x = std:: cmp:: min ( self . cursor . x , line. len ( ) as u16 ) ;
202220 }
221+
203222 fn move_down ( & mut self ) {
204223 if self . cursor . y + 1 >= self . lines . len ( ) as u16 {
205224 return ;
@@ -209,6 +228,23 @@ impl State {
209228 self . cursor . x = std:: cmp:: min ( self . cursor . x , line. len ( ) as u16 ) ;
210229 }
211230
231+ fn move_page_up ( & mut self ) {
232+ for _ in 0 ..self . lines_per_page ( ) {
233+ self . move_up ( ) ;
234+ }
235+ }
236+
237+ fn move_page_down ( & mut self ) {
238+ for _ in 0 ..self . lines_per_page ( ) {
239+ self . move_down ( ) ;
240+ }
241+ }
242+
243+ fn lines_per_page ( & self ) -> u16 {
244+ // TODO
245+ return 10 ;
246+ }
247+
212248 fn left_margin_width ( & self ) -> u16 {
213249 std:: cmp:: max ( 4 , self . lines . len ( ) . to_string ( ) . len ( ) as u16 + 1 )
214250 }
0 commit comments