-
Notifications
You must be signed in to change notification settings - Fork 69
Fix console crash and console key input #1880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,6 @@ namespace Scancode { | |
|
|
||
| class Key | ||
| { | ||
| public: | ||
| public: | ||
| enum class Kind { | ||
| INVALID, // No key. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,7 +92,7 @@ namespace Console { | |
| Cmd::Args args(std::string(commandStart, commandEnd)); | ||
| int argNum = args.Argc() - 1; | ||
| std::string prefix; | ||
| if (!args.Argc() || Str::cisspace(GetText()[GetCursorPos() - 1])) { | ||
| if (!args.Argc() || !GetCursorPos() || Str::cisspace(GetText()[GetCursorPos() - 1])) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way things initially go wrong is with the subtraction underflow in |
||
| argNum++; | ||
| } else { | ||
| prefix = args.Argv(argNum); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1113,6 +1113,24 @@ static void IN_ProcessEvents( bool dropInput ) | |
| { | ||
| std::string text = e.text.text; | ||
|
|
||
| /* We can get a console key as a text event after we've opened the console from a key up/down event, | ||
| * in a separate execution of IN_ProcessEvents() | ||
| * The key character can also be anywhere in the text | ||
| * This might be an SDL bug */ | ||
| text.erase( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would break the feature where you can hold ALT to type a character that would otherwise be a console key (works on some Linux environments)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't that handled in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is where the ALT exemption is initially applied. But IIUC this new third level of console key filtering has no condition to check that, so such characters would be filtered out. |
||
| std::remove_if( text.begin(), text.end(), | ||
| []( unsigned char c ) { | ||
| for( const unsigned char key : Keyboard::GetConsoleKeysString() ) { | ||
| if ( c == key ) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
| ), text.end() | ||
| ); | ||
|
|
||
| const char* c = text.c_str(); | ||
| while ( *c ) { | ||
| int width = Q_UTF8_Width( c ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand, what is the point of forming a string with words like
ESCAPE,0x63etc.?