popout: opt-in ChatInputBar with focus-aware keybind routing
This commit is contained in:
@@ -5,7 +5,11 @@ namespace ChatTwo;
|
||||
// Hellion Chat — v0.6.0 shared input history. Replaces the embedded
|
||||
// ChatLogWindow.InputBacklog so that pop-out windows with their own
|
||||
// ChatInputBar can navigate the same Up/Down history as the main window.
|
||||
// Newest entry at index 0; consecutive duplicates are collapsed.
|
||||
// Index semantics are kept identical to the v0.5.x InputBacklog:
|
||||
// index 0 = oldest entry
|
||||
// index Count - 1 = newest entry
|
||||
// Push performs move-to-newest deduplication: existing entries are
|
||||
// removed before the new one is appended at the end.
|
||||
public static class InputHistoryService
|
||||
{
|
||||
private const int MaxSize = 30;
|
||||
@@ -13,6 +17,8 @@ public static class InputHistoryService
|
||||
|
||||
public static IReadOnlyList<string> Entries => _entries;
|
||||
|
||||
public static int Count => _entries.Count;
|
||||
|
||||
public static void Push(string entry)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(entry))
|
||||
@@ -20,14 +26,20 @@ public static class InputHistoryService
|
||||
|
||||
var trimmed = entry.Trim();
|
||||
|
||||
// Drop consecutive duplicates so spamming the same line does not
|
||||
// pollute the history with repeats.
|
||||
if (_entries.Count > 0 && _entries[0] == trimmed)
|
||||
return;
|
||||
// Move-to-newest: existing entries are removed before the append
|
||||
// so the same line typed twice does not occupy two history slots.
|
||||
for (var i = 0; i < _entries.Count; i++)
|
||||
{
|
||||
if (_entries[i] == trimmed)
|
||||
{
|
||||
_entries.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_entries.Insert(0, trimmed);
|
||||
_entries.Add(trimmed);
|
||||
if (_entries.Count > MaxSize)
|
||||
_entries.RemoveAt(_entries.Count - 1);
|
||||
_entries.RemoveAt(0);
|
||||
}
|
||||
|
||||
public static string? GetByCursor(int cursor)
|
||||
@@ -36,6 +48,4 @@ public static class InputHistoryService
|
||||
return null;
|
||||
return _entries[cursor];
|
||||
}
|
||||
|
||||
public static int Count => _entries.Count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user