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