strip things down but make things better
This commit is contained in:
parent
dc0b8c6688
commit
8e3bdf71e7
6 changed files with 42 additions and 35 deletions
|
@ -268,7 +268,8 @@ namespace ShiftOS.WinForms.Applications
|
|||
{
|
||||
try
|
||||
{
|
||||
a.SuppressKeyPress = true;
|
||||
if (!TerminalBackend.InStory)
|
||||
a.SuppressKeyPress = false;
|
||||
if (!TerminalBackend.PrefixEnabled)
|
||||
{
|
||||
string textraw = txt.Lines[txt.Lines.Length - 1];
|
||||
|
@ -276,9 +277,8 @@ namespace ShiftOS.WinForms.Applications
|
|||
TerminalBackend.SendText(textraw);
|
||||
return;
|
||||
}
|
||||
Console.WriteLine("");
|
||||
var text = txt.Lines.ToArray();
|
||||
var text2 = text[text.Length - 2];
|
||||
var text2 = text[text.Length - 1];
|
||||
var text3 = "";
|
||||
var text4 = Regex.Replace(text2, @"\t|\n|\r", "");
|
||||
|
||||
|
|
|
@ -64,9 +64,6 @@ namespace ShiftOS.WinForms.Controls
|
|||
public void Write(string text)
|
||||
{
|
||||
this.HideSelection = true;
|
||||
this.SelectionFont = ConstructFont();
|
||||
this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor);
|
||||
this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor);
|
||||
this.AppendText(Localization.Parse(text));
|
||||
this.HideSelection = false;
|
||||
}
|
||||
|
@ -89,9 +86,6 @@ namespace ShiftOS.WinForms.Controls
|
|||
Engine.AudioManager.PlayStream(Properties.Resources.writesound);
|
||||
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);
|
||||
this.HideSelection = false;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue