diff --git a/ConsoleBuffer.sln b/ConsoleBuffer.sln
index 0279023..5cdd3b5 100644
--- a/ConsoleBuffer.sln
+++ b/ConsoleBuffer.sln
@@ -5,7 +5,7 @@ VisualStudioVersion = 15.0.28010.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleBuffer", "src\ConsoleBuffer\ConsoleBuffer.csproj", "{A16D11B0-4785-434F-8514-ABCC16DDFBFD}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "condo", "src\condo\condo.csproj", "{D890EB09-11B9-41A8-B9A7-C1D159312A32}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "condo.wpf", "src\condo.wpf\condo.wpf.csproj", "{D890EB09-11B9-41A8-B9A7-C1D159312A32}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/src/ConsoleBuffer/Buffer.cs b/src/ConsoleBuffer/Buffer.cs
index 75aeedd..5b48ca5 100644
--- a/src/ConsoleBuffer/Buffer.cs
+++ b/src/ConsoleBuffer/Buffer.cs
@@ -13,6 +13,7 @@ public sealed class Buffer : INotifyPropertyChanged
private short cursorX;
private short cursorY;
+ private int currentChar;
public (short X, short Y) CursorPosition => (this.cursorX, this.cursorY);
private short bufferTopVisibleLine
@@ -46,8 +47,9 @@ public void Append(byte[] bytes, int length)
{
for (var i = 0;i < length; ++i)
{
- var ch = (char)bytes[i];
- if (ch == '\n')
+ if (!this.AppendChar(bytes[i])) continue;
+
+ if (this.currentChar == '\n')
{
Logger.Verbose($"newline (current: {this.lines[this.currentLine]})");
if (this.currentLine == this.lines.Count - 1)
@@ -57,18 +59,29 @@ public void Append(byte[] bytes, int length)
this.cursorY = (short)Math.Min(this.Height - 1, this.cursorY + 1);
}
- else if (ch == '\r')
+ else if (this.currentChar == '\r')
{
Logger.Verbose($"carriage return");
this.cursorX = 0;
}
- this.lines[this.currentLine].Set(this.cursorX, new Character { Glyph = ch });
+ this.lines[this.currentLine].Set(this.cursorX, new Character { Glyph = this.currentChar });
this.cursorX = (short)Math.Min(this.Width - 1, this.cursorX + 1);
}
}
}
+ ///
+ /// Append a single byte to the current character.
+ ///
+ /// true if the current character represents a completed Unicode character
+ private bool AppendChar(byte b)
+ {
+ // TODO: actual utf-8 parsing.
+ this.currentChar = b;
+ return true;
+ }
+
///
/// Render character-by-character onto the specified target.
///
diff --git a/src/ConsoleBuffer/Character.cs b/src/ConsoleBuffer/Character.cs
index 6de42cb..310fe5b 100644
--- a/src/ConsoleBuffer/Character.cs
+++ b/src/ConsoleBuffer/Character.cs
@@ -1,12 +1,10 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ConsoleBuffer
+namespace ConsoleBuffer
{
// XXX: Gonna end up with a lot of these and they're really freakin' big.
+ // could consider a morphable type with different sizes to avoid the (currently) 12 bytes-per-character issue.
+ // on a 'normal' 80x25 terminal the current buffer alone is just >23kB. A 160 character wide buffer with a 32k
+ // line scrollback is nearly 60MB. Per buffer. Not an issue now but something we should care about and fix in
+ // the future.
public struct Character
{
public struct ColorInfo
@@ -19,6 +17,6 @@ public struct ColorInfo
public ColorInfo Foreground { get; set; }
public ColorInfo Background { get; set; }
- public char Glyph { get; set; } // XXX: char won't cut it for emoji/etc, gonna have to re-do this later!
+ public int Glyph { get; set; } // XXX: a single int isn't quite sufficient to represent emoji with ZWJ. fix later.
}
}
diff --git a/src/condo/App.xaml.cs b/src/condo/App.xaml.cs
index 7311394..a3c5eac 100644
--- a/src/condo/App.xaml.cs
+++ b/src/condo/App.xaml.cs
@@ -1,10 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Data;
-using System.IO;
-using System.Linq;
-using System.Threading;
using System.Threading.Tasks;
using System.Windows;
@@ -19,11 +13,6 @@ public App()
{
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
-
- // XXX: this is some garbage. tasks are a pain.
-#if DEBUG
- new Timer((_) => GC.Collect(2, GCCollectionMode.Forced, true, true), null, TimeSpan.Zero, TimeSpan.FromMilliseconds(50));
-#endif
}
private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
diff --git a/src/condo/MainWindow.xaml.cs b/src/condo/MainWindow.xaml.cs
index b3b46f9..41863a3 100644
--- a/src/condo/MainWindow.xaml.cs
+++ b/src/condo/MainWindow.xaml.cs
@@ -1,12 +1,8 @@
namespace condo
{
- using System;
using System.ComponentModel;
using System.Globalization;
- using System.IO;
using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
@@ -26,6 +22,7 @@ public MainWindow()
this.Loaded += this.OnLoaded;
this.console = TerminalManager.Instance.GetOrCreate(0, "ping -t localhost");
+ System.Diagnostics.Debugger.Launch();
this.console.PropertyChanged += this.UpdateContents;
}
@@ -67,7 +64,7 @@ private void Redraw()
{
for (var y = 0; y < this.console.Width; ++y)
{
- sb.Append(this.characters[x, y].Glyph);
+ sb.Append((char)this.characters[x, y].Glyph);
}
sb.Append('\n');
}
diff --git a/src/condo/Properties/AssemblyInfo.cs b/src/condo/Properties/AssemblyInfo.cs
index cad628e..3b2128b 100644
--- a/src/condo/Properties/AssemblyInfo.cs
+++ b/src/condo/Properties/AssemblyInfo.cs
@@ -1,6 +1,4 @@
using System.Reflection;
-using System.Resources;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
diff --git a/src/condo/TerminalManager.cs b/src/condo/TerminalManager.cs
index bfac4ca..a90f19e 100644
--- a/src/condo/TerminalManager.cs
+++ b/src/condo/TerminalManager.cs
@@ -2,7 +2,6 @@
{
using ConsoleBuffer;
using System.Collections.Generic;
- using System.Threading.Tasks;
///
/// Manages creating/destroying terminals through queued requests.
diff --git a/src/condo/condo.csproj b/src/condo/condo.csproj
deleted file mode 100644
index 766d9a7..0000000
--- a/src/condo/condo.csproj
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {D890EB09-11B9-41A8-B9A7-C1D159312A32}
- WinExe
- condo
- condo
- v4.7.2
- 512
- {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 4
- true
- true
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
- 4.0
-
-
-
-
-
-
-
- MSBuild:Compile
- Designer
-
-
-
- MSBuild:Compile
- Designer
-
-
- App.xaml
- Code
-
-
- MainWindow.xaml
- Code
-
-
-
-
- Code
-
-
- True
- True
- Resources.resx
-
-
- True
- Settings.settings
- True
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
-
-
-
-
-
- {a16d11b0-4785-434f-8514-abcc16ddfbfd}
- ConsoleBuffer
-
-
-
-
\ No newline at end of file