diff --git a/src/ConsoleBuffer/Line.cs b/src/ConsoleBuffer/Line.cs index 16f8f7f..874df01 100644 --- a/src/ConsoleBuffer/Line.cs +++ b/src/ConsoleBuffer/Line.cs @@ -52,7 +52,7 @@ public override string ToString() var sb = new StringBuilder(this.chars.Count); foreach (var c in this.chars) { - sb.Append(c.Glyph); + sb.Append((char)c.Glyph); } return sb.ToString(); } diff --git a/src/ConsoleBuffer/Logger.cs b/src/ConsoleBuffer/Logger.cs index 05ef692..d8e3e76 100644 --- a/src/ConsoleBuffer/Logger.cs +++ b/src/ConsoleBuffer/Logger.cs @@ -6,14 +6,21 @@ public sealed class Logger { - private static readonly Logger Instance = new Logger(); + private static Logger Instance = null; private readonly StreamWriter writer; - private Logger() + public static void Init(string filename) { - var logfile = Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), @"Source\Repos\wincon\wincon.log"); - this.writer = new StreamWriter(logfile, false, Encoding.UTF8); + if (Instance == null) + { + Instance = new Logger(filename); + } + } + + private Logger(string filename) + { + this.writer = new StreamWriter(filename, false, Encoding.UTF8); } private void Write(string msg) @@ -27,7 +34,7 @@ private void Write(string msg) public static void Verbose(string msg) { - Instance.Write(msg); + Instance?.Write(msg); } } } diff --git a/src/condo/App.xaml.cs b/src/condo/App.xaml.cs index 0cd31d1..e368ce8 100644 --- a/src/condo/App.xaml.cs +++ b/src/condo/App.xaml.cs @@ -30,6 +30,7 @@ public App() { this.InitializeComponent(); this.Suspending += OnSuspending; + ConsoleBuffer.Logger.Init(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "wincon.log")); } /// diff --git a/src/condo/MainPage.xaml.cs b/src/condo/MainPage.xaml.cs index 57b8415..1c9e025 100644 --- a/src/condo/MainPage.xaml.cs +++ b/src/condo/MainPage.xaml.cs @@ -24,15 +24,14 @@ public MainPage() this.Loaded += this.OnLoaded; this.console = TerminalManager.Instance.GetOrCreate(0, "ping -t localhost"); - System.Diagnostics.Debugger.Launch(); - this.stuff.Text = "abjkkas"; - //this.console.PropertyChanged += this.UpdateContents; + this.characters = new ConsoleBuffer.Character[this.console.Height, this.console.Width]; + //System.Diagnostics.Debugger.Launch(); } - private async void UpdateContents(object sender, PropertyChangedEventArgs args) + private void UpdateContents(object sender, PropertyChangedEventArgs args) { this.console.Buffer.Render(this); - await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => this.Redraw()); + this.Dispatcher.TryRunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => this.Redraw()); } private Size DetermineSize() @@ -47,9 +46,7 @@ private void OnLoaded(object sender, RoutedEventArgs e) var stuffSize = this.DetermineSize(); this.stuff.Height = stuffSize.Height; this.stuff.Width = stuffSize.Width; - - this.characters = new ConsoleBuffer.Character[this.console.Height, this.console.Width]; - this.Redraw(); + this.console.PropertyChanged += this.UpdateContents; } private void Redraw() @@ -64,7 +61,7 @@ private void Redraw() sb.Append('\n'); } - this.stuff.Text = sb.ToString(); + //this.stuff.Text = sb.ToString(); } public void RenderCharacter(ConsoleBuffer.Character c, int x, int y)