private void Write(
            ITextAttributes currentAttributes,
            TextAttribute key,
            string defaultValue,
            TextWriter writer)
        {
            currentAttributes.TryGetValue(key, out var value);

            if (!string.Equals(value, defaultValue))
            {
                WriteAttribute(writer, key.ToString(), value);
            }
        }
        public static string GetAttribute(
            this ITextAttributes attributes,
            TextAttribute type,
            string defaultValue = null)
        {
            if (attributes != null)
            {
                if (attributes.TryGetValue(type, out var value))
                {
                    return(value);
                }
            }

            return(defaultValue);
        }