* Only allow certain keys. You can define the filter to be used. This makes * sure no invalid keys can get into an editbox, like BELL. * @param key character to be checked * @param afilter the filter to use * @return true or false depending if the character is printable/valid or not */
| 371 | * @return true or false depending if the character is printable/valid or not |
| 372 | */ |
| 373 | bool IsValidChar(char32_t key, CharSetFilter afilter) |
| 374 | { |
| 375 | switch (afilter) { |
| 376 | case CS_ALPHANUMERAL: return IsPrintable(key); |
| 377 | case CS_NUMERAL: return (key >= '0' && key <= '9'); |
| 378 | case CS_NUMERAL_SPACE: return (key >= '0' && key <= '9') || key == ' '; |
| 379 | case CS_NUMERAL_SIGNED: return (key >= '0' && key <= '9') || key == '-'; |
| 380 | case CS_ALPHA: return IsPrintable(key) && !(key >= '0' && key <= '9'); |
| 381 | case CS_HEXADECIMAL: return (key >= '0' && key <= '9') || (key >= 'a' && key <= 'f') || (key >= 'A' && key <= 'F'); |
| 382 | default: NOT_REACHED(); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * Test if a unicode character is considered garbage to be skipped. |
no test coverage detected