aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Main/ShiftOS/Apps/Terminal.cs
diff options
context:
space:
mode:
authorAlex-TIMEHACK <[email protected]>2017-10-14 16:23:41 +0100
committerAlex-TIMEHACK <[email protected]>2017-10-14 16:23:41 +0100
commit59a7eabcbe37d44a1cd4a9b742ce99f423a42ff7 (patch)
tree1c5b03e138a79947ad4c2935c7d8ffd73eb8a420 /ShiftOS.Main/ShiftOS/Apps/Terminal.cs
parentf2ed0c673c2d3f0e021b0307a22792af66fd217d (diff)
downloadshiftos-rewind-59a7eabcbe37d44a1cd4a9b742ce99f423a42ff7.tar.gz
shiftos-rewind-59a7eabcbe37d44a1cd4a9b742ce99f423a42ff7.tar.bz2
shiftos-rewind-59a7eabcbe37d44a1cd4a9b742ce99f423a42ff7.zip
Done like a few things but I need to update so....
Diffstat (limited to 'ShiftOS.Main/ShiftOS/Apps/Terminal.cs')
-rw-r--r--ShiftOS.Main/ShiftOS/Apps/Terminal.cs92
1 files changed, 92 insertions, 0 deletions
diff --git a/ShiftOS.Main/ShiftOS/Apps/Terminal.cs b/ShiftOS.Main/ShiftOS/Apps/Terminal.cs
new file mode 100644
index 0000000..cb5bed3
--- /dev/null
+++ b/ShiftOS.Main/ShiftOS/Apps/Terminal.cs
@@ -0,0 +1,92 @@
+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;
+
+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;
+
+ // The below variables makes the terminal... a terminal!
+ public string OldText = "";
+ public int TrackingPosition = 0;
+
+ public Terminal()
+ {
+ InitializeComponent();
+
+ termmain.ContextMenuStrip = new ContextMenuStrip(); // Disables the right click of a richtextbox!
+ }
+
+ public void Print(string text)
+ {
+ termmain.AppendText($"\n {text} \n {defaulttextResult}");
+ TrackingPosition = termmain.Text.Length;
+ }
+
+ private 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(RunCommand(termmain.Text.Substring(TrackingPosition, termmain.Text.Length - TrackingPosition))); // The most horrific line in the entire application!
+ }
+ }
+
+ 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;
+ }
+ }
+
+ private void termmain_SelectionChanged(object sender, EventArgs e)
+ {
+ if (termmain.SelectionStart < TrackingPosition)
+ {
+ termmain.Text = OldText;
+ termmain.Select(termmain.Text.Length, 0);
+ }
+ }
+
+ private void Terminal_Load(object sender, EventArgs e)
+ {
+ Print("\n");
+ }
+
+ public string RunCommand(string command)
+ {
+ string ToReturn = "";
+
+ if (command == "hi")
+ {
+ ToReturn = $"{ToReturn} \n Hi!";
+ MessageBox.Show("HI!");
+ }
+ return ToReturn;
+ }
+ }
+}