refactor: migrate input history from ChatLogWindow.InputBacklog to InputHistoryService
This commit is contained in:
+11
-14
@@ -44,7 +44,10 @@ public sealed class ChatLogWindow : Window
|
|||||||
internal bool InputFocused { get; private set; }
|
internal bool InputFocused { get; private set; }
|
||||||
private int ActivatePos = -1;
|
private int ActivatePos = -1;
|
||||||
internal string Chat = string.Empty;
|
internal string Chat = string.Empty;
|
||||||
private readonly List<string> InputBacklog = [];
|
// Hellion Chat — v0.6.0 input history was extracted into
|
||||||
|
// InputHistoryService so pop-out windows with their own ChatInputBar
|
||||||
|
// share the same Up/Down history with the main window. The cursor
|
||||||
|
// stays window-local because each window navigates independently.
|
||||||
private int InputBacklogIdx = -1;
|
private int InputBacklogIdx = -1;
|
||||||
public bool TellSpecial;
|
public bool TellSpecial;
|
||||||
private readonly Stopwatch LastResize = new();
|
private readonly Stopwatch LastResize = new();
|
||||||
@@ -330,16 +333,10 @@ public sealed class ChatLogWindow : Window
|
|||||||
|
|
||||||
private void AddBacklog(string message)
|
private void AddBacklog(string message)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < InputBacklog.Count; i++)
|
// v0.6.0 — delegates to the shared InputHistoryService so pop-out
|
||||||
{
|
// ChatInputBar instances see the same history. Move-to-newest
|
||||||
if (InputBacklog[i] != message)
|
// deduplication lives inside the service.
|
||||||
continue;
|
InputHistoryService.Push(message);
|
||||||
|
|
||||||
InputBacklog.RemoveAt(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
InputBacklog.Add(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private float GetRemainingHeightForMessageLog()
|
private float GetRemainingHeightForMessageLog()
|
||||||
@@ -1757,7 +1754,7 @@ public sealed class ChatLogWindow : Window
|
|||||||
offset = 1;
|
offset = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputBacklogIdx = InputBacklog.Count - 1 - offset;
|
InputBacklogIdx = InputHistoryService.Count - 1 - offset;
|
||||||
break;
|
break;
|
||||||
case > 0:
|
case > 0:
|
||||||
InputBacklogIdx--;
|
InputBacklogIdx--;
|
||||||
@@ -1766,7 +1763,7 @@ public sealed class ChatLogWindow : Window
|
|||||||
break;
|
break;
|
||||||
case ImGuiKey.DownArrow:
|
case ImGuiKey.DownArrow:
|
||||||
if (InputBacklogIdx != -1)
|
if (InputBacklogIdx != -1)
|
||||||
if (++InputBacklogIdx >= InputBacklog.Count)
|
if (++InputBacklogIdx >= InputHistoryService.Count)
|
||||||
InputBacklogIdx = -1;
|
InputBacklogIdx = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1774,7 +1771,7 @@ public sealed class ChatLogWindow : Window
|
|||||||
if (prevPos == InputBacklogIdx)
|
if (prevPos == InputBacklogIdx)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
var historyStr = InputBacklogIdx >= 0 ? InputBacklog[InputBacklogIdx] : string.Empty;
|
var historyStr = InputHistoryService.GetByCursor(InputBacklogIdx) ?? string.Empty;
|
||||||
data.DeleteChars(0, data.BufTextLen);
|
data.DeleteChars(0, data.BufTextLen);
|
||||||
data.InsertChars(0, historyStr);
|
data.InsertChars(0, historyStr);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user