<commit_before>﻿// ***********************************************************************
// Copyright (c) 2014 <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************

using System;

namespace NUnit.ConsoleRunner.Utilities
{
    public enum ColorStyle
    {
        /// <summary>
        /// Color for headers
        /// </summary>
        Header,
        /// <summary>
        /// Color for sub-headers
        /// </summary>
        SubHeader,
        /// <summary>
        /// Color for each of the section headers
        /// </summary>
        SectionHeader,
        /// <summary>
        /// The default color for items that don't fit into the other categories
        /// </summary>
        Default,
        /// <summary>
        /// Test output
        /// </summary>
        Output,
        /// <summary>
        /// Color for labels
        /// </summary>
        Label,
        /// <summary>
        /// Color for values, usually go beside labels
        /// </summary>
        Value,
        /// <summary>
        /// Color for passed tests
        /// </summary>
        Pass,
        /// <summary>
        /// Color for failed tests
        /// </summary>
        Failure,
        /// <summary>
        /// Color for warnings, ignored or skipped tests
        /// </summary>
        Warning,
        /// <summary>
        /// Color for errors and exceptions
        /// </summary>
        Error
    }

    /// <summary>
    /// Sets the console color in the constructor and resets it in the dispose
    /// </summary>
    public class ColorConsole : IDisposable
    {
        /// <summary>
        /// Gets or sets the Enabled flag, indicating whether color is 
        /// being used. This must be set at program startup.
        /// </summary>
        public static bool Enabled { get; set; }

        public ColorConsole(ColorStyle style)
        {
            if (ColorConsole.Enabled)
                Console.ForegroundColor = GetColor(style);
        }

        /// <summary>
        /// Writes the value with the specified style.
        /// </summary>
        /// <param name="style">The style.</param>
        /// <param name="value">The value.</param>
        public static void Write(ColorStyle style, string value)
        {
            using (new ColorConsole(style))
            {
                Console.Write(value);
            }
        }

        /// <summary>
        /// Writes the value with the specified style.
        /// </summary>
        /// <param name="style">The style.</param>
        /// <param name="value">The value.</param>
        public static void WriteLine(ColorStyle style, string value)
        {
            using (new ColorConsole(style))
            {
                Console.WriteLine(value);
            }
        }

        /// <summary>
        /// Writes the label and the option that goes with it and optionally writes a new line.
        /// </summary>
        /// <param name="label">The label.</param>
        /// <param name="option">The option.</param>
        /// <param name="writeLine">if set to <c>true</c> [write line].</param>
        public static void WriteLabel(string label, string option, bool writeLine)
        {
            WriteLabel(label, option, ColorStyle.Value, writeLine);
        }

        /// <summary>
        /// Writes the label and the option that goes with it and optionally writes a new line.
        /// </summary>
        /// <param name="label">The label.</param>
        /// <param name="option">The option.</param>
        /// <param name="valueStyle">The color to display the value with</param>
        /// <param name="writeLine">if set to <c>true</c> [write line].</param>
        public static void WriteLabel(string label, string option, ColorStyle valueStyle, bool writeLine)
        {
            Write(ColorStyle.Label, label);
            Write(valueStyle, option);
            if (writeLine)
                Console.WriteLine();
        }

        /// <summary>
        /// By using styles, we can keep everything consistent
        /// </summary>
        /// <param name="style"></param>
        /// <returns></returns>
        public static ConsoleColor GetColor(ColorStyle style)
        {
            switch (style)
            {
                case ColorStyle.Header:
                    return ConsoleColor.White;
                case ColorStyle.SubHeader:
                    return ConsoleColor.Gray;
                case ColorStyle.SectionHeader:
                    return ConsoleColor.Cyan;
                case ColorStyle.Label:
                    return ConsoleColor.Green;
                case ColorStyle.Value:
                    return ConsoleColor.White;
                case ColorStyle.Pass:
                    return ConsoleColor.Green;
                case ColorStyle.Failure:
                    return ConsoleColor.Red;
                case ColorStyle.Warning:
                    return ConsoleColor.Yellow;
                case ColorStyle.Error:
                    return ConsoleColor.Red;
                case ColorStyle.Output:
                    return ConsoleColor.Gray;
                case ColorStyle.Default:
                default:
                    return ConsoleColor.Green;
            }
        }

        #region Implementation of IDisposable

        /// <summary>
        /// If color is enabled, restores the console colors to their defaults
        /// </summary>
        public void Dispose()
        {
            if (ColorConsole.Enabled)
                Console.ResetColor();
        }

        #endregion
    }
}<commit_msg>Vary color scheme depending on background<commit_after>﻿// ***********************************************************************
// Copyright (c) 2014 <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************

using System;

namespace NUnit.ConsoleRunner.Utilities
{
    public enum ColorStyle
    {
        /// <summary>
        /// Color for headers
        /// </summary>
        Header,
        /// <summary>
        /// Color for sub-headers
        /// </summary>
        SubHeader,
        /// <summary>
        /// Color for each of the section headers
        /// </summary>
        SectionHeader,
        /// <summary>
        /// The default color for items that don't fit into the other categories
        /// </summary>
        Default,
        /// <summary>
        /// Test output
        /// </summary>
        Output,
        /// <summary>
        /// Color for labels
        /// </summary>
        Label,
        /// <summary>
        /// Color for values, usually go beside labels
        /// </summary>
        Value,
        /// <summary>
        /// Color for passed tests
        /// </summary>
        Pass,
        /// <summary>
        /// Color for failed tests
        /// </summary>
        Failure,
        /// <summary>
        /// Color for warnings, ignored or skipped tests
        /// </summary>
        Warning,
        /// <summary>
        /// Color for errors and exceptions
        /// </summary>
        Error
    }

    /// <summary>
    /// Sets the console color in the constructor and resets it in the dispose
    /// </summary>
    public class ColorConsole : IDisposable
    {
        /// <summary>
        /// Gets or sets the Enabled flag, indicating whether color is 
        /// being used. This must be set at program startup.
        /// </summary>
        public static bool Enabled { get; set; }

        public ColorConsole(ColorStyle style)
        {
            if (ColorConsole.Enabled)
                Console.ForegroundColor = GetColor(style);
        }

        /// <summary>
        /// Writes the value with the specified style.
        /// </summary>
        /// <param name="style">The style.</param>
        /// <param name="value">The value.</param>
        public static void Write(ColorStyle style, string value)
        {
            using (new ColorConsole(style))
            {
                Console.Write(value);
            }
        }

        /// <summary>
        /// Writes the value with the specified style.
        /// </summary>
        /// <param name="style">The style.</param>
        /// <param name="value">The value.</param>
        public static void WriteLine(ColorStyle style, string value)
        {
            using (new ColorConsole(style))
            {
                Console.WriteLine(value);
            }
        }

        /// <summary>
        /// Writes the label and the option that goes with it and optionally writes a new line.
        /// </summary>
        /// <param name="label">The label.</param>
        /// <param name="option">The option.</param>
        /// <param name="writeLine">if set to <c>true</c> [write line].</param>
        public static void WriteLabel(string label, string option, bool writeLine)
        {
            WriteLabel(label, option, ColorStyle.Value, writeLine);
        }

        /// <summary>
        /// Writes the label and the option that goes with it and optionally writes a new line.
        /// </summary>
        /// <param name="label">The label.</param>
        /// <param name="option">The option.</param>
        /// <param name="valueStyle">The color to display the value with</param>
        /// <param name="writeLine">if set to <c>true</c> [write line].</param>
        public static void WriteLabel(string label, string option, ColorStyle valueStyle, bool writeLine)
        {
            Write(ColorStyle.Label, label);
            Write(valueStyle, option);
            if (writeLine)
                Console.WriteLine();
        }

        /// <summary>
        /// By using styles, we can keep everything consistent
        /// </summary>
        /// <param name="style"></param>
        /// <returns></returns>
        public static ConsoleColor GetColor(ColorStyle style)
        {
            switch (Console.BackgroundColor)
            {
                case ConsoleColor.White:
                    switch (style)
                    {
                        case ColorStyle.Header:
                            return ConsoleColor.DarkBlue;
                        case ColorStyle.SubHeader:
                            return ConsoleColor.DarkGray;
                        case ColorStyle.SectionHeader:
                            return ConsoleColor.DarkBlue;
                        case ColorStyle.Label:
                            return ConsoleColor.DarkGreen;
                        case ColorStyle.Value:
                            return ConsoleColor.Blue;
                        case ColorStyle.Pass:
                            return ConsoleColor.Green;
                        case ColorStyle.Failure:
                            return ConsoleColor.Red;
                        case ColorStyle.Warning:
                            return ConsoleColor.Yellow;
                        case ColorStyle.Error:
                            return ConsoleColor.Red;
                        case ColorStyle.Output:
                            return ConsoleColor.DarkGray;
                        case ColorStyle.Default:
                        default:
                            return ConsoleColor.Green;
                    }

                case ConsoleColor.Gray:
                    switch (style)
                    {
                        case ColorStyle.Header:
                            return ConsoleColor.White;
                        case ColorStyle.SubHeader:
                            return ConsoleColor.DarkGray;
                        case ColorStyle.SectionHeader:
                            return ConsoleColor.Cyan;
                        case ColorStyle.Label:
                            return ConsoleColor.Green;
                        case ColorStyle.Value:
                            return ConsoleColor.White;
                        case ColorStyle.Pass:
                            return ConsoleColor.Green;
                        case ColorStyle.Failure:
                            return ConsoleColor.Red;
                        case ColorStyle.Warning:
                            return ConsoleColor.Yellow;
                        case ColorStyle.Error:
                            return ConsoleColor.Red;
                        case ColorStyle.Output:
                            return ConsoleColor.DarkGray;
                        case ColorStyle.Default:
                        default:
                            return ConsoleColor.Green;
                    }

                default:
                    switch (style)
                    {
                        case ColorStyle.Header:
                            return ConsoleColor.White;
                        case ColorStyle.SubHeader:
                            return ConsoleColor.Gray;
                        case ColorStyle.SectionHeader:
                            return ConsoleColor.Cyan;
                        case ColorStyle.Label:
                            return ConsoleColor.Green;
                        case ColorStyle.Value:
                            return ConsoleColor.White;
                        case ColorStyle.Pass:
                            return ConsoleColor.Green;
                        case ColorStyle.Failure:
                            return ConsoleColor.Red;
                        case ColorStyle.Warning:
                            return ConsoleColor.Yellow;
                        case ColorStyle.Error:
                            return ConsoleColor.Red;
                        case ColorStyle.Output:
                            return ConsoleColor.Gray;
                        case ColorStyle.Default:
                        default:
                            return ConsoleColor.Green;
                    }
            }
        }

        #region Implementation of IDisposable

        /// <summary>
        /// If color is enabled, restores the console colors to their defaults
        /// </summary>
        public void Dispose()
        {
            if (ColorConsole.Enabled)
                Console.ResetColor();
        }

        #endregion
    }
}
{'fraction_non_alphanumeric': 0.10940463807134553, 'fraction_numerical': 0.0004895062106100471, 'mean_word_length': 1.3638993346832513, 'pattern_counts': {'":': 0, '<': 141, '<?xml version=': 0, '>': 141, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2356742', 'n_tokens_mistral': 3721, 'n_tokens_neox': 3537, 'n_words': 1224}