diff --git a/TerminalPilot/.vs/TerminalPilot/v17/.suo b/TerminalPilot/.vs/TerminalPilot/v17/.suo index c665d22..eaa8a1c 100644 Binary files a/TerminalPilot/.vs/TerminalPilot/v17/.suo and b/TerminalPilot/.vs/TerminalPilot/v17/.suo differ diff --git a/TerminalPilot/Classes/DevAuth.cs b/TerminalPilot/Classes/DevAuth.cs index cf9682c..48b01ba 100644 --- a/TerminalPilot/Classes/DevAuth.cs +++ b/TerminalPilot/Classes/DevAuth.cs @@ -58,7 +58,7 @@ public static void InitAuth(string command) { if (ConfigManager.GetUserToken() != String.Empty) { - Console.WriteLine("You are already authenticated!".Pastel(Color.FromArgb(255, 115, 96, 223))); + Console.WriteLine("You are already authenticated!".Pastel(Palletes.GetCurrentPallete(Enums.PalleteType.Small1))); return; } if (command.Split(' ').Length > 2) @@ -66,7 +66,7 @@ public static void InitAuth(string command) if (command.Split(' ')[2] == "logout") { ConfigManager.SetUserToken(null); - Console.WriteLine("You have been logged out.".Pastel(Color.FromArgb(255, 115, 96, 223))); + Console.WriteLine("You have been logged out.".Pastel(Palletes.GetCurrentPallete(Enums.PalleteType.Small1))); return; } } @@ -81,12 +81,12 @@ public static void InitAuth(string command) }; System.Diagnostics.Process.Start(psi); Console.WriteLine(); - Console.WriteLine("Head over to your browser window and complete the authentication.".Pastel(Color.FromArgb(255, 115, 96, 223))); + Console.WriteLine("Head over to your browser window and complete the authentication.".Pastel(Palletes.GetCurrentPallete(Enums.PalleteType.Large))); var usertokenpromise = GetUserTokenLoop(exchangeToken); usertokenpromise.Wait(); var usertoken = usertokenpromise.Result.UserToken; Console.WriteLine(); - Console.WriteLine("Authentication complete!".Pastel(Color.FromArgb(255, 115, 96, 223))); + Console.WriteLine("Authentication complete!".Pastel(Palletes.GetCurrentPallete(Enums.PalleteType.Large))); //save the user token with the config manager ConfigManager.SetUserToken(usertoken); } diff --git a/TerminalPilot/Classes/Palletes.cs b/TerminalPilot/Classes/Palletes.cs new file mode 100644 index 0000000..119196c --- /dev/null +++ b/TerminalPilot/Classes/Palletes.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TerminalPilot.Enums; +using TerminalPilot.Parser; + +namespace TerminalPilot.Classes +{ + //base class + public class Palletes { + public class PalleteClass + { + public Color LargeColor { get; set; } + public Color SmallColor1 { get; set; } + public Color SmallColor2 { get; set; } + public Color SmallColor3 { get; set; } + } + + public static string CurrentPallete = "NeonPurple"; + + public static Color GetCurrentPallete(PalleteType type) + { + PalleteClass currentpallete = IncludedPalletes[CurrentPallete]; + if (type == PalleteType.Large) + { + return currentpallete.LargeColor; + } + else if (type == PalleteType.Small1) + { + return currentpallete.SmallColor1; + } + else if (type == PalleteType.Small2) + { + return currentpallete.SmallColor2; + } + else if (type == PalleteType.Small3) + { + return currentpallete.SmallColor3; + } + return Color.White; + } + public static void SetCurrentPallete(string pallete) + { + CurrentPallete = pallete; + } + public static Dictionary IncludedPalletes = new Dictionary() + { + //neon purple (defualt and my favorite) + {"NeonPurple", new PalleteClass() + { + LargeColor = Color.FromArgb(0, 101, 40, 247), + SmallColor1 = Color.FromArgb(0, 160, 118, 249), + SmallColor2 = Color.FromArgb(0, 215, 187, 245), + SmallColor3 = Color.FromArgb(0, 237, 228, 255), + }}, + // sunset pastel + {"SunsetPastel", new PalleteClass() + { + LargeColor = Color.FromArgb(0, 101, 40, 247), + SmallColor1 = Color.FromArgb(0, 160, 118, 249), + SmallColor2 = Color.FromArgb(0, 215, 187, 245), + SmallColor3 = Color.FromArgb(0, 237, 228, 255), + } + } + }; +} +} diff --git a/TerminalPilot/Classes/ParserConfig.cs b/TerminalPilot/Classes/ParserConfig.cs index b01eb9f..8d261bd 100644 --- a/TerminalPilot/Classes/ParserConfig.cs +++ b/TerminalPilot/Classes/ParserConfig.cs @@ -9,6 +9,6 @@ namespace TerminalPilot.Classes { public class ParserConfig { - public string linefeed = "{PATH}" + ">".Pastel(Color.FromArgb(51, 255, 82)); + public string linefeed = "{USERPATH}{AFTERUSERPATH}" + ">".Pastel(Palletes.GetCurrentPallete(Enums.PalleteType.Large)); } } diff --git a/TerminalPilot/Enums/PalleteType.cs b/TerminalPilot/Enums/PalleteType.cs new file mode 100644 index 0000000..85f9809 --- /dev/null +++ b/TerminalPilot/Enums/PalleteType.cs @@ -0,0 +1,11 @@ +namespace TerminalPilot.Enums +{ + public enum PalleteType + { + Large, + Small1, + Small2, + Small3 + + } +} \ No newline at end of file diff --git a/TerminalPilot/OSSupport/AutomaticConfigConfigurer.cs b/TerminalPilot/OSSupport/AutomaticConfigConfigurer.cs new file mode 100644 index 0000000..66dc80b --- /dev/null +++ b/TerminalPilot/OSSupport/AutomaticConfigConfigurer.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using TerminalPilot.Classes; + +namespace TerminalPilot.OSSupport +{ + public class AutomaticConfigConfigurer + { + public static void StartupConfigure() + { + //check if were on a unix system + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + //options are + // /bin/bash + // custom + ConfigManager.SetShell("/bin/bash", "-c \"{COMMAND}\""); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + //options are + // cmd + // powershell + // custom + ConfigManager.SetShell("cmd.exe", "/c \"{COMMAND}\""); + } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + //options are + // zsh + // /bin/bash + // custom + ConfigManager.SetShell("/bin/zsh", "-c \"{COMMAND}\""); + } + } + } +} diff --git a/TerminalPilot/Parser/Interpreter.cs b/TerminalPilot/Parser/Interpreter.cs index f87d12d..fbd317d 100644 --- a/TerminalPilot/Parser/Interpreter.cs +++ b/TerminalPilot/Parser/Interpreter.cs @@ -19,24 +19,23 @@ public class Command } public class Interpreter { - public static Command[] TerminalPilotCommands = new Command[] { - new Command() { - StartIdentifier = "serial", - Tip = "Use the command 'pilot serial [Port] [Baudrate]' to open a terminal serial connection.", - Example = "pilot serial COM10 9600" - }, - new Command() { - StartIdentifier = "auth", - Tip = "Use the command 'pilot auth' to authenticate with your GitHub account, and get access to tons of cool features.", - Example = "pilot auth" - }, - new Command() { - StartIdentifier = "config", - Tip = "use the command 'pilot config [Mode] [Key] [Value]' to set or get a config parameter.", - Example = "pilot config get Shell" - } - }; + new Command() { + StartIdentifier = "serial", + Tip = "Use the command 'pilot serial [Port] [Baudrate]' to open a terminal serial connection.", + Example = "pilot serial COM10 9600" + }, + new Command() { + StartIdentifier = "auth", + Tip = "Use the command 'pilot auth' to authenticate with your GitHub account, and get access to tons of cool features.", + Example = "pilot auth" + }, + new Command() { + StartIdentifier = "config", + Tip = "use the command 'pilot config [Mode] [Key] [Value]' to set or get a config parameter.", + Example = "pilot config get Shell" + } + }; public static InputType DetermineInputType(string startcommand, TerminalInstance instance) { if ("pilot" == startcommand.Split(' ')[0]) diff --git a/TerminalPilot/Parser/Parser.cs b/TerminalPilot/Parser/Parser.cs index 2c68c76..072f518 100644 --- a/TerminalPilot/Parser/Parser.cs +++ b/TerminalPilot/Parser/Parser.cs @@ -29,7 +29,16 @@ public static void NewLine(TerminalInstance instance) { ParserConfig config = new ParserConfig(); Console.WriteLine(); - Console.Write(config.linefeed.Replace("{PATH}", instance.Workingdirectory.FullName)); + string AfterUserPath = instance.Workingdirectory.FullName.Replace(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ""); + string UserPathAndBefore = instance.Workingdirectory.FullName.Replace(AfterUserPath, ""); + Console.Write(config.linefeed.Replace("{PATH}", UserPathAndBefore.Pastel(Palletes.GetCurrentPallete(PalleteType.Small1))) + AfterUserPath.Pastel(Palletes.GetCurrentPallete(PalleteType.Large))); + } + public static string GetNewLine(TerminalInstance instance) + { + ParserConfig config = new ParserConfig(); + string AfterUserPath = instance.Workingdirectory.FullName.Replace(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ""); + string UserPathAndBefore = instance.Workingdirectory.FullName.Replace(AfterUserPath, ""); + return config.linefeed.Replace("{USERPATH}", UserPathAndBefore.Pastel(Palletes.GetCurrentPallete(PalleteType.Large))).Replace("{AFTERUSERPATH}", AfterUserPath.Pastel(Palletes.GetCurrentPallete(PalleteType.Small1))); } public void StartParse(TerminalInstance instance) { @@ -76,7 +85,9 @@ void messagetip(string message) string _tempflag_pathbeforedireditor = ""; string _tempflag_linecursorleft = ""; Console.WriteLine(); - Console.Write(parseconfig.linefeed.Replace("{PATH}", instance.Workingdirectory.FullName)); + string AfterUserPath = instance.Workingdirectory.FullName.Replace(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ""); + string UserPathAndBefore = instance.Workingdirectory.FullName.Replace(AfterUserPath, ""); + Console.Write(GetNewLine(instance)); _tempflag_deletelimit = Console.CursorLeft; _tempflag_deletelimity = Console.CursorTop; while (instance.alive == true) @@ -99,7 +110,7 @@ void messagetip(string message) Console.WriteLine(); Interpreter.InterpreteCommand(_tempflag_commandwinput, instance); _tempflag_commandwinput = ""; - Console.Write(parseconfig.linefeed.Replace("{PATH}", instance.Workingdirectory.FullName)); + Console.Write(GetNewLine(instance)); _tempflag_deletelimit = Console.CursorLeft; _tempflag_deletelimity = Console.CursorTop; @@ -117,7 +128,10 @@ void messagetip(string message) instance.Workingdirectory = instance.Workingdirectory.Parent; RemoveConsoleLine(Console.CursorTop); - Console.Write(parseconfig.linefeed.Replace("{PATH}", instance.Workingdirectory.FullName).Replace(">", OsDirectoryManager.GetOsBackSpaceString())); + Console.WriteLine(); + AfterUserPath = instance.Workingdirectory.FullName.Replace(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ""); + UserPathAndBefore = instance.Workingdirectory.FullName.Replace(AfterUserPath, ""); + Console.Write(GetNewLine(instance).Replace(">", OsDirectoryManager.GetOsBackSpaceString())); _tempflag_deletelimit = Console.CursorLeft; _tempflag_deletelimity = Console.CursorTop; @@ -131,7 +145,7 @@ void messagetip(string message) //enter dir editor messagetip("You are in directory editor. to exit, press tab."); RemoveConsoleLine(Console.CursorTop); - Console.Write(parseconfig.linefeed.Replace("{PATH}", instance.Workingdirectory.FullName).Replace(">", @"")); + Console.Write(GetNewLine(instance).Replace(">", @"")); Console.CursorLeft = _disposableflag_cursorpos - 1; } @@ -204,7 +218,7 @@ void messagetip(string message) { _grammarflag_plural = " directories"; } - Console.WriteLine("Successfully created " + _disposableflag_dirscreated.ToString().Pastel(Color.Aqua) + _grammarflag_plural); + Console.WriteLine("Successfully created " + _disposableflag_dirscreated.ToString().Pastel(Palletes.GetCurrentPallete(Enums.PalleteType.Small1)) + _grammarflag_plural); instance.Workingdirectory = dirinf; } } @@ -212,7 +226,7 @@ void messagetip(string message) { instance.Workingdirectory = dirinf; } - Console.Write(parseconfig.linefeed.Replace("{PATH}", instance.Workingdirectory.FullName)); + Console.Write(GetNewLine(instance)); _tempflag_deletelimit = Console.CursorLeft; } else diff --git a/TerminalPilot/Program.cs b/TerminalPilot/Program.cs index abd13ae..5cf66ce 100644 --- a/TerminalPilot/Program.cs +++ b/TerminalPilot/Program.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Pastel; using TerminalPilot.Classes; +using TerminalPilot.OSSupport; namespace TerminalPilot { internal class Program @@ -22,18 +23,24 @@ static void Main(string[] args) Configuration config = new Configuration(); OSVariables os = new OSVariables(); + if (ConfigManager.GetShell() == "") + { + AutomaticConfigConfigurer.StartupConfigure(); + instance.Shell = ConfigManager.GetShell(); + instance.ShellCommandArgument = ConfigManager.GetShellArgument(); + } //handle defualt shell - + instance.Workingdirectory = new DirectoryInfo(config.StartUpPath); ConfigManager.StartUp(); Console.Clear(); instance.alive = true; instance.name = "Terminal"; - Console.WriteLine("TerminalPilot".Pastel(Color.Aqua) + ", Version " + Assembly.GetExecutingAssembly().GetName().Version); + Console.WriteLine("TerminalPilot".Pastel(Palletes.GetCurrentPallete(Enums.PalleteType.Large)) + ", Version " + Assembly.GetExecutingAssembly().GetName().Version); Console.WriteLine("From pyrret, Under MIT License."); Console.WriteLine(); - Console.WriteLine("Current Shell: " + instance.Shell.Pastel(Color.Aqua)); + Console.WriteLine("Current Shell: " + instance.Shell.Pastel(Palletes.GetCurrentPallete(Enums.PalleteType.Small1)) + ". You can change it with " + "'pilot shell'".Pastel(Palletes.GetCurrentPallete(Enums.PalleteType.Small1))); Parser.Parser parser = new Parser.Parser(); parser.StartParse(instance); diff --git a/TerminalPilot/app.config b/TerminalPilot/app.config index e7c5695..fa3a757 100644 --- a/TerminalPilot/app.config +++ b/TerminalPilot/app.config @@ -8,8 +8,8 @@ - - + +