Improve text wrapping for preview
This commit is contained in:
Generated
+1
-1
@@ -2490,7 +2490,7 @@ namespace ChatTwo.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Only with parameter.
|
||||
/// Looks up a localized string similar to Must contain parameter.
|
||||
/// </summary>
|
||||
internal static string Options_PreviewOnlyIf_Name {
|
||||
get {
|
||||
|
||||
@@ -1076,7 +1076,7 @@
|
||||
<value>Tooltip</value>
|
||||
</data>
|
||||
<data name="Options_PreviewOnlyIf_Name" xml:space="preserve">
|
||||
<value>Only with parameter</value>
|
||||
<value>Must contain parameter</value>
|
||||
</data>
|
||||
<data name="Options_PreviewOnlyIf_Description" xml:space="preserve">
|
||||
<value>Show only if the text contains special parameter</value>
|
||||
|
||||
@@ -236,19 +236,30 @@ public class InputPreview : Window
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var letter in text.Content)
|
||||
var splits = text.Content.Split(" ");
|
||||
for (var i = 0; i < splits.Length; i++)
|
||||
{
|
||||
var letterSize = ImGui.CalcTextSize(letter.ToString());
|
||||
if (ImGui.GetContentRegionAvail().X < letterSize.X)
|
||||
// The last character should never be an empty string
|
||||
// Sorting this out because it leads to double whitespaces
|
||||
if (i + 1 == splits.Length && splits[i] == "")
|
||||
break;
|
||||
|
||||
var wordSize = ImGui.CalcTextSize(splits[i]);
|
||||
if (ImGui.GetContentRegionAvail().X < wordSize.X)
|
||||
ImGui.NewLine();
|
||||
|
||||
CursorPosition++;
|
||||
if (ImGui.Selectable($"{letter}##{CursorPosition + unique}", false, ImGuiSelectableFlags.None, letterSize))
|
||||
foreach (var letter in $"{splits[i]} ")
|
||||
{
|
||||
SelectedCursorPos = CursorPosition;
|
||||
LogWindow.KeepFocusedThroughPreview = true;
|
||||
var letterSize = ImGui.CalcTextSize(letter.ToString());
|
||||
|
||||
CursorPosition++;
|
||||
if (ImGui.Selectable($"{letter}##{CursorPosition + unique}", false, ImGuiSelectableFlags.None, letterSize))
|
||||
{
|
||||
SelectedCursorPos = CursorPosition;
|
||||
LogWindow.KeepFocusedThroughPreview = true;
|
||||
}
|
||||
ImGui.SameLine();
|
||||
}
|
||||
ImGui.SameLine();
|
||||
}
|
||||
ImGui.NewLine();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user