diff options
| author | Michael <[email protected]> | 2017-03-09 16:14:35 -0500 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-03-09 16:14:35 -0500 |
| commit | 3f08cb807c1490af423450e3eb03a46aa11caf2f (patch) | |
| tree | 38ec804cae9d1106f78074eea4b926f3204fd8f9 /ShiftOS.WinForms | |
| parent | d9b4e79bcffea6139fadefcd95a020029941eda7 (diff) | |
| download | shiftos_thereturn-3f08cb807c1490af423450e3eb03a46aa11caf2f.tar.gz shiftos_thereturn-3f08cb807c1490af423450e3eb03a46aa11caf2f.tar.bz2 shiftos_thereturn-3f08cb807c1490af423450e3eb03a46aa11caf2f.zip | |
Colored terminal text
Diffstat (limited to 'ShiftOS.WinForms')
| -rw-r--r-- | ShiftOS.WinForms/Controls/TerminalBox.cs | 10 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Tools/ControlManager.cs | 42 |
2 files changed, 52 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index b75d077..7c0da57 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -26,9 +26,11 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; +using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Controls { @@ -53,13 +55,21 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { this.HideSelection = true; + this.Select(this.TextLength, 0); + this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); + this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text)); this.HideSelection = false; } public void WriteLine(string text) { + this.HideSelection = true; + this.Select(this.TextLength, 0); + this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); + this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text) + Environment.NewLine); + this.HideSelection = false; } bool quickCopying = false; diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 5cc4813..52663d7 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -152,6 +152,48 @@ namespace ShiftOS.WinForms.Tools } } + internal static Color ConvertColor(ConsoleColor cCol) + { + switch (cCol) + { + case ConsoleColor.Black: + return Color.Black; + case ConsoleColor.Gray: + return Color.Gray; + case ConsoleColor.DarkGray: + return Color.DarkGray; + case ConsoleColor.Blue: + return Color.Blue; + case ConsoleColor.Cyan: + return Color.Cyan; + case ConsoleColor.DarkBlue: + return Color.DarkBlue; + case ConsoleColor.DarkCyan: + return Color.DarkCyan; + case ConsoleColor.DarkGreen: + return Color.DarkGreen; + case ConsoleColor.DarkMagenta: + return Color.DarkMagenta; + case ConsoleColor.DarkRed: + return Color.DarkRed; + case ConsoleColor.DarkYellow: + return Color.YellowGreen; + case ConsoleColor.Yellow: + return Color.Yellow; + case ConsoleColor.Green: + return Color.Green; + case ConsoleColor.Magenta: + return Color.Magenta; + case ConsoleColor.Red: + return Color.Red; + case ConsoleColor.White: + return Color.White; + default: + return Color.Black; + } + + } + public static void SetCursor(Control ctrl) { #if STUPID |
