aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Main/ShiftOS
diff options
context:
space:
mode:
authorAlex-TIMEHACK <[email protected]>2017-10-15 20:25:37 +0100
committerAlex-TIMEHACK <[email protected]>2017-10-15 20:25:37 +0100
commitb2f7322f3072ff90c8e6039ec4b3219d3c3fb919 (patch)
treec9bfc21c4cc20df9eab5dbaa1c12772a90ef0f74 /ShiftOS.Main/ShiftOS
parent7efdde5832b517153363621aaec982211ff25f61 (diff)
downloadshiftos-rewind-b2f7322f3072ff90c8e6039ec4b3219d3c3fb919.tar.gz
shiftos-rewind-b2f7322f3072ff90c8e6039ec4b3219d3c3fb919.tar.bz2
shiftos-rewind-b2f7322f3072ff90c8e6039ec4b3219d3c3fb919.zip
It's broken.
Diffstat (limited to 'ShiftOS.Main/ShiftOS')
-rw-r--r--ShiftOS.Main/ShiftOS/Apps/Terminal.Designer.cs2
-rw-r--r--ShiftOS.Main/ShiftOS/Apps/Terminal.cs72
-rw-r--r--ShiftOS.Main/ShiftOS/Desktop.cs2
3 files changed, 46 insertions, 30 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 a9bd093..1bd5c03 100644
--- a/ShiftOS.Main/ShiftOS/Apps/Terminal.cs
+++ b/ShiftOS.Main/ShiftOS/Apps/Terminal.cs
@@ -8,15 +8,19 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
-using ShiftOS.Engine.Terminal;
+using ShiftOS.Main.Terminal;
namespace ShiftOS.Main.ShiftOS.Apps
{
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 DoClear = false;
+ public bool RunningCommand = false;
+ public bool WaitingResponse = false;
+ public string InputReturnText = "";
// The below variables makes the terminal... a terminal!
public string OldText = "";
@@ -27,12 +31,8 @@ namespace ShiftOS.Main.ShiftOS.Apps
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;
+ TerminalBackend.trm.Add(this); // Makes the commands run!
}
private void termmain_KeyDown(object sender, KeyEventArgs e)
@@ -45,51 +45,67 @@ namespace ShiftOS.Main.ShiftOS.Apps
// 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!
+ 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 (termmain.SelectionStart < TrackingPosition)
+ if (!RunningCommand)
{
- if (doClear == false) // If it's not clearing the terminal
+ if (termmain.SelectionStart < TrackingPosition)
{
- termmain.Text = OldText;
- termmain.Select(termmain.Text.Length, 0);
+ if (!DoClear) // If it's not clearing the terminal
+ {
+ termmain.Text = OldText;
+ termmain.Select(termmain.Text.Length, 0);
+ }
+ }
+ else
+ {
+ OldText = termmain.Text;
}
- }
- else
- {
- OldText = termmain.Text;
}
}
private void termmain_SelectionChanged(object sender, EventArgs e)
{
- if (termmain.SelectionStart < TrackingPosition)
+ if (!RunningCommand)
{
- termmain.Text = OldText;
- termmain.Select(termmain.Text.Length, 0);
+ if (termmain.SelectionStart < TrackingPosition)
+ {
+ termmain.Text = OldText;
+ termmain.Select(termmain.Text.Length, 0);
+ }
}
}
private void Terminal_Load(object sender, EventArgs e)
{
- Print("\n");
+ termmain.Text = $"\n {defaulttextResult}";
+ TrackingPosition = termmain.Text.Length;
}
- public string RunCommand(string command)
+ public void Input(string request)
{
- string ToReturn = "";
+ InputReturnText = "";
+ RunningCommand = false;
- if (command == "hi")
- {
- ToReturn = $"{ToReturn} \n Hi!";
- MessageBox.Show("HI!");
- }
- return ToReturn;
+ termmain.AppendText($"\n {request} ");
+ TrackingPosition = termmain.Text.Length;
+ }
+
+ public void Clear()
+ {
+ DoClear = true;
+ termmain.Text = $"\n {defaulttextResult}";
+ TrackingPosition = termmain.Text.Length;
+ DoClear = false;
}
}
}
diff --git a/ShiftOS.Main/ShiftOS/Desktop.cs b/ShiftOS.Main/ShiftOS/Desktop.cs
index 06f1fc8..3477788 100644
--- a/ShiftOS.Main/ShiftOS/Desktop.cs
+++ b/ShiftOS.Main/ShiftOS/Desktop.cs
@@ -61,7 +61,7 @@ namespace ShiftOS.Main.ShiftOS
private void terminalToolStripMenuItem_Click(object sender, EventArgs e)
{
Apps.Terminal trm = new Apps.Terminal();
-
+
ShiftWM.Init(trm, "Terminal", null, false, true);
}
}