aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Engine/Terminal
diff options
context:
space:
mode:
authorAlex-TIMEHACK <[email protected]>2017-11-18 16:33:30 +0000
committerAlex-TIMEHACK <[email protected]>2017-11-18 16:33:30 +0000
commit6faabfbbd86d70c99e197a3d8cfcf7db0680d17f (patch)
tree36b9adff940f8afe596d4b9c0ba0ef60a28bb690 /ShiftOS.Engine/Terminal
parent4037be53b29a122732cfc10693e9c0027f606bb0 (diff)
downloadshiftos-rewind-6faabfbbd86d70c99e197a3d8cfcf7db0680d17f.tar.gz
shiftos-rewind-6faabfbbd86d70c99e197a3d8cfcf7db0680d17f.tar.bz2
shiftos-rewind-6faabfbbd86d70c99e197a3d8cfcf7db0680d17f.zip
Fixed fork?
Diffstat (limited to 'ShiftOS.Engine/Terminal')
-rw-r--r--ShiftOS.Engine/Terminal/Commands/Hello.cs9
-rw-r--r--ShiftOS.Engine/Terminal/TerminalBackend.cs46
-rw-r--r--ShiftOS.Engine/Terminal/TerminalCommand.cs182
3 files changed, 0 insertions, 237 deletions
diff --git a/ShiftOS.Engine/Terminal/Commands/Hello.cs b/ShiftOS.Engine/Terminal/Commands/Hello.cs
deleted file mode 100644
index 7d4b82f..0000000
--- a/ShiftOS.Engine/Terminal/Commands/Hello.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace ShiftOS.Engine.Terminal.Commands
-{
- public class Hello : TerminalCommand
- {
- public override string GetName() => "Hello";
-
- public override string Run(params string[] parameters) => "Oh, HELLO, " + string.Join(" ", parameters);
- }
-} \ No newline at end of file
diff --git a/ShiftOS.Engine/Terminal/TerminalBackend.cs b/ShiftOS.Engine/Terminal/TerminalBackend.cs
deleted file mode 100644
index e079d22..0000000
--- a/ShiftOS.Engine/Terminal/TerminalBackend.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-
-namespace ShiftOS.Engine.Terminal
-{
- public static class TerminalBackend
- {
- // The line below gets all the terminal commands in... well... the entire ShiftOS.Engine
- public static IEnumerable<TerminalCommand> instances = Assembly.GetExecutingAssembly().GetTypes()
- .Where(t => t.IsSubclassOf(typeof(TerminalCommand)) && t.GetConstructor(Type.EmptyTypes) != null)
- .Select(t => Activator.CreateInstance(t) as TerminalCommand);
-
- /// <summary>
- /// Runs a terminal command.
- /// </summary>
- /// <param name="command"></param>
- /// <returns>Returns all the output from that command.</returns>
- public static string RunCommand(string command)
- {
- string name;
- try
- {
- name = command.Split(' ')[0];
- }
- catch
- {
- name = command;
- }
-
- var theParams = new string[command.Split(' ').Length - 1];
- Array.Copy(command.Split(' '), 1, theParams, 0, command.Split(' ').Length - 1);
-
- foreach (var instance in Instances)
- {
- if (instance.GetName() == name)
- {
- return instance.Run(theParams);
- }
- }
-
- return "The command cannot be found.";
- }
- }
-} \ No newline at end of file
diff --git a/ShiftOS.Engine/Terminal/TerminalCommand.cs b/ShiftOS.Engine/Terminal/TerminalCommand.cs
deleted file mode 100644
index 110d1d2..0000000
--- a/ShiftOS.Engine/Terminal/TerminalCommand.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-using System;
-
-using System.Collections.Generic;
-
-using System.Drawing;
-
-using System.Linq;
-
-using System.Text;
-
-using System.Threading.Tasks;
-
-using System.Windows.Forms;
-
-
-
-namespace ShiftOS.Main.Terminal
-{
-
- public class TerminalCommand
-
- {
-
- public int TermID { get; set; }
-
-
-
- public virtual string Name { get; }
-
- public virtual string Summary { get; }
-
- public virtual string Usage { get; }
-
- public virtual bool Unlocked { get; set; }
-
-
-
- public virtual void Run(params string[] parameters) { }
-
-
-
- /// <summary>
-
- /// Writes a blank line in the terminal.
-
- /// </summary>
-
- public virtual void WriteLine()
-
- {
-
- WriteLine("");
-
- }
-
-
-
- /// <summary>
-
- /// Writes specified text in the terminal and starts a new line.
-
- /// </summary>
-
- /// <param name="value"><summary>The text to write before the new line is made.</summary></param>
-
- public virtual void WriteLine(string value)
-
- {
-
- Array.Find(TerminalBackend.trm.ToArray(), w => w.TerminalID == TermID).termmain.AppendText($"{value} \n");
-
- }
-
-
-
- /// <summary>
-
- /// Writes specified text in the terminal in the specified color and starts a new line.
-
- /// </summary>
-
- /// <param name="value"><summary>The text to write before the new line is made.</summary></param>
-
- /// <param name="textClr"><summary>The color the text is written in.</summary></param>
-
- public virtual void WriteLine(string value, Color textClr)
-
- {
-
- ShiftOS.Apps.Terminal trm = Array.Find(TerminalBackend.trm.ToArray(), w => w.TerminalID == TermID);
-
-
-
- int startPoint = trm.termmain.Text.Length;
-
- trm.termmain.AppendText($"{value} \n");
-
- trm.termmain.Select(startPoint, $"{value} \n".Length);
-
- trm.termmain.SelectionColor = textClr;
-
- }
-
-
-
- /// <summary>
-
- /// Writes specified text in the terminal.
-
- /// </summary>
-
- /// <param name="value"><summary>The text to write.</summary></param>
-
- /// <param name="textClr"><summary>The color the text is written in.</summary></param>
-
- public virtual void Write(string value, Color textClr)
-
- {
-
-
-
- ShiftOS.Apps.Terminal trm = Array.Find(TerminalBackend.trm.ToArray(), w => w.TerminalID == TermID);
-
-
-
- int startPoint = trm.termmain.Text.Length;
-
- trm.termmain.AppendText($"{value}");
-
- trm.termmain.Select(startPoint, $"{value}".Length);
-
- trm.termmain.SelectionColor = textClr;
-
- }
-
-
-
- /// <summary>
-
- /// Writes specified text in the terminal.
-
- /// </summary>
-
- /// <param name="value"><summary>The text to say before requesting text. </summary></param>
-
- public virtual Task<string> Input(string value = "")
-
- {
-
- ShiftOS.Apps.Terminal trm = Array.Find(TerminalBackend.trm.ToArray(), w => w.TerminalID == TermID);
-
- trm.Input(value);
-
-
-
- Task<string> Input = new Task<string>(() =>
-
- {
-
- while (true)
-
- if (trm.InputReturnText != "") break;
-
-
-
- // The terminal has finally decided!
-
-
-
- return trm.InputReturnText;
-
- });
-
- Input.Start();
-
- return Input;
-
- }
-
- }
-
-} \ No newline at end of file