Cosmos icon indicating copy to clipboard operation
Cosmos copied to clipboard

Console Bugs

Open glintpry opened this issue 2 years ago • 0 comments

Area of Cosmos - What area of Cosmos are we dealing with?

Cosmos Inner-code bug.

Expected Behaviour - What do you think that should happen?

Identical to .NET Console behavior must be expected just with a 80x25 size.

Actual Behaviour - What unexpectedly happens?

Proper functioning of placements of text in code

Reproduction - How did you get this error to appear?

The code is:

public const int CWidth = 80;
public const int CHeight = 25;
public const string kernelName = "Test";
public const string kernelVersion = "v1.0";
public const ConsoleColor consoleKernelAccentColor = ConsoleColor.DarkCyan;

public static int finalSelection = 0;

public static void Run()
{
    var disks = new List<string>() { "0:\\", "1:\\", "2:\\" };

    Console.BackgroundColor = consoleKernelAccentColor;
    Console.ForegroundColor = ConsoleColor.White;
    Console.Clear();
    Console.WriteLine(kernelName + " " + kernelVersion + " Installer (via Cosmares)");

    Console.CursorLeft = 0;
    Console.CursorTop = CHeight;
    Console.BackgroundColor = ConsoleColor.DarkGray;
    Console.Write(new string(' ', CWidth));
    Console.CursorLeft = 0;
    Console.CursorTop = CHeight;
    Console.ForegroundColor = ConsoleColor.Black;
    Console.Write("Use arrow keys to move, space to select and enter to next.");

    var winX = CWidth / 16;
    var winY = 3;
    var winWidth = CWidth - (CWidth / 16) - 5;
    var winHeight = CHeight - 5;
    Console.BackgroundColor = ConsoleColor.White;
    for (var i = 0; i < winHeight; i++)
    {
        Console.CursorLeft = winX;
        Console.CursorTop = winY + i;
        Console.Write(new string(' ', winWidth));
    }

    Console.CursorLeft = winX + 2;
    Console.CursorTop = winY + 1;
    Console.Write("Select a disk:");

    var boxX = winX + 4;
    var boxY = winY + 3;
    var boxWidth = winWidth - 8; // (winWidth - (4*2))
    var boxHeight = winHeight - 6; // (winHeight - (3*2))
    Console.BackgroundColor = ConsoleColor.Gray;
    for (var i = 0; i < boxHeight; i++)
    {
        Console.CursorLeft = boxX;
        Console.CursorTop = boxY + i;
        Console.Write(new string(' ', boxWidth));
    }

    var selected = 0;
    var selectedVal = disks[selected];
    var hovered = 0;
    var hoveredVal = disks[hovered];
update:
    var diskIndex = 0;
    for (var i = 0; i < disks.Count; i++)
    {
        if (i == selected)
        {
            Console.BackgroundColor = consoleKernelAccentColor;
        } else if (i == hovered)
        {
            Console.BackgroundColor = ConsoleColor.DarkGray;
        }

        Console.CursorLeft = boxX;
        Console.CursorTop = boxY + i;
        Console.Write(new string(' ', boxWidth));
        Console.CursorLeft = boxX;
        Console.CursorTop = boxY + i;
        Console.Write(disks[i]);
        Console.BackgroundColor = ConsoleColor.Gray;
    }

    var key = Console.ReadKey(true);
    while (key.Modifiers != ConsoleModifiers.Control && key.Modifiers != ConsoleModifiers.Shift && key.Key != ConsoleKey.Escape)
    {
        if (key.Key == ConsoleKey.UpArrow && hovered - 1 > -1)
        {
            hovered--;
            goto update;
        }
        else if (key.Key == ConsoleKey.DownArrow && hovered + 1 < disks.Count)
        {
            hovered++;
            goto update;
        }
        else if (key.Key == ConsoleKey.Enter)
        {
            finalSelection = selected;
            return;
        }
        else if (key.Key == ConsoleKey.Spacebar)
        {
            selected = hovered;
            goto update;
        }
        key = Console.ReadKey(true);
    }
    return;
}

Version - Were you using the User Kit or Dev Kit? And what User Kit version or Dev Kit commit (Cosmos, IL2CPU, X#)?

It is the latest DevKit and its part of the main cosmos base.

Screenshots:

Expected first, and cosmos second image image

The CWidth and CHeight are used in both code so the 80x25 console can be used in the .NET one

glintpry avatar Mar 05 '24 15:03 glintpry

just use svgaiiterminal /j

9xbt avatar Mar 08 '24 21:03 9xbt