From 251521835b60024dec292a759d738e2b81bf1417 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Mar 2017 16:46:34 -0500 Subject: Console colors! --- ShiftOS.WinForms/Applications/Terminal.cs | 4 ++-- ShiftOS.WinForms/Controls/TerminalBox.cs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 7bab213..65a8f0f 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -134,7 +134,7 @@ namespace ShiftOS.WinForms.Applications rtbterm.Text = ""; TerminalBackend.PrefixEnabled = true; TerminalBackend.InStory = false; - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + TerminalBackend.PrintPrompt(); if (Shiftorium.UpgradeInstalled("wm_free_placement")) { this.ParentForm.Width = 640; @@ -276,7 +276,7 @@ namespace ShiftOS.WinForms.Applications } if (TerminalBackend.PrefixEnabled) { - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + TerminalBackend.PrintPrompt(); } } } diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index 7c0da57..9e4c61c 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading; @@ -56,16 +57,31 @@ namespace ShiftOS.WinForms.Controls { this.HideSelection = true; this.Select(this.TextLength, 0); + this.SelectionFont = ConstructFont(); this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text)); this.HideSelection = false; } + private Font ConstructFont() + { + FontStyle fs = FontStyle.Regular; + if (ConsoleEx.Bold) + fs = fs | FontStyle.Bold; + if (ConsoleEx.Italic) + fs = fs | FontStyle.Italic; + if (ConsoleEx.Underline) + fs = fs | FontStyle.Underline; + + return new Font(this.Font, fs); + } + public void WriteLine(string text) { this.HideSelection = true; this.Select(this.TextLength, 0); + this.SelectionFont = ConstructFont(); this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text) + Environment.NewLine); -- cgit v1.2.3