mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-12-25 17:21:55 +01:00
Merge pull request #5086 from zhaowenlan1779/swkbd-digit-fix
swkbd: Fix digit filter
This commit is contained in:
commit
821a35bd2b
@ -15,9 +15,9 @@ namespace Frontend {
|
|||||||
|
|
||||||
ValidationError SoftwareKeyboard::ValidateFilters(const std::string& input) const {
|
ValidationError SoftwareKeyboard::ValidateFilters(const std::string& input) const {
|
||||||
if (config.filters.prevent_digit) {
|
if (config.filters.prevent_digit) {
|
||||||
if (std::any_of(input.begin(), input.end(),
|
if (std::count_if(input.begin(), input.end(),
|
||||||
[](unsigned char c) { return std::isdigit(c); })) {
|
[](unsigned char c) { return std::isdigit(c); }) > config.max_digits) {
|
||||||
return ValidationError::DigitNotAllowed;
|
return ValidationError::MaxDigitsExceeded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.filters.prevent_at) {
|
if (config.filters.prevent_at) {
|
||||||
|
@ -47,8 +47,7 @@ struct KeyboardConfig {
|
|||||||
bool has_custom_button_text; /// If true, use the button_text instead
|
bool has_custom_button_text; /// If true, use the button_text instead
|
||||||
std::vector<std::string> button_text; /// Contains the button text that the caller provides
|
std::vector<std::string> button_text; /// Contains the button text that the caller provides
|
||||||
struct Filters {
|
struct Filters {
|
||||||
bool prevent_digit; /// Disallow the use of more than a certain number of digits
|
bool prevent_digit; /// Limit maximum digit count to max_digits
|
||||||
/// TODO: how many is a certain number
|
|
||||||
bool prevent_at; /// Disallow the use of the @ sign.
|
bool prevent_at; /// Disallow the use of the @ sign.
|
||||||
bool prevent_percent; /// Disallow the use of the % sign.
|
bool prevent_percent; /// Disallow the use of the % sign.
|
||||||
bool prevent_backslash; /// Disallow the use of the \ sign.
|
bool prevent_backslash; /// Disallow the use of the \ sign.
|
||||||
@ -68,7 +67,7 @@ enum class ValidationError {
|
|||||||
// Button Selection
|
// Button Selection
|
||||||
ButtonOutOfRange,
|
ButtonOutOfRange,
|
||||||
// Configured Filters
|
// Configured Filters
|
||||||
DigitNotAllowed,
|
MaxDigitsExceeded,
|
||||||
AtSignNotAllowed,
|
AtSignNotAllowed,
|
||||||
PercentNotAllowed,
|
PercentNotAllowed,
|
||||||
BackslashNotAllowed,
|
BackslashNotAllowed,
|
||||||
|
Loading…
Reference in New Issue
Block a user