diff options
| author | Michael <[email protected]> | 2017-06-28 08:19:44 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-06-28 08:19:44 -0400 |
| commit | 00cd41ea928781ad760cff3d14bd78d60758679d (patch) | |
| tree | 1ce9714d71831cef82ebfd161827a4db54d90405 /ShiftOS.WinForms/Applications/Terminal.cs | |
| parent | cd2190f6caa16e8d909aa1d662996d690772a67f (diff) | |
| download | shiftos_thereturn-00cd41ea928781ad760cff3d14bd78d60758679d.tar.gz shiftos_thereturn-00cd41ea928781ad760cff3d14bd78d60758679d.tar.bz2 shiftos_thereturn-00cd41ea928781ad760cff3d14bd78d60758679d.zip | |
Slight... very slight... fileskimmer mods
Diffstat (limited to 'ShiftOS.WinForms/Applications/Terminal.cs')
| -rw-r--r-- | ShiftOS.WinForms/Applications/Terminal.cs | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 51ad42b..794edf7 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -47,12 +47,51 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { + [FileHandler("Shell script", ".trm", "fileicontrm")] [Launcher("{TITLE_TERMINAL}", false, null, "{AL_UTILITIES}")] [WinOpen("{WO_TERMINAL}")] [DefaultTitle("{TITLE_TERMINAL}")] [DefaultIcon("iconTerminal")] - public partial class Terminal : UserControl, IShiftOSWindow + public partial class Terminal : UserControl, IShiftOSWindow, IFileHandler { + public void OpenFile(string file) + { + int lastline = 0; + string lastlinetext = ""; + + try + { + var lines = new List<string>(ShiftOS.Objects.ShiftFS.Utils.ReadAllText(file).Split(new[] { Environment.NewLine.ToString() }, StringSplitOptions.RemoveEmptyEntries)); + AppearanceManager.SetupWindow(this); + var parser = CommandParser.GenerateSample(); + foreach (var line in lines) + { + lastline = lines.IndexOf(line) + 1; + lastlinetext = line; + var command = parser.ParseCommand(line); + TerminalBackend.InvokeCommand(command.Key, command.Value); + } + } + catch(Exception ex) + { + ConsoleEx.ForegroundColor = ConsoleColor.Red; + ConsoleEx.Bold = true; + Console.WriteLine("Script exception"); + ConsoleEx.ForegroundColor = ConsoleColor.Yellow; + ConsoleEx.Bold = false; + ConsoleEx.Italic = true; +#if DEBUG + Console.WriteLine(ex.Message); +#endif + Console.WriteLine(ex.StackTrace); + if(lastline > 0) + { + Console.WriteLine(" at " + lastlinetext + " (line " + lastline + ") in " + file); + } + } + TerminalBackend.PrintPrompt(); + } + public static Stack<string> ConsoleStack = new Stack<string>(); public static System.Windows.Forms.Timer ti = new System.Windows.Forms.Timer(); |
