mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 14:38:34 +01:00
put StringBuilder overloads to use
This commit is contained in:
parent
f5adf50823
commit
c060d78010
2 changed files with 7 additions and 2 deletions
|
@ -423,7 +423,7 @@ namespace MLEM.Ui.Elements {
|
||||||
var maxWidth = this.DisplayArea.Width / this.Scale - this.TextOffsetX * 2;
|
var maxWidth = this.DisplayArea.Width / this.Scale - this.TextOffsetX * 2;
|
||||||
if (this.Multiline) {
|
if (this.Multiline) {
|
||||||
// soft wrap if we're multiline
|
// soft wrap if we're multiline
|
||||||
this.splitText = this.Font.Value.SplitStringSeparate(this.text.ToString(), maxWidth, this.TextScale).ToArray();
|
this.splitText = this.Font.Value.SplitStringSeparate(this.text, maxWidth, this.TextScale).ToArray();
|
||||||
this.displayedText = string.Join("\n", this.splitText);
|
this.displayedText = string.Join("\n", this.splitText);
|
||||||
this.UpdateCaretData();
|
this.UpdateCaretData();
|
||||||
|
|
||||||
|
@ -466,7 +466,7 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// not multiline, so scroll horizontally based on caret position
|
// not multiline, so scroll horizontally based on caret position
|
||||||
if (this.Font.Value.MeasureString(this.text.ToString()).X * this.TextScale > maxWidth) {
|
if (this.Font.Value.MeasureString(this.text).X * this.TextScale > maxWidth) {
|
||||||
if (this.textOffset > this.CaretPos) {
|
if (this.textOffset > this.CaretPos) {
|
||||||
// if we're moving the caret to the left
|
// if we're moving the caret to the left
|
||||||
this.textOffset = this.CaretPos;
|
this.textOffset = this.CaretPos;
|
||||||
|
|
|
@ -110,6 +110,11 @@ namespace MLEM.Font {
|
||||||
return this.MeasureString(new CharSource(text), ignoreTrailingSpaces, null);
|
return this.MeasureString(new CharSource(text), ignoreTrailingSpaces, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="MeasureString(string,bool)"/>
|
||||||
|
public Vector2 MeasureString(StringBuilder text, bool ignoreTrailingSpaces = false) {
|
||||||
|
return this.MeasureString(new CharSource(text), ignoreTrailingSpaces, null);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Truncates a string to a given width. If the string's displayed area is larger than the maximum width, the string is cut off.
|
/// Truncates a string to a given width. If the string's displayed area is larger than the maximum width, the string is cut off.
|
||||||
/// Optionally, the string can be cut off a bit sooner, adding the <paramref name="ellipsis"/> at the end instead.
|
/// Optionally, the string can be cut off a bit sooner, adding the <paramref name="ellipsis"/> at the end instead.
|
||||||
|
|
Loading…
Reference in a new issue