feat(input-bar): add SetPendingMessage/AppendPending mutators + Activate/FocusedPreview flags
Replaces v1.5.6's direct LogWindow.Chat mutation pattern with typed mutators that LogWarning + clip/drop on BufferCapacity overflow (silent-overwrite semantics preserved, but overflow is now observable via /xllog). Plumbing for v1.7.1 PayloadHandler resurrection — DrawPlayerPopup (tell- prefix) and DrawStatusPopup (status-link append) will call these mutators instead of mutating a public field.
This commit is contained in:
@@ -36,6 +36,9 @@ internal sealed class InputBar
|
||||
private bool _isFocused;
|
||||
private bool? _isFocusedOverride; // Test-only; null = honour per-frame Draw() value.
|
||||
|
||||
public bool Activate;
|
||||
public bool FocusedPreview;
|
||||
|
||||
public InputBar(
|
||||
SymbolPicker symbolPicker,
|
||||
FontManager fonts,
|
||||
@@ -69,6 +72,44 @@ internal sealed class InputBar
|
||||
|
||||
public void ClearBuffer() => _pendingMessage = string.Empty;
|
||||
|
||||
// BufferCapacity is an ImGui UX limit, not a protocol constraint. We
|
||||
// LogWarning + truncate/drop (matching v1.5.6's silent-overwrite semantics)
|
||||
// so overflow is observable via /xllog without forcing try/catch at call-sites.
|
||||
public void SetPendingMessage(string value)
|
||||
{
|
||||
if (value is null)
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
if (value.Length > BufferCapacity)
|
||||
{
|
||||
_logger.LogWarning(
|
||||
"SetPendingMessage: value of length {Length} exceeds BufferCapacity ({Capacity}); truncating.",
|
||||
value.Length,
|
||||
BufferCapacity
|
||||
);
|
||||
_pendingMessage = value[..BufferCapacity];
|
||||
}
|
||||
else
|
||||
{
|
||||
_pendingMessage = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void AppendPending(string suffix)
|
||||
{
|
||||
if (string.IsNullOrEmpty(suffix))
|
||||
return;
|
||||
if (_pendingMessage.Length + suffix.Length > BufferCapacity)
|
||||
{
|
||||
_logger.LogWarning(
|
||||
"AppendPending: appending {SuffixLength} chars would exceed BufferCapacity ({Capacity}); dropping suffix.",
|
||||
suffix.Length,
|
||||
BufferCapacity
|
||||
);
|
||||
return;
|
||||
}
|
||||
_pendingMessage += suffix;
|
||||
}
|
||||
|
||||
public void Draw(Tab? activeTab)
|
||||
{
|
||||
if (!_fonts.FontsReady)
|
||||
@@ -168,6 +209,12 @@ internal sealed class InputBar
|
||||
|
||||
private void DrawInputField(Tab? activeTab)
|
||||
{
|
||||
if (Activate)
|
||||
{
|
||||
ImGui.SetKeyboardFocusHere();
|
||||
Activate = false;
|
||||
}
|
||||
|
||||
ImGui.SetNextItemWidth(-QuickButtonsReserve);
|
||||
if (
|
||||
ImGui.InputText(
|
||||
|
||||
Reference in New Issue
Block a user