Skip to content

Commit

Permalink
sort of vaguely working uwp except it freezes up pretty fast wheee
Browse files Browse the repository at this point in the history
  • Loading branch information
doubleyewdee committed Nov 13, 2018
1 parent ef05c6a commit 11dd8d4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/ConsoleBuffer/Line.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
17 changes: 12 additions & 5 deletions src/ConsoleBuffer/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -27,7 +34,7 @@ private void Write(string msg)

public static void Verbose(string msg)
{
Instance.Write(msg);
Instance?.Write(msg);
}
}
}
1 change: 1 addition & 0 deletions src/condo/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
ConsoleBuffer.Logger.Init(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "wincon.log"));
}

/// <summary>
Expand Down
15 changes: 6 additions & 9 deletions src/condo/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit 11dd8d4

Please sign in to comment.