From e0254a72c2b31bf6aa274389eeb93879a240b9b5 Mon Sep 17 00:00:00 2001 From: jtsshieh Date: Sat, 23 Sep 2017 23:04:51 -0400 Subject: [PATCH 1/2] Fix the terminal indexing bug --- Histacom2/OS/Win95/Win95Apps/WinClassicTerminal.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Histacom2/OS/Win95/Win95Apps/WinClassicTerminal.cs b/Histacom2/OS/Win95/Win95Apps/WinClassicTerminal.cs index 668078e..ab736cb 100644 --- a/Histacom2/OS/Win95/Win95Apps/WinClassicTerminal.cs +++ b/Histacom2/OS/Win95/Win95Apps/WinClassicTerminal.cs @@ -174,11 +174,14 @@ private void richTextBox1_KeyUp(object sender, KeyEventArgs e) cmdPrompt.Focus(); cmdPrompt.AppendText($"\n{output}"); // Append the command output - - int numLines = output.Split('\n').Length; // Get the number of lines from the command output - currentLine = currentLine + 2 + numLines; // Set the current line to equals the previous line plus 2 plus the number of lines from the command - + string[] stringSeparators = new string[] { "\n" }; + string[] lines = output.Split(stringSeparators, StringSplitOptions.None); + foreach (string s in lines) + { + currentLine++; + } cmdPrompt.AppendText($"\n\n{prefix}"); // Append the text to the RichTextBox + currentLine = currentLine + 3; } } } From c9785e86e80413f325076d7b5fc0f4651867c5d2 Mon Sep 17 00:00:00 2001 From: jtsshieh Date: Sun, 24 Sep 2017 13:56:26 -0400 Subject: [PATCH 2/2] added in clear command --- .../OS/Win95/Win95Apps/WinClassicTerminal.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Histacom2/OS/Win95/Win95Apps/WinClassicTerminal.cs b/Histacom2/OS/Win95/Win95Apps/WinClassicTerminal.cs index ab736cb..d87dc4e 100644 --- a/Histacom2/OS/Win95/Win95Apps/WinClassicTerminal.cs +++ b/Histacom2/OS/Win95/Win95Apps/WinClassicTerminal.cs @@ -28,7 +28,7 @@ public partial class WinClassicTerminal : UserControl public static string prefix = @"C:\WINDOWS>"; public static string workingDir = $"{SaveSystem.ProfileWindowsDirectory}"; public string output = ""; - + public bool cls = false; public WinClassicTerminal(bool readOnly) { InitializeComponent(); @@ -107,9 +107,10 @@ private void btnFont_Click(object sender, EventArgs e) { //TODO: Add font UC(?) } - + private void richTextBox1_KeyUp(object sender, KeyEventArgs e) { + if (e.KeyData == Keys.Return) { string[] cmd = cmdPrompt.Lines[currentLine].Substring(prefix.Length).Split(' '); @@ -151,6 +152,12 @@ private void richTextBox1_KeyUp(object sender, KeyEventArgs e) dline = dline.Insert(34, "bytes free"); output += dline; + break; + case "cls": + currentLine = 0; + cmdPrompt.Clear(); + cls = true; + output = prefix; break; default: // Temporary CMD redirect @@ -180,8 +187,12 @@ private void richTextBox1_KeyUp(object sender, KeyEventArgs e) { currentLine++; } - cmdPrompt.AppendText($"\n\n{prefix}"); // Append the text to the RichTextBox - currentLine = currentLine + 3; + if (!cls) + { + cmdPrompt.AppendText($"\n\n{prefix}"); // Append the text to the RichTextBox + currentLine = currentLine + 3; + } + cls = false; } } }