@@ -94,6 +94,7 @@ compile_error!(
94
94
"Please set either the 'render-tui-crossterm' or 'render-tui-termion' feature whne using the 'render-tui'"
95
95
) ;
96
96
97
+ use crosstermion:: crossterm:: event:: { KeyCode , KeyEventKind , KeyModifiers } ;
97
98
use crosstermion:: {
98
99
input:: { key_input_stream, Key } ,
99
100
terminal:: { tui:: new_terminal, AlternateRawScreen } ,
@@ -175,25 +176,32 @@ pub fn render_with_input(
175
176
let mut skip_redraw = false ;
176
177
match event {
177
178
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 {
180
187
InterruptDrawInfo :: Instantly => break ,
181
188
InterruptDrawInfo :: Deferred ( _) => interrupt_mode = InterruptDrawInfo :: Deferred ( true ) ,
182
189
} ,
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 ,
195
202
_ => skip_redraw = true ,
196
203
} ,
204
+ Event :: Input ( _) => skip_redraw = true ,
197
205
Event :: SetWindowSize ( bound) => state. user_provided_window_size = Some ( bound) ,
198
206
Event :: SetTitle ( title) => state. title = title,
199
207
Event :: SetInformation ( info) => state. information = info,
0 commit comments