From a10440a45c40652b13e883aec832a0c8ded685e8 Mon Sep 17 00:00:00 2001 From: John T Date: Sun, 5 Nov 2017 18:47:46 -0500 Subject: Added a half-complete ShiftFS and did some code cleanup --- ShiftOS.Main/ShiftOS/Apps/Terminal.cs | 143 +++++++++++++++------------------- 1 file changed, 64 insertions(+), 79 deletions(-) (limited to 'ShiftOS.Main/ShiftOS/Apps/Terminal.cs') diff --git a/ShiftOS.Main/ShiftOS/Apps/Terminal.cs b/ShiftOS.Main/ShiftOS/Apps/Terminal.cs index a9bd093..4c11136 100644 --- a/ShiftOS.Main/ShiftOS/Apps/Terminal.cs +++ b/ShiftOS.Main/ShiftOS/Apps/Terminal.cs @@ -1,95 +1,80 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; -using ShiftOS.Engine; using ShiftOS.Engine.Terminal; namespace ShiftOS.Main.ShiftOS.Apps { - public partial class Terminal : UserControl - { - public string defaulttextBefore = "user> "; - public string defaulttextResult = "user@shiftos> "; // NOT YET IMPLEMENTED!!! - public bool doClear = false; + public partial class Terminal : UserControl + { + public string DefaulttextBefore = "user> "; + string DefaulttextResult = "user@shiftos> "; // NOT YET IMPLEMENTED!!! + bool DoClear = false; - // The below variables makes the terminal... a terminal! - public string OldText = ""; - public int TrackingPosition = 0; + // The below variables makes the terminal... a terminal! + string OldText = ""; - public Terminal() - { - InitializeComponent(); + int TrackingPosition; - termmain.ContextMenuStrip = new ContextMenuStrip(); // Disables the right click of a richtextbox! - } + public Terminal() + { + InitializeComponent(); - public void Print(string text) - { - termmain.AppendText($"\n {text} \n {defaulttextResult}"); - TrackingPosition = termmain.Text.Length; - } + termmain.ContextMenuStrip = new ContextMenuStrip(); // Disables the right click of a richtextbox! + } - private void termmain_KeyDown(object sender, KeyEventArgs e) - { - // The below code disables the ability to paste anything other then text... + void Print(string text) + { + termmain.AppendText($"\n {text} \n {DefaulttextResult}"); + TrackingPosition = termmain.Text.Length; + } - if (e.Control && e.KeyCode == Keys.V) - { - //if (Clipboard.ContainsText()) - // termmain.Paste(DataFormats.GetFormat(DataFormats.Text)); - e.Handled = true; - } else if (e.KeyCode == Keys.Enter) { - Print(TerminalBackend.RunCommand(termmain.Text.Substring(TrackingPosition, termmain.Text.Length - TrackingPosition))); // The most horrific line in the entire application! - e.Handled = true; - } - } + void termmain_KeyDown(object sender, KeyEventArgs e) + { + // The below code disables the ability to paste anything other then text... - private void termmain_TextChanged(object sender, EventArgs e) - { - if (termmain.SelectionStart < TrackingPosition) - { - if (doClear == false) // If it's not clearing the terminal - { - termmain.Text = OldText; - termmain.Select(termmain.Text.Length, 0); - } - } - else - { - OldText = termmain.Text; - } - } + if (e.Control && e.KeyCode == Keys.V) + { + //if (Clipboard.ContainsText()) + // termmain.Paste(DataFormats.GetFormat(DataFormats.Text)); + e.Handled = true; + } + else if (e.KeyCode == Keys.Enter) + { + Print( + TerminalBackend.RunCommand( + termmain.Text.Substring( + TrackingPosition, + termmain.Text.Length - TrackingPosition))); // The most horrific line in the entire application! + e.Handled = true; + } + } - private void termmain_SelectionChanged(object sender, EventArgs e) - { - if (termmain.SelectionStart < TrackingPosition) - { - termmain.Text = OldText; - termmain.Select(termmain.Text.Length, 0); - } - } + void termmain_TextChanged(object sender, EventArgs e) + { + if (termmain.SelectionStart < TrackingPosition) + { + if (DoClear) return; + + termmain.Text = OldText; + termmain.Select(termmain.Text.Length, 0); + } + else + { + OldText = termmain.Text; + } + } - private void Terminal_Load(object sender, EventArgs e) - { - Print("\n"); - } + void termmain_SelectionChanged(object sender, EventArgs e) + { + if (termmain.SelectionStart >= TrackingPosition) return; + + termmain.Text = OldText; + termmain.Select(termmain.Text.Length, 0); + } - public string RunCommand(string command) - { - string ToReturn = ""; - - if (command == "hi") - { - ToReturn = $"{ToReturn} \n Hi!"; - MessageBox.Show("HI!"); - } - return ToReturn; - } - } -} + void Terminal_Load(object sender, EventArgs e) + { + Print("\n"); + } + } +} \ No newline at end of file -- cgit v1.2.3