aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Main/ShiftOS
diff options
context:
space:
mode:
authorAShifter <[email protected]>2017-11-18 10:04:42 -0700
committerAShifter <[email protected]>2017-11-18 10:04:42 -0700
commitb4a8a646b1d0c67414a0e1eeedcf9442739fd990 (patch)
tree92c92907a420f2bb97719f4fd6c19ac72e283b8d /ShiftOS.Main/ShiftOS
parentebdc09fe679b4b06fd149c8fc6539244100ce896 (diff)
parentcc734557de877186c5f5eb1e59efdcb785ac37a8 (diff)
downloadshiftos-rewind-b4a8a646b1d0c67414a0e1eeedcf9442739fd990.tar.gz
shiftos-rewind-b4a8a646b1d0c67414a0e1eeedcf9442739fd990.tar.bz2
shiftos-rewind-b4a8a646b1d0c67414a0e1eeedcf9442739fd990.zip
Merge remote-tracking branch 'refs/remotes/ShiftOS-Rewind/master'
Diffstat (limited to 'ShiftOS.Main/ShiftOS')
-rw-r--r--ShiftOS.Main/ShiftOS/Apps/Terminal.Designer.cs2
-rw-r--r--ShiftOS.Main/ShiftOS/Apps/Terminal.cs140
-rw-r--r--ShiftOS.Main/ShiftOS/Desktop.cs13
3 files changed, 104 insertions, 51 deletions
diff --git a/ShiftOS.Main/ShiftOS/Apps/Terminal.Designer.cs b/ShiftOS.Main/ShiftOS/Apps/Terminal.Designer.cs
index e92cdb4..b514bbf 100644
--- a/ShiftOS.Main/ShiftOS/Apps/Terminal.Designer.cs
+++ b/ShiftOS.Main/ShiftOS/Apps/Terminal.Designer.cs
@@ -60,6 +60,6 @@
#endregion
- private System.Windows.Forms.RichTextBox termmain;
+ public System.Windows.Forms.RichTextBox termmain;
}
}
diff --git a/ShiftOS.Main/ShiftOS/Apps/Terminal.cs b/ShiftOS.Main/ShiftOS/Apps/Terminal.cs
index 4c11136..c65f705 100644
--- a/ShiftOS.Main/ShiftOS/Apps/Terminal.cs
+++ b/ShiftOS.Main/ShiftOS/Apps/Terminal.cs
@@ -1,14 +1,19 @@
using System;
using System.Windows.Forms;
-using ShiftOS.Engine.Terminal;
+using ShiftOS.Engine;
+using ShiftOS.Main.Terminal;
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 partial class Terminal : UserControl
+ {
+ public int TerminalID = TerminalBackend.trmTopID++; // Used so that we can have multiple instances of the terminal whilst the command begin run knowing what terminal to send the text to - very complicated ;)
+ public string defaulttextBefore = "user> ";
+ public string defaulttextResult = "user@shiftos> "; // NOT YET IMPLEMENTED!!!
+ public bool DoClear = false;
+ public bool RunningCommand = false;
+ public bool WaitingResponse = false;
+ public string InputReturnText = "";
// The below variables makes the terminal... a terminal!
string OldText = "";
@@ -20,13 +25,91 @@ namespace ShiftOS.Main.ShiftOS.Apps
InitializeComponent();
termmain.ContextMenuStrip = new ContextMenuStrip(); // Disables the right click of a richtextbox!
- }
- void Print(string text)
+ TerminalBackend.trm.Add(this);
+ }
+
+ void Print()
+ {
+ termmain.AppendText($"\n {defaulttextResult}");
+ TrackingPosition = termmain.Text.Length;
+ }
+
+ void Print(string text)
{
- termmain.AppendText($"\n {text} \n {DefaulttextResult}");
+ 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) {
+ // RunningCommand = true;
+ // TerminalBackend.RunCommand(termmain.Text.Substring(TrackingPosition, termmain.Text.Length - TrackingPosition), TerminalID); // The most horrific line in the entire application!
+ // RunningCommand = false;
+ // termmain.AppendText($"\n {defaulttextResult}");
+ // TrackingPosition = termmain.Text.Length;
+ // e.Handled = true;
+ // }
+ //}
+
+ private void termmain_TextChanged(object sender, EventArgs e)
+ {
+ if (!RunningCommand)
+ {
+ if (termmain.SelectionStart < TrackingPosition)
+ {
+ if (!DoClear) // 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 (!RunningCommand)
+ {
+ if (termmain.SelectionStart < TrackingPosition)
+ {
+ termmain.Text = OldText;
+ termmain.Select(termmain.Text.Length, 0);
+ }
+ }
+ }
+
+ private void Terminal_Load(object sender, EventArgs e)
+ {
+ termmain.Text = $"\n {defaulttextResult}";
+ TrackingPosition = termmain.Text.Length;
+ termmain.Select(termmain.TextLength, 1);
+ }
+
+ public void Input(string request)
+ {
+ InputReturnText = "";
+ RunningCommand = false;
+
+ termmain.AppendText($"\n {request} ");
+ TrackingPosition = termmain.Text.Length;
+ }
+
+ public void Clear()
+ {
+ DoClear = true;
+ termmain.Text = $"\n {defaulttextResult}";
+ TrackingPosition = termmain.Text.Length;
+ DoClear = false;
+ }
void termmain_KeyDown(object sender, KeyEventArgs e)
{
@@ -40,41 +123,10 @@ namespace ShiftOS.Main.ShiftOS.Apps
}
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!
+ TerminalBackend.RunCommand(termmain.Text.Substring(TrackingPosition, termmain.Text.Length - TrackingPosition), TerminalID); // The most horrific line in the entire application!
+ Print();
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");
- }
}
-} \ No newline at end of file
+}
diff --git a/ShiftOS.Main/ShiftOS/Desktop.cs b/ShiftOS.Main/ShiftOS/Desktop.cs
index 95e4d26..4bf4805 100644
--- a/ShiftOS.Main/ShiftOS/Desktop.cs
+++ b/ShiftOS.Main/ShiftOS/Desktop.cs
@@ -54,11 +54,12 @@ namespace ShiftOS.Main.ShiftOS
void timer1_Tick(object sender, EventArgs e) =>
taskbarClock.Text = $"{DateTime.Now:t}";
- void terminalToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var trm = new Terminal();
- ShiftWM.Init(trm, "Terminal", null);
- }
+ private void terminalToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ Apps.Terminal trm = new Apps.Terminal();
+
+ ShiftWM.Init(trm, "Terminal", null, false, true);
+ }
void textPadToolStripMenuItem_Click(object sender, EventArgs e)
{
@@ -72,4 +73,4 @@ namespace ShiftOS.Main.ShiftOS
ShiftWM.Init(fs, "File Skimmer", Resources.iconFileSkimmer);
}
}
-} \ No newline at end of file
+}