Skip to content

Commit

Permalink
imp - Clear whole buffer for Windows conhost
Browse files Browse the repository at this point in the history
---

For the console host, we need to clear the entire buffer.

---

Type: imp
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Feb 26, 2024
1 parent 86e0956 commit 667036d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ static string UpdateHeadline()
var display = new StringBuilder();
// Clear the console and write the time using figlet
display.Append(
CsiSequences.GenerateCsiCursorPosition(1, 1) +
CsiSequences.GenerateCsiEraseInDisplay(0)
);
ConsoleWrapper.ClearLoadBack();
cachedTimeStr = TimeDateRenderers.RenderTime(FormatType.Short);
var figFont = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);
int figHeight = FigletTools.GetFigletHeight(timeStr, figFont) / 2;
Expand Down
10 changes: 8 additions & 2 deletions public/Nitrocid/Drivers/Console/BaseConsoleDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using Terminaux.Colors;
using System.Runtime.Serialization;
using Terminaux.Writer.DynamicWriters;
using SpecProbe.Platform;

namespace Nitrocid.Drivers.Console
{
Expand Down Expand Up @@ -262,8 +263,13 @@ public virtual void Clear(bool loadBack = false)
{
if (loadBack)
SystemConsole.Write(ColorTools.CurrentBackgroundColor.VTSequenceBackground);
SetCursorPosition(0, 0);
SystemConsole.Write(CsiSequences.GenerateCsiEraseInDisplay(0));
if (PlatformHelper.IsOnWindowsOrWsl())
SystemConsole.Clear();
else
{
SetCursorPosition(0, 0);
SystemConsole.Write(CsiSequences.GenerateCsiEraseInDisplay(0));
}
}
}

Expand Down
19 changes: 5 additions & 14 deletions public/Nitrocid/Misc/Splash/BaseSplash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Threading;
using Nitrocid.ConsoleBase.Colors;
using Nitrocid.Kernel.Debugging;
using Terminaux.Base;
using Terminaux.Colors;
using Terminaux.Sequences.Builder.Types;

Expand Down Expand Up @@ -50,14 +51,9 @@ public class BaseSplash : ISplash
/// <inheritdoc/>
public virtual string Opening(SplashContext context)
{
var builder = new StringBuilder();
DebugWriter.WriteDebug(DebugLevel.I, "Splash opening. Clearing console...");
ColorTools.SetConsoleColor(KernelColorTools.GetColor(KernelColorType.Background), true);
builder.Append(
CsiSequences.GenerateCsiCursorPosition(1, 1) +
CsiSequences.GenerateCsiEraseInDisplay(0)
);
return builder.ToString();
ConsoleWrapper.ClearLoadBack();
return "";
}

/// <inheritdoc/>
Expand All @@ -77,15 +73,10 @@ public virtual string Display(SplashContext context)
/// <inheritdoc/>
public virtual string Closing(SplashContext context, out bool delayRequired)
{
var builder = new StringBuilder();
DebugWriter.WriteDebug(DebugLevel.I, "Splash closing. Clearing console...");
ColorTools.SetConsoleColor(KernelColorTools.GetColor(KernelColorType.Background), true);
builder.Append(
CsiSequences.GenerateCsiCursorPosition(1, 1) +
CsiSequences.GenerateCsiEraseInDisplay(0)
);
ConsoleWrapper.ClearLoadBack();
delayRequired = false;
return builder.ToString();
return "";
}

/// <inheritdoc/>
Expand Down
5 changes: 1 addition & 4 deletions public/Nitrocid/Users/Login/ModernLogonScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ static string UpdateHeadline()
var display = new StringBuilder();
// Clear the console and write the time using figlet
display.Append(
CsiSequences.GenerateCsiCursorPosition(1, 1) +
CsiSequences.GenerateCsiEraseInDisplay(0)
);
ConsoleWrapper.ClearLoadBack();
cachedTimeStr = TimeDateRenderers.RenderTime(FormatType.Short);
var figFont = FigletTools.GetFigletFont(Config.MainConfig.DefaultFigletFontName);
int figHeight = FigletTools.GetFigletHeight(timeStr, figFont) / 2;
Expand Down

0 comments on commit 667036d

Please sign in to comment.