| 43 | } |
| 44 | |
| 45 | void Console::ProcessEvents( const SystemEvents& events ) |
| 46 | { |
| 47 | using KeyCode= SystemEvent::KeyEvent::KeyCode; |
| 48 | |
| 49 | for( const SystemEvent& event : events ) |
| 50 | { |
| 51 | if( event.type == SystemEvent::Type::CharInput ) |
| 52 | { |
| 53 | if( event.event.char_input.ch != '`' && |
| 54 | input_cursor_pos_ < c_max_input_line_length ) |
| 55 | { |
| 56 | input_line_[ input_cursor_pos_ ]= event.event.char_input.ch; |
| 57 | input_cursor_pos_++; |
| 58 | input_line_[ input_cursor_pos_ ]= '\0'; |
| 59 | } |
| 60 | continue; |
| 61 | } |
| 62 | |
| 63 | if( !( event.type == SystemEvent::Type::Key && event.event.key.pressed ) ) |
| 64 | continue; |
| 65 | |
| 66 | const KeyCode key_code= event.event.key.key_code; |
| 67 | if( key_code == KeyCode::Enter ) |
| 68 | { |
| 69 | lines_position_= 0u; |
| 70 | Log::Info( input_line_ ); |
| 71 | |
| 72 | if( input_cursor_pos_ > 0u ) |
| 73 | { |
| 74 | WriteHistory(); |
| 75 | commands_processor_.ProcessCommand( input_line_ ); |
| 76 | } |
| 77 | |
| 78 | input_cursor_pos_= 0u; |
| 79 | input_line_[ input_cursor_pos_ ]= '\0'; |
| 80 | } |
| 81 | else if( key_code == KeyCode::Escape ) |
| 82 | { |
| 83 | Toggle(); |
| 84 | } |
| 85 | else if( key_code == KeyCode::Backspace ) |
| 86 | { |
| 87 | if( input_cursor_pos_ > 0u ) |
| 88 | { |
| 89 | input_cursor_pos_--; |
| 90 | input_line_[ input_cursor_pos_ ]= '\0'; |
| 91 | } |
| 92 | } |
| 93 | else if( key_code == KeyCode::Tab ) |
| 94 | { |
| 95 | const std::string completed_command= commands_processor_.TryCompleteCommand( input_line_ ); |
| 96 | std::strncpy( input_line_, completed_command.c_str(), sizeof(input_line_) ); |
| 97 | input_cursor_pos_= std::strlen( input_line_ ); |
| 98 | } |
| 99 | else if( key_code == KeyCode::Up ) |
| 100 | { |
| 101 | if( history_size_ > 0u ) |
| 102 | { |
nothing calls this directly
no test coverage detected