@@ -94,6 +94,7 @@ compile_error!(
9494 "Please set either the 'render-tui-crossterm' or 'render-tui-termion' feature whne using the 'render-tui'"
9595) ;
9696
97+ use crosstermion:: crossterm:: event:: { KeyCode , KeyEventKind , KeyModifiers } ;
9798use crosstermion:: {
9899 input:: { key_input_stream, Key } ,
99100 terminal:: { tui:: new_terminal, AlternateRawScreen } ,
@@ -175,25 +176,32 @@ pub fn render_with_input(
175176 let mut skip_redraw = false ;
176177 match event {
177178 Event :: Tick => { }
178- Event :: Input ( key) => match key {
179- Key :: Esc | Key :: Char ( 'q' ) | Key :: Ctrl ( 'c' ) | Key :: Ctrl ( '[' ) => match interrupt_mode {
179+ Event :: Input ( key) if key. kind != KeyEventKind :: Release => match key. code {
180+ KeyCode :: Char ( 'c' ) | KeyCode :: Char ( '[' ) if key. modifiers . contains ( KeyModifiers :: CONTROL ) => {
181+ match interrupt_mode {
182+ InterruptDrawInfo :: Instantly => break ,
183+ InterruptDrawInfo :: Deferred ( _) => interrupt_mode = InterruptDrawInfo :: Deferred ( true ) ,
184+ }
185+ }
186+ KeyCode :: Esc | KeyCode :: Char ( 'q' ) => match interrupt_mode {
180187 InterruptDrawInfo :: Instantly => break ,
181188 InterruptDrawInfo :: Deferred ( _) => interrupt_mode = InterruptDrawInfo :: Deferred ( true ) ,
182189 } ,
183- Key :: Char ( '`' ) => state. hide_messages = !state. hide_messages ,
184- Key :: Char ( '~' ) => state. messages_fullscreen = !state. messages_fullscreen ,
185- Key :: Char ( 'J' ) => state. message_offset = state. message_offset . saturating_add ( 1 ) ,
186- Key :: Char ( 'D' ) => state. message_offset = state. message_offset . saturating_add ( 10 ) ,
187- Key :: Char ( 'j' ) => state. task_offset = state. task_offset . saturating_add ( 1 ) ,
188- Key :: Char ( 'd' ) => state. task_offset = state. task_offset . saturating_add ( 10 ) ,
189- Key :: Char ( 'K' ) => state. message_offset = state. message_offset . saturating_sub ( 1 ) ,
190- Key :: Char ( 'U' ) => state. message_offset = state. message_offset . saturating_sub ( 10 ) ,
191- Key :: Char ( 'k' ) => state. task_offset = state. task_offset . saturating_sub ( 1 ) ,
192- Key :: Char ( 'u' ) => state. task_offset = state. task_offset . saturating_sub ( 10 ) ,
193- Key :: Char ( '[' ) => state. hide_info = !state. hide_info ,
194- Key :: Char ( '{' ) => state. maximize_info = !state. maximize_info ,
190+ KeyCode :: Char ( '`' ) => state. hide_messages = !state. hide_messages ,
191+ KeyCode :: Char ( '~' ) => state. messages_fullscreen = !state. messages_fullscreen ,
192+ KeyCode :: Char ( 'J' ) => state. message_offset = state. message_offset . saturating_add ( 1 ) ,
193+ KeyCode :: Char ( 'D' ) => state. message_offset = state. message_offset . saturating_add ( 10 ) ,
194+ KeyCode :: Char ( 'j' ) => state. task_offset = state. task_offset . saturating_add ( 1 ) ,
195+ KeyCode :: Char ( 'd' ) => state. task_offset = state. task_offset . saturating_add ( 10 ) ,
196+ KeyCode :: Char ( 'K' ) => state. message_offset = state. message_offset . saturating_sub ( 1 ) ,
197+ KeyCode :: Char ( 'U' ) => state. message_offset = state. message_offset . saturating_sub ( 10 ) ,
198+ KeyCode :: Char ( 'k' ) => state. task_offset = state. task_offset . saturating_sub ( 1 ) ,
199+ KeyCode :: Char ( 'u' ) => state. task_offset = state. task_offset . saturating_sub ( 10 ) ,
200+ KeyCode :: Char ( '[' ) => state. hide_info = !state. hide_info ,
201+ KeyCode :: Char ( '{' ) => state. maximize_info = !state. maximize_info ,
195202 _ => skip_redraw = true ,
196203 } ,
204+ Event :: Input ( _) => skip_redraw = true ,
197205 Event :: SetWindowSize ( bound) => state. user_provided_window_size = Some ( bound) ,
198206 Event :: SetTitle ( title) => state. title = title,
199207 Event :: SetInformation ( info) => state. information = info,
0 commit comments