mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-27 06:58:34 +01:00
Compare commits
No commits in common. "62a7a898349c795439a7901f21e456236d3764be" and "50da081be987f0bd13b28b5f61e21713b9396230" have entirely different histories.
62a7a89834
...
50da081be9
3 changed files with 5 additions and 22 deletions
|
@ -17,9 +17,6 @@ Jump to version:
|
||||||
Additions
|
Additions
|
||||||
- Added GraphicsExtensions.WithRenderTargets, a multi-target version of WithRenderTarget
|
- Added GraphicsExtensions.WithRenderTargets, a multi-target version of WithRenderTarget
|
||||||
|
|
||||||
Fixes
|
|
||||||
- Fixed TextInput not working correctly when using surrogate pairs
|
|
||||||
|
|
||||||
## 6.2.0
|
## 6.2.0
|
||||||
|
|
||||||
### MLEM
|
### MLEM
|
||||||
|
|
|
@ -63,18 +63,6 @@ namespace MLEM.Font {
|
||||||
return (curr, 1);
|
return (curr, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns an index in this code point source that is as close to <paramref name="index"/> as possible, but not between two members of a surrogate pair. If the <paramref name="index"/> is already not between surrogate pairs, it is returned unchanged.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="index">The index to ensure is not between surrogates.</param>
|
|
||||||
/// <param name="increase">Whether the returned index should be increased by 1 (instead of decreased by 1) when it is between surrogates.</param>
|
|
||||||
/// <returns>An index close to <paramref name="index"/>, but not between surrogates.</returns>
|
|
||||||
public int EnsureSurrogateBoundary(int index, bool increase) {
|
|
||||||
if (index < this.Length && char.IsLowSurrogate(this[index]))
|
|
||||||
return increase || index <= 0 ? index + 1 : index - 1;
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Returns an enumerator that iterates through the collection.</summary>
|
/// <summary>Returns an enumerator that iterates through the collection.</summary>
|
||||||
/// <returns>A <see cref="T:System.Collections.Generic.IEnumerator`1" /> that can be used to iterate through the collection.</returns>
|
/// <returns>A <see cref="T:System.Collections.Generic.IEnumerator`1" /> that can be used to iterate through the collection.</returns>
|
||||||
/// <filterpriority>1</filterpriority>
|
/// <filterpriority>1</filterpriority>
|
||||||
|
|
|
@ -105,8 +105,7 @@ namespace MLEM.Input {
|
||||||
set {
|
set {
|
||||||
var val = (int) MathHelper.Clamp(value, 0F, this.text.Length);
|
var val = (int) MathHelper.Clamp(value, 0F, this.text.Length);
|
||||||
if (this.caretPos != val) {
|
if (this.caretPos != val) {
|
||||||
// ensure that we don't move to a location that is between high and low surrogates
|
this.caretPos = val;
|
||||||
this.caretPos = new CodePointSource(this.text).EnsureSurrogateBoundary(val, val > this.caretPos);
|
|
||||||
this.caretBlinkTimer = 0;
|
this.caretBlinkTimer = 0;
|
||||||
this.SetTextDataDirty(false);
|
this.SetTextDataDirty(false);
|
||||||
}
|
}
|
||||||
|
@ -361,7 +360,7 @@ namespace MLEM.Input {
|
||||||
if (!this.FilterText(ref strg, removeMismatching))
|
if (!this.FilterText(ref strg, removeMismatching))
|
||||||
return;
|
return;
|
||||||
if (this.MaximumCharacters != null && strg.Length > this.MaximumCharacters)
|
if (this.MaximumCharacters != null && strg.Length > this.MaximumCharacters)
|
||||||
strg = strg.Substring(0, new CodePointSource(strg).EnsureSurrogateBoundary(this.MaximumCharacters.Value, false));
|
strg = strg.Substring(0, this.MaximumCharacters.Value);
|
||||||
this.text.Clear();
|
this.text.Clear();
|
||||||
this.text.Append(strg);
|
this.text.Append(strg);
|
||||||
this.CaretPos = this.text.Length;
|
this.CaretPos = this.text.Length;
|
||||||
|
@ -379,7 +378,7 @@ namespace MLEM.Input {
|
||||||
if (!this.FilterText(ref strg, removeMismatching))
|
if (!this.FilterText(ref strg, removeMismatching))
|
||||||
return false;
|
return false;
|
||||||
if (this.MaximumCharacters != null && this.text.Length + strg.Length > this.MaximumCharacters)
|
if (this.MaximumCharacters != null && this.text.Length + strg.Length > this.MaximumCharacters)
|
||||||
strg = strg.Substring(0, new CodePointSource(strg).EnsureSurrogateBoundary(this.MaximumCharacters.Value - this.text.Length, false));
|
strg = strg.Substring(0, this.MaximumCharacters.Value - this.text.Length);
|
||||||
this.text.Insert(this.CaretPos, strg);
|
this.text.Insert(this.CaretPos, strg);
|
||||||
this.CaretPos += strg.Length;
|
this.CaretPos += strg.Length;
|
||||||
this.SetTextDataDirty();
|
this.SetTextDataDirty();
|
||||||
|
@ -394,8 +393,7 @@ namespace MLEM.Input {
|
||||||
public bool RemoveText(int index, int length) {
|
public bool RemoveText(int index, int length) {
|
||||||
if (index < 0 || index >= this.text.Length)
|
if (index < 0 || index >= this.text.Length)
|
||||||
return false;
|
return false;
|
||||||
var source = new CodePointSource(this.text);
|
this.text.Remove(index, length);
|
||||||
this.text.Remove(source.EnsureSurrogateBoundary(index, false), source.EnsureSurrogateBoundary(index + length, true) - index);
|
|
||||||
// ensure that caret pos is still in bounds
|
// ensure that caret pos is still in bounds
|
||||||
this.CaretPos = this.CaretPos;
|
this.CaretPos = this.CaretPos;
|
||||||
this.SetTextDataDirty();
|
this.SetTextDataDirty();
|
||||||
|
@ -419,7 +417,7 @@ namespace MLEM.Input {
|
||||||
this.CaretPos = destStart + destAccum.Length;
|
this.CaretPos = destStart + destAccum.Length;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
destAccum += CodePointSource.ToString(new CodePointSource(this.text).GetCodePoint(destStart + destAccum.Length).CodePoint);
|
destAccum += this.text[destStart + destAccum.Length];
|
||||||
}
|
}
|
||||||
// if we don't find a proper position, just move to the end of the destination line
|
// if we don't find a proper position, just move to the end of the destination line
|
||||||
this.CaretPos = destEnd;
|
this.CaretPos = destEnd;
|
||||||
|
|
Loading…
Reference in a new issue