public DefaultGitPromptSettings(ConsoleColor defaultBackgroundColor) { After = PromptColor.Create(ConsoleColor.Yellow, defaultBackgroundColor); Before = PromptColor.Create(ConsoleColor.Yellow, defaultBackgroundColor); BeforeIndex = PromptColor.Create(ConsoleColor.DarkGreen, defaultBackgroundColor); Branch = PromptColor.Create(ConsoleColor.Cyan, defaultBackgroundColor); BranchAhead = PromptColor.Create(ConsoleColor.Green, defaultBackgroundColor); BranchBehind = PromptColor.Create(ConsoleColor.Red, defaultBackgroundColor); BranchBehindAndAhead = PromptColor.Create(ConsoleColor.Yellow, defaultBackgroundColor); Delim = PromptColor.Create(ConsoleColor.Yellow, defaultBackgroundColor); Index = PromptColor.Create(ConsoleColor.DarkGreen, defaultBackgroundColor); Untracked = PromptColor.Create(ConsoleColor.DarkRed, defaultBackgroundColor); Working = PromptColor.Create(ConsoleColor.DarkRed, defaultBackgroundColor); }
private void WriteColor(string msg, PromptColor color) { var previousForeground = Console.ForegroundColor; var previousBackground = Console.BackgroundColor; Console.ForegroundColor = color.Foreground; Console.BackgroundColor = color.Background; try { Console.Write(msg); } finally { Console.ForegroundColor = previousForeground; Console.BackgroundColor = previousBackground; } }
private void WriteColor(string msg, PromptColor color) { var previousForeground = Console.ForegroundColor; var previousBackground = Console.BackgroundColor; Console.ForegroundColor = color.Foreground; Console.BackgroundColor = color.Background; try { Console.Write(msg); } finally { Console.ForegroundColor = previousForeground; Console.BackgroundColor = previousBackground; } }