2

I'm using https://github.com/tomakita/Colorful.Console, but I don't mind solutions that wouldn't include this nuget.

using System;
using System.Collections.Generic;
using System.Drawing;
using Colorful;

namespace CMDAdv
{
    class Program
    {
        static void Main()
        {
            Colorful.Console.WriteLineFormatted(Dialog.intro, Color.Tomato, ColorfulDescription());
            Advance("What will you do?", "examine shimmer");
            Colorful.Console.Clear();
            Advance("continue", "no");
        }

        static void Advance(string writeOutput, string required)
        {
            string input;
            Colorful.Console.WriteLine(writeOutput, Color.BlanchedAlmond);
            input = ReadLine();

            while (!input.Equals(required, StringComparison.OrdinalIgnoreCase))
            {
                Colorful.Console.WriteLine("Try again.", Color.Red);
                input = Colorful.Console.ReadLine();
            }
        }
        
        static string ReadLine(string input, string color)
        {
            input = Colorful.Console.ReadLine();
            color = Colorful.Console.ToString(Color.Red);
            return input;
        }

        static Formatter[] ColorfulDescription()
        {
            Formatter[] coloredText = new Formatter[]
            {
                new Formatter("shimmer", Color.LightBlue)

            };
            return coloredText;
        }
    }
}

As you can see I tried to add color to ReadLine using a method but that doesn't really work. Anyone know how to do this?

I'm using Colorful.Console, also I have tried different ways such as ReadLine(Color.Pink); etc etc.

Daethic
  • 29
  • 2
  • Check this link maybe it can help you: https://stackoverflow.com/questions/2743260/is-it-possible-to-write-to-the-console-in-colour-in-net – Arianit Jan 14 '21 at 22:16
  • 1
    I've edited code so it is crystal clear you are not asking about standard Console functions. If you feel that this edit was too drastic please come up with another way to avoid confusion with regular `System.Console` methods. Also point to the library you are using (presumably https://github.com/tomakita/Colorful.Console). Also also clarify if you need to use Colorful or looking for solution without it too. – Alexei Levenkov Jan 14 '21 at 22:18
  • How does your code manage to call `input = ReadLine();` with no arguments? And what does "reading a color" even mean? To me it seems a bit like saying "how can I make the words I speak purple?" – Caius Jard Jan 14 '21 at 22:28
  • No idea @CaiusJard. That code does not work either way. – Daethic Jan 15 '21 at 12:44

0 Answers0