diff options
| author | Alex-TIMEHACK <[email protected]> | 2017-11-18 16:29:54 +0000 |
|---|---|---|
| committer | Alex-TIMEHACK <[email protected]> | 2017-11-18 16:29:54 +0000 |
| commit | 4037be53b29a122732cfc10693e9c0027f606bb0 (patch) | |
| tree | 8533ea9ee0ac8f5f7f696b85cb039f783657ada0 /ShiftOS.Main/ShiftOS/Apps/Terminal.cs | |
| parent | 65b7ac2b8cbc4478f6d31a21f106048aeb075078 (diff) | |
| parent | 97722fbe9d474adffbba0b92e9727c48a8205234 (diff) | |
| download | shiftos-rewind-4037be53b29a122732cfc10693e9c0027f606bb0.tar.gz shiftos-rewind-4037be53b29a122732cfc10693e9c0027f606bb0.tar.bz2 shiftos-rewind-4037be53b29a122732cfc10693e9c0027f606bb0.zip | |
Updated my fork!
Conflicts:
ShiftOS.Engine/ShiftOS.Engine.csproj
ShiftOS.Engine/Terminal/Commands/Hello.cs
ShiftOS.Engine/Terminal/TerminalBackend.cs
ShiftOS.Engine/Terminal/TerminalCommand.cs
ShiftOS.Main/ShiftOS.Main.csproj
ShiftOS.Main/ShiftOS/Apps/Terminal.cs
ShiftOS.Main/ShiftOS/Desktop.cs
Diffstat (limited to 'ShiftOS.Main/ShiftOS/Apps/Terminal.cs')
| -rw-r--r-- | ShiftOS.Main/ShiftOS/Apps/Terminal.cs | 88 |
1 files changed, 72 insertions, 16 deletions
diff --git a/ShiftOS.Main/ShiftOS/Apps/Terminal.cs b/ShiftOS.Main/ShiftOS/Apps/Terminal.cs index 1bd5c03..a5c5a11 100644 --- a/ShiftOS.Main/ShiftOS/Apps/Terminal.cs +++ b/ShiftOS.Main/ShiftOS/Apps/Terminal.cs @@ -1,11 +1,4 @@ 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.Main.Terminal; @@ -21,24 +14,37 @@ namespace ShiftOS.Main.ShiftOS.Apps public bool RunningCommand = false; public bool WaitingResponse = false; public string InputReturnText = ""; +using ShiftOS.Engine.Terminal; - // The below variables makes the terminal... a terminal! - public string OldText = ""; - public int TrackingPosition = 0; +namespace ShiftOS.Main.ShiftOS.Apps +{ + public partial class Terminal : UserControl + { + public string DefaulttextBefore = "user> "; + string DefaulttextResult = "user@shiftos> "; // NOT YET IMPLEMENTED!!! + bool DoClear = false; - public Terminal() - { - InitializeComponent(); + // The below variables makes the terminal... a terminal! + string OldText = ""; + + int TrackingPosition; termmain.ContextMenuStrip = new ContextMenuStrip(); // Disables the right click of a richtextbox! TerminalBackend.trm.Add(this); // Makes the commands run! } + public Terminal() + { + InitializeComponent(); - private void termmain_KeyDown(object sender, KeyEventArgs e) - { - // The below code disables the ability to paste anything other then text... + termmain.ContextMenuStrip = new ContextMenuStrip(); // Disables the right click of a richtextbox! + } + void Print(string text) + { + termmain.AppendText($"\n {text} \n {DefaulttextResult}"); + TrackingPosition = termmain.Text.Length; + } if (e.Control && e.KeyCode == Keys.V) { //if (Clipboard.ContainsText()) @@ -109,3 +115,53 @@ namespace ShiftOS.Main.ShiftOS.Apps } } } + void termmain_KeyDown(object sender, KeyEventArgs e) + { + // The below code disables the ability to paste anything other then 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; + } + } + + 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; + } + } + + void termmain_SelectionChanged(object sender, EventArgs e) + { + if (termmain.SelectionStart >= TrackingPosition) return; + + termmain.Text = OldText; + termmain.Select(termmain.Text.Length, 0); + } + + void Terminal_Load(object sender, EventArgs e) + { + Print("\n"); + } + } +} |
