Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
imp - Use alternative buffer
Browse files Browse the repository at this point in the history
We need to use alternative buffer

---

We need to use alternative buffer if we're running on Unix. This ensures
that all GRILO pre-boot output are saved once it shuts down.

---

Type: imp
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Aug 8, 2023
1 parent ae26073 commit 13e653e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions GRILO.Bootloader/GRILO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using GRILO.Bootloader.Diagnostics;
using GRILO.Bootloader.KeyHandler;
using System.Linq;
using Terminaux.Sequences.Builder;
using Terminaux.Reader.Inputs;
using Terminaux.Writer.ConsoleWriters;

Expand All @@ -41,6 +42,7 @@ internal class GRILO
internal static bool waitingForBootKey = true;
internal static bool waitingForFirstBootKey = true;
internal static string griloVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
internal static bool isOnAlternativeBuffer = false;

static void Main()
{
Expand All @@ -66,6 +68,13 @@ static void Main()
var bootApps = BootManager.GetBootApps();
DiagnosticsWriter.WriteDiag(DiagnosticsLevel.Info, "Bootable apps read successfully.");

// Switch to alternative buffer
if (!GRILOPlatform.IsOnWindows())
{
TextWriterColor.WritePlain($"{VtSequenceBasicChars.EscapeChar}7{VtSequenceBasicChars.EscapeChar}[?47h", false);
isOnAlternativeBuffer = true;
}

// Now, draw the boot menu. Note that the chosen boot entry counts from zero.
int chosenBootEntry = Config.Instance.BootSelect;
while (!shutdownRequested)
Expand Down Expand Up @@ -216,6 +225,12 @@ Controls defined by custom boot style
TextWriterColor.Write("Press any key to exit.");
Input.DetectKeypress();
}
finally
{
if (isOnAlternativeBuffer)
TextWriterColor.WritePlain($"{VtSequenceBasicChars.EscapeChar}[2J{VtSequenceBasicChars.EscapeChar}[?47l{VtSequenceBasicChars.EscapeChar}8", false);
Console.CursorVisible = true;
}
}
}
}

0 comments on commit 13e653e

Please sign in to comment.