mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Refactor exit handling and command input in TUI
- Improved the exit process by ensuring the backend shutdown is called after handling offline prompts. - Enhanced command input history management by encapsulating text setting logic in a dedicated method to prevent event handler interference. - Adjusted the background color in the color parser for better visibility. - Increased the sleep duration in the TUI exit guard thread to ensure a smoother shutdown process.
This commit is contained in:
parent
0ceaaead10
commit
b33ee7e4a1
4 changed files with 79 additions and 67 deletions
|
|
@ -494,10 +494,21 @@ namespace MinecraftClient.Tui
|
|||
}
|
||||
|
||||
string historyText = _commandHistory[_historyIndex];
|
||||
_commandInput.Text = historyText;
|
||||
_commandInput.CaretIndex = historyText.Length;
|
||||
Dispatcher.UIThread.Post(() => _commandInput.CaretIndex = historyText.Length,
|
||||
DispatcherPriority.Input);
|
||||
SetCommandText(historyText);
|
||||
}
|
||||
|
||||
private void SetCommandText(string text)
|
||||
{
|
||||
_commandInput.TextChanged -= OnCommandTextChanged;
|
||||
try
|
||||
{
|
||||
_commandInput.Text = text;
|
||||
_commandInput.CaretIndex = text.Length;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_commandInput.TextChanged += OnCommandTextChanged;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ namespace MinecraftClient.Tui
|
|||
return tb;
|
||||
}
|
||||
|
||||
tb.Background = Brushes.Black;
|
||||
|
||||
IBrush currentColor = Brushes.White;
|
||||
bool bold = false;
|
||||
bool italic = false;
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ namespace MinecraftClient.Tui
|
|||
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
Thread.Sleep(1000);
|
||||
Environment.Exit(0);
|
||||
}) { Name = "TUI-Exit-Guard", IsBackground = true }.Start();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue