From aed3cbbf09f53d9eea9150628e1d5054349085fb Mon Sep 17 00:00:00 2001 From: Tom Laird-McConnell Date: Fri, 6 Dec 2024 13:39:24 -0800 Subject: [PATCH 1/2] fix for long delay starting up on linux --- .../InputLessDefaultNetConsole.cs | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs b/src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs index fa3f9dfc..2246660a 100644 --- a/src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs +++ b/src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs @@ -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 { get => _supportEmoji ?? false; } public void SetTitle(string title) { @@ -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 } @@ -195,6 +182,7 @@ protected bool CheckActualizeTheSize() protected void ActualizeSize() { + Size = new PixelBufferSize((ushort)Console.WindowWidth, (ushort)Console.WindowHeight); Resized?.Invoke(); } From 292771e561f3adbb0b10b394b563144914dc09c0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 6 Dec 2024 21:50:21 +0000 Subject: [PATCH 2/2] Automated JetBrains cleanup Co-authored-by: <+@users.noreply.github.com> --- .../Infrastructure/InputLessDefaultNetConsole.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs b/src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs index 2246660a..b2b42f91 100644 --- a/src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs +++ b/src/Consolonia.Core/Infrastructure/InputLessDefaultNetConsole.cs @@ -47,7 +47,7 @@ public bool CaretVisible public PixelBufferSize Size { get; private set; } - public bool SupportsComplexEmoji { get => _supportEmoji ?? false; } + public bool SupportsComplexEmoji => _supportEmoji ?? false; public void SetTitle(string title) { @@ -162,10 +162,10 @@ private void PrepareConsole() // 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(); + $"{Esc.Foreground(Colors.Transparent)}{Esc.Background(Colors.Transparent)}{TestEmoji}"); + (int left2, _) = Console.GetCursorPosition(); _supportEmoji = left2 - left == 2; - Console.SetCursorPosition(left, top); + Console.SetCursorPosition(left, top); WriteText(Esc.ClearScreen); #pragma warning restore CA1303 // Do not pass literals as localized parameters @@ -182,7 +182,6 @@ protected bool CheckActualizeTheSize() protected void ActualizeSize() { - Size = new PixelBufferSize((ushort)Console.WindowWidth, (ushort)Console.WindowHeight); Resized?.Invoke(); }