Skip to content

Commit

Permalink
Further cleanup of Giles Setup. Window size and position no longer se…
Browse files Browse the repository at this point in the history
…t. No longer blocking Ctrl-C (GH-4)
  • Loading branch information
codereflection committed Nov 6, 2011
1 parent 7b9c84a commit 3537cfb
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/Giles/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ static void Main(string[] args) {
Environment.Exit(1);
}

config = GilesSetupFor(options);
config = GetGilesConfigFor(options);

kernel = new StandardKernel(new SlayerModule(config));

ConsoleSetup();

sourceWatcher = StartSourceWatcher();

SetupInteractiveMenuOptions();
menuOptions = GetInteractiveMenuOptions();

DisplayInteractiveMenuOptions();

MainFeedbackLoop();
}

static GilesConfig GilesSetupFor(CLOptions options)
static GilesConfig GetGilesConfigFor(CLOptions options)
{
var solutionPath = options.SolutionPath.Replace("\"", string.Empty);
var testAssemblyPath = GetTestAssemblyPath(options);
Expand All @@ -63,11 +63,11 @@ static string GetGilesFunnyLine()
}

static SourceWatcher StartSourceWatcher() {
var sourceWatcher = kernel.Get<SourceWatcher>();
var watcher = kernel.Get<SourceWatcher>();

// HACK: Only *.cs files? Really?
sourceWatcher.Watch(config.SolutionPath, @"*.cs");
return sourceWatcher;
watcher.Watch(config.SolutionPath, @"*.cs");
return watcher;
}

private static string GetTestAssemblyPath(CLOptions options)
Expand Down Expand Up @@ -116,16 +116,15 @@ private static int Width {
static void ConsoleSetup() {
Console.Clear();
Console.Title = GetGilesFunnyLine();
GilesConsoleWindowControls.SetConsoleWindowPosition(0, 75);
Console.SetBufferSize(1024, 5000);
//GilesConsoleWindowControls.SetConsoleWindowPosition(0, 75);
//Console.SetBufferSize(1024, 5000);
//Console.SetWindowSize(Width, Height);
Console.CancelKeyPress += Console_CancelKeyPress;
Console.WriteLine("Giles - your own personal watcher");
Console.WriteLine("\t\"I'd like to test that theory...\"\n\n");
}

static void SetupInteractiveMenuOptions() {
menuOptions = new[]
static InteractiveMenuOption[] GetInteractiveMenuOptions() {
return new[]
{
new InteractiveMenuOption { HandlesKey = key => key == "?", Task = DisplayInteractiveMenuOptions },
new InteractiveMenuOption { HandlesKey = key => key == "i", Task = DisplayConfig },
Expand All @@ -147,6 +146,7 @@ static void MainFeedbackLoop() {
.Where(option => option.HandlesKey(keyValue))
.Each(option => option.Task());
}
Console.WriteLine("Until next time...");
}

static void RequestQuit() {
Expand Down Expand Up @@ -182,11 +182,6 @@ static T GetUserValue<T>(T defaultValue) {
return (T)Convert.ChangeType(newValue, typeof(T));
}

static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) {
// eating the ctrl-c for breakfast...
e.Cancel = true;
}

static void DisplayConfig() {
Console.WriteLine("\nCurrent Configuration");
Console.WriteLine(" Build Delay: " + config.BuildDelay);
Expand Down

0 comments on commit 3537cfb

Please sign in to comment.