Code Monkey home page Code Monkey logo

colorful.console's People

Contributors

adam8797 avatar chandler-davidson avatar drewnoakes avatar jamieg avatar k0rsh avatar midianok avatar ollelogdahl avatar redbaty avatar rehansaeed avatar shreyasjejurkar avatar tomakita avatar zolrath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colorful.console's Issues

Horizontal color alternation?

Hi!

Love your library! Thank you very much for making it!
I'd like to print something in ASCII (e.g. "mySign"), with the word "my" painted in one color, and the word "Sign" in another.
Is it something I should be able to do with PatternBasedColorAlternator? Because I'm afraid I can't get it to work... I tried:

   Colorful.Console.WriteAsciiAlternating("mySign", 
                new PatternBasedColorAlternator<string>(new TextPatternCollection(new[] { "my", "Sign" }), Color.Yellow, Color.Orange));

but that only outputs it in yellow... I must be holding it wrong.

Any suggestions?

Doesn't work by default with JetBrains Rider (due to a issue in Rider)

As you may know, JetBrains announced a .NET IDE of their own called Rider, which is based on the IntelliJ platform.
By default, when launching console applications, Rider redirects the output to its own Output pane, rather than launching the actual console.

This causes Colorful.Console to throw:

Unhandled Exception: Colorful.ColorMappingException: Color conversion failed with system error code 6!
 at Colorful.ColorMapper.MapColor(ConsoleColor color, UInt32 r, UInt32 g, UInt32 b)
 at Colorful.ColorMapper.MapColor(ConsoleColor oldColor, Color newColor)
 at Colorful.ColorManager.GetConsoleColor(Color color)
 at Colorful.Console.MapToScreen(StyledString styledString, String trailer)
 at Colorful.Console.WriteAsciiInColorStyled(String trailer, StyledString target, StyleSheet styleSheet)
 at Colorful.Console.WriteLineStyled(StyledString value, StyleSheet styleSheet)
 at Colorful.Console.WriteAsciiStyled(String value, FigletFont font, StyleSheet styleSheet)
 at Program.Main(String[] args)

The "6" comes from Marshal.GetLastWin32Error(), and it's the value for invalid handle. Looking at the library's source, I see the source of the error here: https://github.com/tomakita/Colorful.Console/blob/master/src/Colorful.Console/ColorMapper.cs#L107

My best guess, is since Rider's Output window is not a real console, it doesn't have a handle, and the library fails because of it.

I'm not sure what can be done about this, but I wanted to give you heads up about it, and let you know that I've also submitted this bug to JetBrains here: https://youtrack.jetbrains.com/issue/RIDER-389

NuGet Package

This project is cool and deserves more recognition. I was sad to find that there isn't a NuGet package for it (Or at least I could not find one).

Console text not colored in AllocConsoles

So I'm using AllocConsole in my C# WPF application and did this:
Console.WriteLine("Results have finished. Review any warnings or errors you are getting above to make sure running the process works well.", Color.Yellow);

Though, it's still in the standard color. Any help with this?

Extend to 256 colors limit in Windows 10 Anniversary Update

Windows 10 Anniversary Update can use VT100 terminal codes. (Enabled by setting flag ENABLE_VIRTUAL_TERMINAL_PROCESSING by SetConsoleMode) and have 256 extended colors.

Howto:
http://stackoverflow.com/a/43321133/7815105
https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx

Sample (uses indexes)
`
class Program
{
[DllImport( "kernel32.dll", SetLastError = true )]
public static extern bool SetConsoleMode( IntPtr hConsoleHandle, int mode );
[DllImport( "kernel32.dll", SetLastError = true )]
public static extern bool GetConsoleMode( IntPtr handle, out int mode );
[DllImport( "kernel32.dll", SetLastError = true )]
public static extern IntPtr GetStdHandle( int handle );

	static void Main( string[] args )
	{
		var handle = GetStdHandle( -11 );
		int mode;
		GetConsoleMode( handle, out mode );
		SetConsoleMode( handle, mode | 0x4 );

		for (int i=0;i<255;i++ )
		{
			Console.Write( "\x1b[48;5;" + i + "m*" );
		}

		Console.ReadLine();
	}
}

`
default

Also color can be set in r,g,b mode but it is replaced to nearest of 256.

WriteLineWithGradient prints vertical only

Hey, I might be doing something wrong but I think when using "WriteLineWithGradient" every char is pushed into a new line. Can you confirm.

Eg:

string myString = "A somewhat irrelevant string";

 List<char> charList = new List<char>();

for (int i = 0; i < myString.Length; i++)
{ 
    charList.Add(Convert.ToChar(myString.Substring(i, 1))); 
}

Console.WriteLineWithGradient(charList, Color.Yellow, Color.Fuchsia, 16);
Console.ReadLine();

feat suggestion: overloads for WriteLineFormatted that just take in Formatter or Formatter[]

I wanted to display a line of text in three different colors. I found it odd I had to define a string and a formatter (which weren't really being used) when calling Console.WriteLineFormatted given that I was passing it an array of formatters which seems to me more than enough information to use. This could be a simplified flow so instead of this:

var progress = new Formatter[]
{
    new Formatter($"{sw.Elapsed:hh\\:mm\\:ss} time elapsed", Color.AliceBlue), 
    new Formatter($"{results.completed} of {results.totalOperations} products processed ({percentDone}% complete)", Color.Aqua),
    new Formatter($"with {results.errors} errors", Color.OrangeRed),
};
Console.WriteLineFormatted("{0} {1} {2}", Color.Gray, progress);

Maybe there could be a couple of overloads for WriteLineFormatted

  • overload that takes in Formatter
  • overload that takes in Formatter[]

An overload for Formatter[] would let you do this:

var progress = new Formatter[]
{
    new Formatter($"{sw.Elapsed:hh\\:mm\\:ss} time elapsed ", Color.AliceBlue), 
    new Formatter($" {results.completed} of {results.totalOperations} products processed ({percentDone}% complete) ", Color.Aqua),
    new Formatter($" with {results.errors} errors ", Color.OrangeRed),
};
Console.WriteLineFormatted(progress);

Default foreground color reverts to default after specific color change

I noticed the default foreground console color reverts to non-name grey after a WriteLine with a specific color.
Setting the foregound color again does not fix the issue.

        static void ColorfulTest()
        {
            Colorful.Console.WriteLine($"Foregound Console Color : \"{Colorful.Console.ForegroundColor.ToString()}\"");
            System.Drawing.Color color = System.Drawing.Color.Cyan;
            Colorful.Console.ForegroundColor = color;
            Colorful.Console.WriteLine($"Foregound Console Color : \"{Colorful.Console.ForegroundColor.ToString()}\"");
            color = System.Drawing.Color.DeepSkyBlue;
            Colorful.Console.WriteLine($"Console Color : \"{color.ToString()}\"", color);
            Colorful.Console.WriteLine($"Foregound Console Color : \"{Colorful.Console.ForegroundColor.ToString()}\"");
            color = System.Drawing.Color.DarkBlue;
            Colorful.Console.WriteLine($"Console Color : \"{color.ToString()}\"", color);
            Colorful.Console.WriteLine($"Foregound Console Color : \"{Colorful.Console.ForegroundColor.ToString()}\"");
            color = System.Drawing.Color.Cyan;
            Colorful.Console.ForegroundColor = color;
            Colorful.Console.WriteLine($"Console Color : \"{color.ToString()}\"", color);
            Colorful.Console.WriteLine($"Foregound Console Color : \"{Colorful.Console.ForegroundColor.ToString()}\"");
            Colorful.Console.ResetColor();
            Colorful.Console.WriteLine($"Foregound Console Color : \"{Colorful.Console.ForegroundColor.ToString()}\"");
        }

2017-05-22 2

Remove System.Drawing dependency

Any chance the bits that depend on system.drawing can be moved into a different package? I'd like to use this to manage basic console functionality, but my console apps cannot run in server core or server nano due to the lack of GDI+

Figlet font width?

Hi, me again :)

I was wondering, is it possible to control the width of the figlet fonts from Colorful.Console?
The default seems to be writing out the fonts at full width, but I'd like to print out smushed. Is it possible currently?

Thanks!
Igal.

Foreground color reverts to default after resume from sleep

Hi, using nuget version 1.0.7.0 on Win 10 x64.
C# .NET console app created with Visual Studio 2017 Enterprise.
Console produces text every few seconds.
Machine went to sleep, when I woke the machine up, the console started painting in the default color.

ANSI Escape Sequences not supported.

using System.Drawing;
using Console = Colorful.Console;

 internal class Program
    {
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        private static void Main(string[] args)
        {
            if (!EnableConsoleColors())
                return;
     
          Console.WriteLine("Test", Color.Red);
          Console.WriteLine("\u001b[31mHello World!\u001b[0m");
        }

        #region "Interoperability"

        [DllImport("kernel32.dll", SetLastError = true)]
        public static extern bool SetConsoleMode(IntPtr hConsoleHandle, int mode);

        [DllImport("kernel32.dll", SetLastError = true)]
        public static extern bool GetConsoleMode(IntPtr handle, out int mode);

        [DllImport("kernel32.dll", SetLastError = true)]
        public static extern IntPtr GetStdHandle(int handle);

        public static bool EnableConsoleColors()
        {
            var handle = GetStdHandle(-11);
            int mode;
            return GetConsoleMode(handle, out mode) &&
                SetConsoleMode(handle, mode | 0x4);
        }

        #endregion "Interoperability"
}

This makes the Color.Red to extend to the entire output.

Any workaround?

WriteLineWithGradient breaks console colours after?

I guess this is something to do with the max 16 colours supported by Windows (although I heard they upped it to 256 in Win10 Anniversary edition), but when I use the example code (or any of my own) that uses Console.WriteLineWithGradient, the console colours don't revert back to default after. I can do Console.ReplaceAllColorsWithDefaults() after but it ruins the gradient effect.
Here is the result from this code

List<int> ints = new List<int>()
{
    7,
    70,
    700,
    7000,
    70000,
    700000,
    7000000,
    -7000000,
    -700000,
    -70000,
    -7000,
    -700,
    -70,
    -7
};
Console.WriteLineWithGradient(ints.OrderBy(x => x).ToList(), Color.MediumSpringGreen, Color.BlueViolet, 14);
//Console.ReplaceAllColorsWithDefaults();
Console.WriteLine("why is this a weird colour?");

image
My "why is this a weird colour?" print should be in the LightGray colour, should it not?
If I uncomment the Console.ReplaceAllColorsWithDefaults(); then run the code again, I get this output
image
which prints the correct colour for "why is this a weird colour?" but it ruins the gradient.

I can fix this by commenting the Console.ReplaceAllColorsWithDefaults(); line and then on all future WriteLines after the gradient I have to add Color.LightGray or else it prints in the wrong colour for the rest of program execution, is there any solution to this? Or is it something I am doing wrong?

Possible mono incompatibility?

Been developing a project using Visual Studio 2015 using Colorful.Console.
Verified that it builds & runs using VS & Windows.
Verified that it builds using Mono 4.6 and runs on Windows.
However, trying to run either (Built on Windows or built on Mono) on Linux using mono results in an undefined entry point exception.

Here is the stack trace: https://puu.sh/wBLPg/e05ad8cf11.png

.net core 3.0 preview 7

Great library,

I seem to be having a problem trying to get this library to work in a .net core 3.0 app

Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Win32.SystemEvents, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)

Missing reference to System.Drawing ?

Version 1.0.7:
image
(works)

Version 1.1.0:
image

HOWEVER, as a caveat, if you downgrade to 1.0.7, compile, then upgrade the library to 1.1.0, it will then resolve and add the missing reference assembly??

not sure why this happens but its quite hilarious IMO

Adding .NET Core Support

Well, not much to add to the title. Started a console project with this new .NET Core approach, added Colorful.Console nuget and got the incompatibility error once added.

I just let you know the incompatibility in case it is trivial to fix, but I don't think this is an urgent issue ๐Ÿ‘

Figlet Write Include Carriage Return

Where in the source code would you suggest I update so the Console.Write method does not emit a carriage return.

FigletFont font = FigletFont.Load(Path.Combine(Environment.CurrentDirectory, @"FigletFonts\big.flf"));
  Figlet big = new Figlet(font);

  font = FigletFont.Load(Path.Combine(Environment.CurrentDirectory, @"FigletFonts\small.flf"));
  Figlet small = new Figlet(font);

  Console.Write(big.ToAscii("T"), ColorTranslator.FromHtml("#8AFFEF"));
  Console.Write(small.ToAscii("imothy"), ColorTranslator.FromHtml("#8AFFEF"));

emits

T
imothy

instead of
Timothy

Ugly Gradient On Mac OS

The gradient is not what's shown in the example and is quite ugly. So far, I've only tested on Mac OS, but this seems wrong.

I get this:
capturfiles-feb-16-2018_06 18 39

Given this:

    private static void WriteLogo() {
      var font = FigletFont.Load("Fonts/slant.flf");
      var figlet = new Figlet(font);

      for (var line = 0; line < figlet.ToAscii("Resourceful").CharacterGeometry.GetLength(0); line++) {
        var lineChars = figlet.ToAscii("Resourceful").CharacterGeometry;
        var rowChars = new List<char>();

        for (var col = 0; col < lineChars.GetLength(1); col++) {;
          rowChars.Add(lineChars[line, col]);
        }

        Console.WriteWithGradient(
          input: rowChars,
          startColor: Color.Yellow,
          endColor: Color.Fuchsia);
        
        Console.Write("\n");
      }
    }

EDIT: The above is in Rider's built in terminal. The gradient looks different yet in iTerm 2:
capturfiles-feb-16-2018_06 27 52

Formatting doesn't work as expected

Given the code:

`string dream = "a dream of {0} and {1} and {2} and {3} and {4} and {5} and {6} and {7} and {8} and {9}...";
Formatter[] fruits = new Formatter[]
{
new Formatter("bananas", Color.LightGoldenrodYellow),
new Formatter("strawberries", Color.Pink),
new Formatter("mangoes", Color.PeachPuff),
new Formatter("pineapples", Color.Yellow),
new Formatter("cherries", Color.Red),
new Formatter("oranges", Color.Orange),
new Formatter("apples", Color.LawnGreen),
new Formatter("peaches", Color.MistyRose),
new Formatter("plums", Color.Indigo),
new Formatter("melons", Color.LightGreen),
};

Console.WriteLineFormatted(dream, Color.Gray, fruits);`

If we modify this line:
string dream = "a dream of {0} and {1} and {2} and {3} and {4} and {5} and {6} and {7} and {8} and {9}...";
into:
string dream = "a dream of {0} and {0} and {0} and {0} and {0} and {0} and {6} and {7} and {8} and {9}...";
the outputs are the same, instead of having the string"bananas" repeated 6 times.

In fact, you can even scramble the indexes around and their order won't be respected.

WriteLineFormatted does not work

private static readonly Formatter[] ResponseFormatter = {
   new Formatter("BBD",  Color.DeepPink)
};

then usage:

Colorful.Console.WriteLineFormatted($"โ–  result BBD", Color.LightGray, ResponseFormatter);

does not color 'BBD' as expected.

powershell console left with incorrect colors in some situations

Having an issue where sometimes the console colors are getting screwed up. Here is a code sample that shows the point:

var styleSheetGlobalStatus = new StyleSheet(Color.White);
			styleSheetGlobalStatus.AddStyle("\\*CG[^*]+\\*", Color.Green, a => a.Substring(3, a.Length - 4));
			styleSheetGlobalStatus.AddStyle("\\*CY[^*]+\\*", Color.Yellow, a => a.Substring(3, a.Length - 4));
			styleSheetGlobalStatus.AddStyle("\\*CR[^*]+\\*", Color.Red, a => a.Substring(3, a.Length - 4));
			styleSheetGlobalStatus.AddStyle("\\*CC[^*]+\\*", Color.Cyan, a => a.Substring(3, a.Length - 4));
			Console.WriteLineStyled("*CC1* *CG2* *CY3* *CR4*", styleSheetGlobalStatus);
			Console.BackgroundColor = Color.Black;

What is interesting is that only when the background color is set to black does it screw up (and that is with the background set to black). In addition if you leave the writelinestyled off it doesn't happen.

Standard command shell is fine. Trying to use the app with a powershell script combo so just not using powershell is not an option.

The behavior I see is that the powershell window starts out with background black, foreground white. After running this the foreground color is set to black.

Is it thread safe?

I create a software, its multi threaded and i want to know if i can use ColorfulConsole.

Not working

##I tried this on my console application and it's not working. The application closes immediately and when i call Console.Readkey() it throws an excepiton.

Work around for 16 colors and cross platform suport.

Sorry i have dyslexsia so spelling and gramer is bad

Hello, i am writing a console based text editor, and was looking for a lib to make colorful text for syntax highlighting, and saw your lib, it does not work on linux, because i use .net core on linux, i ended up writing my own solution to the problem, i solved the cross platform problem and the 16 color limit, here is how i did it if you want to know:

i used ANSI codes, windows does not support this, only in 2016 did that add support for it(ref [1]), linux does support this, and it allows you do all colors as you like, plus exsta tings like bold stylizing etc.

for older windows you can use fall back code that you have at the moment, but for windows 10 and linux and mac(using .net core) all this works no problem.
here is some copy paste code to try it out:

 class Program
    {
        static void Main(string[] args)
        {
            //this makes the codes posible, that dont work unless you do this
            var stdout = Console.OpenStandardOutput();
            var con = new StreamWriter(stdout, Encoding.ASCII);
            con.AutoFlush = true;
            Console.SetOut(con);

            Foreground(255);
            Background(31);

            Console.WriteLine("TEST");

            Reset();
            Console.ReadKey();
        }

        static void Foreground(int c)
        {
            Console.Write($"\x1b[38;5;{c}m ");
        }

        static void Background(int c)
        {
            Console.Write($"\x1b[48;5;{c}m ");
        }

        static void Reset()
        {
            Console.Write($"\x1b[0m ");
        }
    }

[1] https://en.wikipedia.org/wiki/ANSI_escape_code

here is an excelent tutorial on how this all works(just remember that C# uses \x instead of \u
http://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html

Resetting colors to its defaults

There is a hint in documentation to use Colorful.Console.ReplaceAllColorsWithDefaults if we want to set colors back to defaults but this method is marked private and not accessible.

What about simple Reset() method or implementing resetting colors in Clear() method?

Where to get working Figlet fonts from?

Hello, I've tried figlet fonts found here ( https://github.com/xero/figlet-fonts ) but they don;t seem to work at all. Where do we get working figlet fonts from?

In other words, this snippet doesn't output anything, it just generates empty lines:
`FigletFont font = FigletFont.Load("chunky.flf");
Figlet figlet = new Figlet(font);

Console.WriteLine(figlet.ToAscii("Belvedere"), ColorTranslator.FromHtml("#8AFFEF"));
Console.WriteLine(figlet.ToAscii("ice"), ColorTranslator.FromHtml("#FAD6FF"));
Console.WriteLine(figlet.ToAscii("cream."), ColorTranslator.FromHtml("#B8DBFF"));`

Error with new colors as a default arguement

I have a method that draws a single character anywhere on the screen. I want you to be able to specify colors, however, I also want the default color to be white. This is what I have:

public void draw(int x, int y, string text, Color color = Color.White)

It gives me this error:

Default parameter value for 'color' must be a compile-time constant

Any way around this?

breaks if I loop through colors

this seems to break it as it stops changing the text color.

foreach (var color in GetColors())
{
Console.WriteLine($"{color.Name,-20}", color)
}

Colorful not working well on .Net Core Console application

I have the following code in .net core (version 2.2) console application, including examples provided in main page:

using Console = Colorful.Console;

...

static void Main(string[] args)
{
  string[] storyFragments = new[] { "test123", "asdasdasdasdasd" };
  int r = 225;
  int g = 255;
  int b = 250;
  for (int i = 0; i < storyFragments.Length; i++)
  {
	Console.WriteLine(storyFragments[i], Color.FromArgb(r, g, b));

	r -= 18;
	b -= 9;
  } // no colorful here, all are white

  List<char> chars = new List<char>()
  {
	'r', 'e', 'x', 's', 'z', 'q', 'j', 'w', 't', 'a', 'b', 'c', 'l', 'm',
	'r', 'e', 'x', 's', 'z', 'q', 'j', 'w', 't', 'a', 'b', 'c', 'l', 'm',
	'r', 'e', 'x', 's', 'z', 'q', 'j', 'w', 't', 'a', 'b', 'c', 'l', 'm',
	'r', 'e', 'x', 's', 'z', 'q', 'j', 'w', 't', 'a', 'b', 'c', 'l', 'm'
  };

  Console.WriteWithGradient(chars, Color.Yellow, Color.Fuchsia, 14); // latest colors are not supported and they are white
  Console.WriteLine();

  Console.WriteLine("test #0E72CA", FromHex("#0E72CA")); //this must be blue
  Console.Read();

}

static Color FromHex(string color)
{
  int argb = Int32.Parse(color.Replace("#", ""), NumberStyles.HexNumber);
  return Color.FromArgb(argb);
}

How it looks like:

image

Seems that final result is not same with you provided ... What I missed ?

Reset console palette to default

Changes to the console palette made by Colorful.Console remain after application exit.
This messes up colors in other console programs. Like FAR Manager:

  • before running ExampleConsoleApplication:
    farbefore
  • and after running it:
    farafter

Colorful.Console Dictionary Exception

I've been using Colorful.Console for a test application and in a multi-threaded environment the ColorStore causes an exception. The Color is getting added to the dictionary in another thread, making the colorStore.RequiresUpdate check invalid.

Console.WriteLine("Setting initial behavior to stopped", Color.Cyan);
ends up throwing an Exception as it seems to be attempting to add the Color to a dictionary in which it already exists.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Colorful.ColorStore.Update(Color newColor, ConsoleColor oldColor)
   at Colorful.ColorManager.GetConsoleColor(Color color)
   at Colorful.Console.WriteInColor[T](Action`1 action, T target, Color color)
   at Colorful.Console.WriteLine(String value, Color color)

This can be fixed by either switching to ConcurrentDictionary or catching the exception in ColorStore.Update.

Console not colored when using Console.Error

When making Console.Error calls, the console is not colored.

ie Console.Error.WriteLine("An Error Has Occurred", Color.Red) is the default color scheme. but Console.WriteLine("An Error Has Occurred", Color.Red) is red.

WriteWithGradient() causes issues with further calls to WriteLine()

After calling
Console#WriteWithGradient(...)
some strange behaviour can occur when trying to set the colour back to white.

In my particular case, I write with a gradient, write with the colour Gray, then write with the colour White, and the text which should be white is rendered using a colour from the gradient (seems to also be a little inconsistent as to which colour is sampled).

I think the only way to explain this is with a simple screenshot, so:

210c88c05bf6487f312468a3d4793601

OS Information: Windows 10 Pro 64-bit, version 1809, build 17763.437

.NET Core 2.0

Hi there,

Just wondering if this project should be working under .NET Core 2.0?

error CS0433: The type 'Color' exists in both 'CoreCompat.System.Drawing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c0a7ed9c2333b592' and 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

I'm getting the following error:
https://github.com/CoreCompat/System.Drawing/issues/4

Bug in FigletFont

I just wanted to put this on as a potential problem and solution for anyone else interested.

When I modified the example to Show WriteAscii it showed that the FigletFont setup is hit by a bug.

public static FigletFont Parse(string fontContent)
        {
            if (fontContent == null) { throw new ArgumentNullException(nameof(fontContent)); }

            return Parse(fontContent.Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
        }

Is passing a single string not an array to

public static FigletFont Parse(IEnumerable<string> fontLines)

and Font.Lines[] gets only 1 item instead of hundreds. After which it all goes very badly.

When I changed it from;

fontContent.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)

to;

fontContent.Split( new char[] { '\r','\n' }, StringSplitOptions.None)

It worked! I think this may be a bug in the .NET Core framework behind this.

So watch out folks

Write and the like functions in the background thread does not work.

I use Coloful.Console.ReadKey () or Console.ReadKey () in the main thread to block the end of the console and use Colorful.Write ("xxxx", Color.Red) in the background thread to output the data from the background thread. At the beginning, Colorful.Write can work properly, but after it outputs 7 or so data, Colorful.Write is blocked. When I press any key in the console interface, Colorful.Write will output all the previous data. I have tried the traditional Console.Write and everything is OK.

Colorful.Console is overloading Console.Write and printing newlines when it should not.

Code:

static void Main(string[] args)
        {
            Console.Write("{0,-32} ", args[0], Color.LightGray);
            Console.Write("ONLINE", Color.FromArgb(0, 0, 255, 0));

            Console.Write(Environment.NewLine);
            Console.Write(Environment.NewLine);
            Console.Write(Environment.NewLine);

            Console.Write("{0,-32} ", args[0]);
            Console.Write("ONLINE", Color.FromArgb(0, 0, 255, 0));
        }

Resulting output: http://i.imgur.com/s1aoPAd.png

This should NOT be happening. No newline character (\n) was in the string format specifier, and Console.Write does NOT newline by default (thats what we have Console.WriteLine) for.

This only happens when you do not specify a color option as part of the overload.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.