diff options
| author | Michael <[email protected]> | 2017-05-28 07:21:16 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-05-28 07:21:16 -0400 |
| commit | 8e3bdf71e71096711f11a0d51b2b384e117391ee (patch) | |
| tree | 4df860d8c7f48837a101491ce0d756a66720ff2a /ShiftOS_TheReturn | |
| parent | dc0b8c66885593f7412e24bf7132bc08f6c40a9c (diff) | |
| download | shiftos_thereturn-8e3bdf71e71096711f11a0d51b2b384e117391ee.tar.gz shiftos_thereturn-8e3bdf71e71096711f11a0d51b2b384e117391ee.tar.bz2 shiftos_thereturn-8e3bdf71e71096711f11a0d51b2b384e117391ee.zip | |
strip things down but make things better
Diffstat (limited to 'ShiftOS_TheReturn')
| -rw-r--r-- | ShiftOS_TheReturn/ConsoleEx.cs | 7 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/SaveSystem.cs | 2 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/TerminalBackend.cs | 11 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/TerminalTextWriter.cs | 45 |
4 files changed, 39 insertions, 26 deletions
diff --git a/ShiftOS_TheReturn/ConsoleEx.cs b/ShiftOS_TheReturn/ConsoleEx.cs index 90f9cc0..74483dc 100644 --- a/ShiftOS_TheReturn/ConsoleEx.cs +++ b/ShiftOS_TheReturn/ConsoleEx.cs @@ -48,5 +48,12 @@ namespace ShiftOS.Engine /// Gets or sets whether text in the Terminal is underlined. /// </summary> public static bool Underline { get; set; } + + internal static void Flush() + { + OnFlush?.Invoke(); + } + + public static Action OnFlush; } } diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index f3d95be..24a491d 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -393,6 +393,7 @@ namespace ShiftOS.Engine TerminalBackend.TextSent += ev; Console.WriteLine(); Console.Write(CurrentSave.SystemName + " login: "); + ConsoleEx.Flush(); while (progress == 0) { Thread.Sleep(10); @@ -401,6 +402,7 @@ namespace ShiftOS.Engine goto Login; Console.WriteLine(); Console.Write("password: "); + ConsoleEx.Flush(); while (progress == 1) Thread.Sleep(10); if (goback) diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index b18e27c..1c024eb 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -361,14 +361,12 @@ namespace ShiftOS.Engine /// <param name="isRemote">Whether the command should be sent through Remote Terminal Session (RTS).</param> public static void InvokeCommand(string text, bool isRemote = false) { + if (string.IsNullOrWhiteSpace(text)) + return; var tw = new MemoryTextWriter(); Console.SetOut(tw); try { - - if (string.IsNullOrWhiteSpace(text)) - return; - var args = GetArgs(ref text); Stopwatch debugger = new Stopwatch(); @@ -533,10 +531,9 @@ namespace ShiftOS.Engine /// </summary> public static void PrintPrompt() { + Console.WriteLine(); if (SaveSystem.CurrentSave != null && CurrentUser != null) { - Desktop.InvokeOnWorkerThread(() => - { ConsoleEx.BackgroundColor = SkinEngine.LoadedSkin.TerminalBackColorCC; ConsoleEx.Italic = false; ConsoleEx.Underline = false; @@ -566,7 +563,7 @@ namespace ShiftOS.Engine ConsoleEx.Bold = false; ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; Console.Write(" "); - }); + ConsoleEx.Flush(); } } diff --git a/ShiftOS_TheReturn/TerminalTextWriter.cs b/ShiftOS_TheReturn/TerminalTextWriter.cs index 010e02c..4c0c3a0 100644 --- a/ShiftOS_TheReturn/TerminalTextWriter.cs +++ b/ShiftOS_TheReturn/TerminalTextWriter.cs @@ -37,14 +37,19 @@ namespace ShiftOS.Engine /// </summary> public class TerminalTextWriter : TextWriter { - /// <summary> - /// Win32 API call to lock the window from being updated. - /// </summary> - /// <param name="hWndLock">The Win32 window handle</param> - /// <returns>...I....have no idea.</returns> - [System.Runtime.InteropServices.DllImport("user32.dll")] - public static extern bool LockWindowUpdate(IntPtr hWndLock); + public TerminalTextWriter() + { + ConsoleEx.OnFlush = () => + { + Desktop.InvokeOnWorkerThread(() => + { + UnderlyingControl?.Write(buffer); + buffer = ""; + }); + }; + } + /// <summary> /// Gets the encoding format for this <see cref="TextWriter"/>. God bless the Unicode Consortiem. /// </summary> @@ -94,11 +99,17 @@ namespace ShiftOS.Engine } else { - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl?.Write(value.ToString()); - select(); - })); + buffer += value; + } + } + + private string buffer = ""; + + public string Buffer + { + get + { + return buffer; } } @@ -118,11 +129,8 @@ namespace ShiftOS.Engine else { - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl?.WriteLine(value); - select(); - })); + buffer += value + Environment.NewLine; + ConsoleEx.Flush(); } } @@ -149,8 +157,7 @@ namespace ShiftOS.Engine Desktop.InvokeOnWorkerThread(new Action(() => { - UnderlyingControl?.Write(value.ToString()); - select(); + buffer += value; })); } } |
