microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Common/Text/StringBuilder.cs
134lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using System.Text; |
| 5 | |
| 6 | namespace Microsoft.Teams.Common.Text; |
| 7 | |
| 8 | public static class StringBuilderExtensions |
| 9 | { |
| 10 | public static StringBuilder Reset(this StringBuilder builder) |
| 11 | { |
| 12 | return builder.Append(ANSI.Reset); |
| 13 | } |
| 14 | |
| 15 | public static StringBuilder Append(this StringBuilder builder, ANSI code, string text) |
| 16 | { |
| 17 | return builder.Append(code).Append(text).Append(ANSI.Reset); |
| 18 | } |
| 19 | |
| 20 | public static StringBuilder Bold(this StringBuilder builder, string text) |
| 21 | { |
| 22 | return builder.Append(ANSI.Bold).Append(text).Append(ANSI.BoldReset); |
| 23 | } |
| 24 | |
| 25 | public static StringBuilder Italic(this StringBuilder builder, string text) |
| 26 | { |
| 27 | return builder.Append(ANSI.Italic).Append(text).Append(ANSI.ItalicReset); |
| 28 | } |
| 29 | |
| 30 | public static StringBuilder Underline(this StringBuilder builder, string text) |
| 31 | { |
| 32 | return builder.Append(ANSI.Underline).Append(text).Append(ANSI.UnderlineReset); |
| 33 | } |
| 34 | |
| 35 | public static StringBuilder Strike(this StringBuilder builder, string text) |
| 36 | { |
| 37 | return builder.Append(ANSI.Strike).Append(text).Append(ANSI.StrikeReset); |
| 38 | } |
| 39 | |
| 40 | public static StringBuilder Black(this StringBuilder builder, string text) |
| 41 | { |
| 42 | return builder.Append(ANSI.ForegroundBlack).Append(text).Append(ANSI.ForegroundReset); |
| 43 | } |
| 44 | |
| 45 | public static StringBuilder BgBlack(this StringBuilder builder, string text) |
| 46 | { |
| 47 | return builder.Append(ANSI.BackgroundBlack).Append(text).Append(ANSI.BackgroundReset); |
| 48 | } |
| 49 | |
| 50 | public static StringBuilder Red(this StringBuilder builder, string text) |
| 51 | { |
| 52 | return builder.Append(ANSI.ForegroundRed).Append(text).Append(ANSI.ForegroundReset); |
| 53 | } |
| 54 | |
| 55 | public static StringBuilder BgRed(this StringBuilder builder, string text) |
| 56 | { |
| 57 | return builder.Append(ANSI.BackgroundRed).Append(text).Append(ANSI.BackgroundReset); |
| 58 | } |
| 59 | |
| 60 | public static StringBuilder Green(this StringBuilder builder, string text) |
| 61 | { |
| 62 | return builder.Append(ANSI.ForegroundGreen).Append(text).Append(ANSI.ForegroundReset); |
| 63 | } |
| 64 | |
| 65 | public static StringBuilder BgGreen(this StringBuilder builder, string text) |
| 66 | { |
| 67 | return builder.Append(ANSI.BackgroundGreen).Append(text).Append(ANSI.BackgroundReset); |
| 68 | } |
| 69 | |
| 70 | public static StringBuilder Yellow(this StringBuilder builder, string text) |
| 71 | { |
| 72 | return builder.Append(ANSI.ForegroundYellow).Append(text).Append(ANSI.ForegroundReset); |
| 73 | } |
| 74 | |
| 75 | public static StringBuilder BgYellow(this StringBuilder builder, string text) |
| 76 | { |
| 77 | return builder.Append(ANSI.BackgroundYellow).Append(text).Append(ANSI.BackgroundReset); |
| 78 | } |
| 79 | |
| 80 | public static StringBuilder Blue(this StringBuilder builder, string text) |
| 81 | { |
| 82 | return builder.Append(ANSI.ForegroundBlue).Append(text).Append(ANSI.ForegroundReset); |
| 83 | } |
| 84 | |
| 85 | public static StringBuilder BgBlue(this StringBuilder builder, string text) |
| 86 | { |
| 87 | return builder.Append(ANSI.BackgroundBlue).Append(text).Append(ANSI.BackgroundReset); |
| 88 | } |
| 89 | |
| 90 | public static StringBuilder Magenta(this StringBuilder builder, string text) |
| 91 | { |
| 92 | return builder.Append(ANSI.ForegroundMagenta).Append(text).Append(ANSI.ForegroundReset); |
| 93 | } |
| 94 | |
| 95 | public static StringBuilder BgMagenta(this StringBuilder builder, string text) |
| 96 | { |
| 97 | return builder.Append(ANSI.BackgroundMagenta).Append(text).Append(ANSI.BackgroundReset); |
| 98 | } |
| 99 | |
| 100 | public static StringBuilder Cyan(this StringBuilder builder, string text) |
| 101 | { |
| 102 | return builder.Append(ANSI.ForegroundCyan).Append(text).Append(ANSI.ForegroundReset); |
| 103 | } |
| 104 | |
| 105 | public static StringBuilder BgCyan(this StringBuilder builder, string text) |
| 106 | { |
| 107 | return builder.Append(ANSI.BackgroundCyan).Append(text).Append(ANSI.BackgroundReset); |
| 108 | } |
| 109 | |
| 110 | public static StringBuilder White(this StringBuilder builder, string text) |
| 111 | { |
| 112 | return builder.Append(ANSI.ForegroundWhite).Append(text).Append(ANSI.ForegroundReset); |
| 113 | } |
| 114 | |
| 115 | public static StringBuilder BgWhite(this StringBuilder builder, string text) |
| 116 | { |
| 117 | return builder.Append(ANSI.BackgroundWhite).Append(text).Append(ANSI.BackgroundReset); |
| 118 | } |
| 119 | |
| 120 | public static StringBuilder Gray(this StringBuilder builder, string text) |
| 121 | { |
| 122 | return builder.Append(ANSI.ForegroundGray).Append(text).Append(ANSI.ForegroundReset); |
| 123 | } |
| 124 | |
| 125 | public static StringBuilder Default(this StringBuilder builder, string text) |
| 126 | { |
| 127 | return builder.Append(ANSI.ForegroundDefault).Append(text).Append(ANSI.ForegroundReset); |
| 128 | } |
| 129 | |
| 130 | public static StringBuilder BgDefault(this StringBuilder builder, string text) |
| 131 | { |
| 132 | return builder.Append(ANSI.BackgroundDefault).Append(text).Append(ANSI.BackgroundReset); |
| 133 | } |
| 134 | } |