mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
Include control characters in TextInput FileNames and PathNames rules
This commit is contained in:
parent
04050b9144
commit
e4e7191d8d
2 changed files with 15 additions and 2 deletions
|
@ -24,6 +24,7 @@ Improvements
|
||||||
- Allow changing the default values used by default TextFormatter codes
|
- Allow changing the default values used by default TextFormatter codes
|
||||||
- Allow setting ExternalGestureHandling through the InputHandler constructor
|
- Allow setting ExternalGestureHandling through the InputHandler constructor
|
||||||
- Allow specifying start and end indices when drawing a TokenizedString
|
- Allow specifying start and end indices when drawing a TokenizedString
|
||||||
|
- Include control characters in TextInput FileNames and PathNames rules
|
||||||
|
|
||||||
Fixes
|
Fixes
|
||||||
- Fixed control characters being included in TextInput
|
- Fixed control characters being included in TextInput
|
||||||
|
|
|
@ -61,11 +61,23 @@ namespace MLEM.Input {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A <see cref="Rule"/> that only allows characters not contained in <see cref="Path.GetInvalidPathChars"/>
|
/// A <see cref="Rule"/> that only allows characters not contained in <see cref="Path.GetInvalidPathChars"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Rule PathNames = (input, add) => add.IndexOfAny(Path.GetInvalidPathChars()) < 0;
|
public static readonly Rule PathNames = (input, add) => {
|
||||||
|
foreach (var c in add) {
|
||||||
|
if (char.IsControl(c) || Path.GetInvalidPathChars().Contains(c))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A <see cref="Rule"/> that only allows characters not contained in <see cref="Path.GetInvalidFileNameChars"/>
|
/// A <see cref="Rule"/> that only allows characters not contained in <see cref="Path.GetInvalidFileNameChars"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Rule FileNames = (input, add) => add.IndexOfAny(Path.GetInvalidFileNameChars()) < 0;
|
public static readonly Rule FileNames = (input, add) => {
|
||||||
|
foreach (var c in add) {
|
||||||
|
if (char.IsControl(c) || Path.GetInvalidFileNameChars().Contains(c))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This text input's current text
|
/// This text input's current text
|
||||||
|
|
Loading…
Reference in a new issue