Пример #1
0
        /// <summary>
        /// Converts mud color codes into ANSI color codes.  Note: This updates the StringBuilder directly.
        /// </summary>
        /// <param name="sb"></param>
        public static void MudToAnsiColorCodes(ref Utf16ValueStringBuilder sb)
        {
            var span = sb.AsSpan();

            // If there are no color codes don't bother loop through the replacements.
            if (!span.Contains('{'))
            {
                return;
            }

            // First the colors
            foreach (var item in ColorMap)
            {
                sb.Replace(item.AnsiColor.MudColorCode, item.AnsiColor.ToString());
            }

            // Next the styles
            foreach (var item in StyleMap)
            {
                sb.Replace(item.AnsiColor.MudColorCode, item.AnsiColor.ToString());
            }
        }
Пример #2
0
        /// <summary>
        /// Converts ANSI color codes into mud color codes.  Note: This updates the StringBuilder directly.
        /// </summary>
        /// <param name="sb"></param>
        public static void AnsiToMudColorCodes(ref Utf16ValueStringBuilder sb)
        {
            var span = sb.AsSpan();

            // If there are no color codes don't bother loop through the replacements.
            if (!span.Contains('\x1B'))
            {
                return;
            }

            foreach (var item in ColorMap)
            {
                sb.Replace(item.AnsiColor.ToString(), item.AnsiColor.MudColorCode);
            }
        }
Пример #3
0
 /// <summary>
 /// Replaces all instances of one character with another in this builder.
 /// </summary>
 /// <param name="oldChar">The character to replace.</param>
 /// <param name="newChar">The character to replace <paramref name="oldChar"/> with.</param>
 public void Replace(char oldChar, char newChar) => _vsb.Replace(oldChar, newChar);