@@ -36,21 +36,21 @@ public void Initialize(IncrementalGeneratorInitializationContext context) {
3636 private static void GenerateCode ( SourceProductionContext context , ImmutableArray < AdditionalText > files ) {
3737 IEnumerable < ColorEntry > colors = files . SelectMany ( file => ParseColorFile ( context , file ) ) . ToArray ( ) ;
3838 var builder = new GeneratorStringBuilder ( ) ;
39-
39+
4040 #region Fore & Background
41- foreach ( string section in new [ ] { "Foreground" , "Background" } ) {
41+ foreach ( string section in new [ ] { "Foreground" , "Background" , "Underline" } ) {
4242 context . AddSource ( $ "Ansi{ section } Builder.g.cs", builder
4343 . AppendUsings ( "System" )
4444 . AppendAutoGenerated ( )
4545 . AppendNamespace ( "CodeOfChaos.Ansi" )
4646 . AppendLine ( $ "public partial class Ansi{ section } Builder {{")
47- . ForEach ( colors , ( stringBuilder , entry ) => stringBuilder
47+ . ForEach ( colors , itemFormatter : ( stringBuilder , entry ) => stringBuilder
4848 . AppendBodyIndented ( $$ """
4949 #region {{ entry . Name }}
5050 private static CodeOfChaos.Ansi.ByteVector3 _{{ entry . Name }} = new({{ entry . Colors }} );
51-
51+
5252 public string {{ entry . Name }} (string text) => $"{CodeOfChaos.Ansi.AnsiCodes.Rgb{{ section }} Color(_{{ entry . Name }} )}{text}{CodeOfChaos.Ansi.AnsiCodes.ResetGraphicsModes}";
53-
53+
5454 public Ansi{{ section }} Builder Append{{ entry . Name }} (string text) => BuilderAction(() => {
5555 Builder
5656 .Append(CodeOfChaos.Ansi.AnsiCodes.Rgb{{ section }} Color(_{{ entry . Name }} ))
@@ -70,21 +70,21 @@ private static void GenerateCode(SourceProductionContext context, ImmutableArray
7070 action(this);
7171 Builder.Append(CodeOfChaos.Ansi.AnsiCodes.ResetGraphicsModes);
7272 });
73-
73+
7474 public Ansi{{ section }} Builder Append{{ entry . Name }} Line(string text) => BuilderAction(() => {
7575 Builder
7676 .Append(CodeOfChaos.Ansi.AnsiCodes.Rgb{{ section }} Color(_{{ entry . Name }} ))
7777 .Append(text)
7878 .AppendLine(CodeOfChaos.Ansi.AnsiCodes.ResetGraphicsModes);
7979 });
80-
80+
8181 public Ansi{{ section }} Builder Append{{ entry . Name }} Line(Func<string> action) => BuilderAction(() => {
8282 Builder
8383 .Append(CodeOfChaos.Ansi.AnsiCodes.Rgb{{ section }} Color(_{{ entry . Name }} ))
8484 .Append(action())
8585 .AppendLine(CodeOfChaos.Ansi.AnsiCodes.ResetGraphicsModes);
8686 });
87-
87+
8888 public Ansi{{ section }} Builder Append{{ entry . Name }} Line(Action<Ansi{{ section }} Builder> action) => BuilderAction(() => {
8989 Builder.Append(CodeOfChaos.Ansi.AnsiCodes.Rgb{{ section }} Color(_{{ entry . Name }} ));
9090 action(this);
@@ -97,7 +97,7 @@ private static void GenerateCode(SourceProductionContext context, ImmutableArray
9797 )
9898 . AppendLine ( "}" )
9999 . ToStringAndClear ( )
100- ) ;
100+ ) ;
101101 }
102102 #endregion
103103 }
0 commit comments