| 87 | } |
| 88 | |
| 89 | void Console::parseEvent( const ParseMessage& message ) |
| 90 | { |
| 91 | // handle invalid user input |
| 92 | if ( message.errorCode ) |
| 93 | { |
| 94 | setTextColor( ERROR_COLOR ); |
| 95 | append(message.message.c_str()); |
| 96 | |
| 97 | setTextColor( NORMAL_COLOR ); |
| 98 | append(""); |
| 99 | displayPrompt( ); |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | // interpret valid user input |
| 104 | int errorCode; |
| 105 | std::string res; |
| 106 | if ( message.message.size() ) |
| 107 | res = m_interpreter->interpret( message.message, &errorCode ); |
| 108 | if ( errorCode ) |
| 109 | { |
| 110 | setTextColor( ERROR_COLOR ); |
| 111 | } |
| 112 | else |
| 113 | { |
| 114 | setTextColor( OUTPUT_COLOR ); |
| 115 | } |
| 116 | |
| 117 | if ( res.size( ) ) |
| 118 | { |
| 119 | append(res.c_str()); |
| 120 | } |
| 121 | |
| 122 | setTextColor( NORMAL_COLOR ); |
| 123 | |
| 124 | // set up the next line on the console |
| 125 | append(""); |
| 126 | displayPrompt( ); |
| 127 | } |
| 128 | |
| 129 | QString Console::getLine( ) |
| 130 | { |