From 65cb15f6c862aaa6d38490766016180445d5ee41 Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Sat, 18 Feb 2023 23:49:21 +0100 Subject: [PATCH] Add support for underlined text in term --- Capy64/Runtime/Libraries/Term.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Capy64/Runtime/Libraries/Term.cs b/Capy64/Runtime/Libraries/Term.cs index 8e75f5a..cf44fa8 100644 --- a/Capy64/Runtime/Libraries/Term.cs +++ b/Capy64/Runtime/Libraries/Term.cs @@ -30,6 +30,7 @@ internal class Term : IComponent public char Character; public Color Foreground; public Color Background; + public bool Underline; } public const int CharWidth = 6; @@ -190,7 +191,7 @@ internal class Term : IComponent return new(termPos.X * CharWidth, termPos.Y * CharHeight); } - public static void PlotChar(Vector2 pos, char ch, Color? fgc = null, Color? bgc = null, bool save = true) + public static void PlotChar(Vector2 pos, char ch, Color? fgc = null, Color? bgc = null, bool underline = false, bool save = true) { if (pos.X < 0 || pos.Y < 0 || pos.X >= Width || pos.Y >= Height) return; @@ -213,6 +214,11 @@ internal class Term : IComponent _game.Drawing.DrawString(charpos, "\xFFFD", fg); } + if(underline) + { + _game.Drawing.DrawLine(charpos + new Vector2(0, CharHeight), charpos + new Vector2(CharWidth, CharHeight), fg); + } + if (!save) return; @@ -221,6 +227,7 @@ internal class Term : IComponent Character = ch, Foreground = ForegroundColor, Background = BackgroundColor, + Underline = underline, }; } @@ -237,7 +244,7 @@ internal class Term : IComponent Background = BackgroundColor, }; - PlotChar(pos, ch.Character, ch.Foreground, ch.Background, false); + PlotChar(pos, ch.Character, ch.Foreground, ch.Background, ch.Underline, false); } public static void RedrawAll()