Skip to content

Commit

Permalink
fix for issue #189 slow startup (#194)
Browse files Browse the repository at this point in the history
* fix for long delay starting up on linux
  • Loading branch information
tomlm authored Dec 8, 2024
1 parent a256342 commit 4a17fb5
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,7 @@ public bool CaretVisible

public PixelBufferSize Size { get; private set; }

public bool SupportsComplexEmoji
{
get
{
if (_supportEmoji == null)
{
// Detect complex emoji support by writing a complex emoji and checking cursor position.
// If the cursor moves 2 positions, it indicates proper rendering of composite surrogate pairs.
(int left, int top) = Console.GetCursorPosition();
WriteText(
$"{Esc.Foreground(Colors.Transparent)}{Esc.Background(Colors.Transparent)}{TestEmoji}");

// TODO, escape sequence
(int left2, _) = Console.GetCursorPosition();
_supportEmoji = left2 - left == 2;
Console.SetCursorPosition(left, top);

WriteText(Esc.ClearScreen);
}

return _supportEmoji ?? true;
}
}
public bool SupportsComplexEmoji => _supportEmoji ?? false;

public void SetTitle(string title)
{
Expand Down Expand Up @@ -180,6 +158,15 @@ private void PrepareConsole()
// enable alternate screen so original console screen is not affected by the app
WriteText(Esc.EnableAlternateBuffer);
WriteText(Esc.HideCursor);
// Detect complex emoji support by writing a complex emoji and checking cursor position.
// If the cursor moves 2 positions, it indicates proper rendering of composite surrogate pairs.
(int left, int top) = Console.GetCursorPosition();
WriteText(
$"{Esc.Foreground(Colors.Transparent)}{Esc.Background(Colors.Transparent)}{TestEmoji}");
(int left2, _) = Console.GetCursorPosition();
_supportEmoji = left2 - left == 2;
Console.SetCursorPosition(left, top);

WriteText(Esc.ClearScreen);
#pragma warning restore CA1303 // Do not pass literals as localized parameters
}
Expand Down

0 comments on commit 4a17fb5

Please sign in to comment.