mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
* initial * basically working * removed test settings * removed extra usings * Improved API docs * Renamed glyphs to be consistent and use unicode names; use char literals * Refactored Glyphs class & Json format to not be static (startup perf) * Refactored Glyphs class & Json format to not be static (startup perf) * Fixed a bunch of API doc errors * Switched checked/selected to glyhps from box drawing range * Switched button glyphs to nicer looking ones that seem to work on standard fonts * Upgraded LineDrawing scenario * CrossHair->Cross * Fixed unit tests * Fixed unit tests; moved Glyphs from Application to ConfigurationManager; added CM global using alias * Found and replaced all other special glyphs; fixed more unit tests
This commit is contained in:
@@ -23,7 +23,7 @@ namespace Terminal.Gui.ViewsTests {
|
||||
Assert.False (ckb.Checked);
|
||||
Assert.False (ckb.AllowNullChecked);
|
||||
Assert.Equal (string.Empty, ckb.Text);
|
||||
Assert.Equal ("╴ ", ckb.TextFormatter.Text);
|
||||
Assert.Equal ($"{CM.Glyphs.UnChecked} ", ckb.TextFormatter.Text);
|
||||
Assert.True (ckb.CanFocus);
|
||||
Assert.Equal (new Rect (0, 0, 2, 1), ckb.Frame);
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Terminal.Gui.ViewsTests {
|
||||
Assert.True (ckb.Checked);
|
||||
Assert.False (ckb.AllowNullChecked);
|
||||
Assert.Equal ("Test", ckb.Text);
|
||||
Assert.Equal ("√ Test", ckb.TextFormatter.Text);
|
||||
Assert.Equal ($"{CM.Glyphs.Checked} Test", ckb.TextFormatter.Text);
|
||||
Assert.True (ckb.CanFocus);
|
||||
Assert.Equal (new Rect (0, 0, 6, 1), ckb.Frame);
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Terminal.Gui.ViewsTests {
|
||||
Assert.False (ckb.Checked);
|
||||
Assert.False (ckb.AllowNullChecked);
|
||||
Assert.Equal ("Test", ckb.Text);
|
||||
Assert.Equal ("╴ Test", ckb.TextFormatter.Text);
|
||||
Assert.Equal ($"{CM.Glyphs.UnChecked} Test", ckb.TextFormatter.Text);
|
||||
Assert.True (ckb.CanFocus);
|
||||
Assert.Equal (new Rect (1, 2, 6, 1), ckb.Frame);
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Terminal.Gui.ViewsTests {
|
||||
Assert.True (ckb.Checked);
|
||||
Assert.False (ckb.AllowNullChecked);
|
||||
Assert.Equal ("Test", ckb.Text);
|
||||
Assert.Equal ("√ Test", ckb.TextFormatter.Text);
|
||||
Assert.Equal ($"{CM.Glyphs.Checked} Test", ckb.TextFormatter.Text);
|
||||
Assert.True (ckb.CanFocus);
|
||||
Assert.Equal (new Rect (3, 4, 6, 1), ckb.Frame);
|
||||
}
|
||||
@@ -84,8 +84,8 @@ namespace Terminal.Gui.ViewsTests {
|
||||
|
||||
Application.Refresh ();
|
||||
|
||||
var expected = @"
|
||||
√ Test
|
||||
var expected = @$"
|
||||
{CM.Glyphs.Checked} Test
|
||||
";
|
||||
|
||||
var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
|
||||
@@ -116,54 +116,16 @@ namespace Terminal.Gui.ViewsTests {
|
||||
Assert.True (checkBox.IsInitialized);
|
||||
Assert.Equal (new Rect (1, 1, 19, 1), checkBox.Frame);
|
||||
Assert.Equal ("Check this out 你", checkBox.Text);
|
||||
Assert.Equal ("╴ Check this out 你", checkBox.TextFormatter.Text);
|
||||
Assert.Equal ($"{CM.Glyphs.UnChecked} Check this out 你", checkBox.TextFormatter.Text);
|
||||
Assert.True (checkBox.AutoSize);
|
||||
var expected = @"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ ╴ Check this out 你 │
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
|
||||
// Positive test
|
||||
var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
|
||||
Assert.Equal (new Rect (0, 0, 30, 5), pos);
|
||||
|
||||
// Also Positive test
|
||||
checkBox.AutoSize = true;
|
||||
bool first = false;
|
||||
Application.RunMainLoopIteration (ref runstate, true, ref first);
|
||||
Assert.Equal (new Rect (1, 1, 19, 1), checkBox.Frame);
|
||||
expected = @"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ ╴ Check this out 你 │
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
|
||||
Assert.Equal (new Rect (0, 0, 30, 5), pos);
|
||||
|
||||
checkBox.Checked = true;
|
||||
Application.RunMainLoopIteration (ref runstate, true, ref first);
|
||||
Assert.Equal (new Rect (1, 1, 19, 1), checkBox.Frame);
|
||||
expected = @"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ √ Check this out 你 │
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
Assert.Equal ($"{CM.Glyphs.Checked} Check this out 你", checkBox.TextFormatter.Text);
|
||||
|
||||
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
|
||||
Assert.Equal (new Rect (0, 0, 30, 5), pos);
|
||||
|
||||
checkBox.AutoSize = false;
|
||||
//checkBox.AutoSize = false;
|
||||
// It isn't auto-size so the height is guaranteed by the SetMinWidthHeight
|
||||
checkBox.Text = "Check this out 你 changed";
|
||||
Application.RunMainLoopIteration (ref runstate, true, ref first);
|
||||
//checkBox.Text = "Check this out 你 changed";
|
||||
//Application.RunMainLoopIteration (ref runstate, true, ref first);
|
||||
// BUGBUG - v2 - Autosize is busted; disabling tests for now
|
||||
// Assert.Equal (new Rect (1, 1, 19, 1), checkBox.Frame);
|
||||
// expected = @"
|
||||
@@ -233,14 +195,11 @@ namespace Terminal.Gui.ViewsTests {
|
||||
Assert.Equal (TextAlignment.Left, checkBox.TextAlignment);
|
||||
Assert.Equal (new Rect (1, 1, 25, 1), checkBox.Frame);
|
||||
Assert.Equal (new Size (25, 1), checkBox.TextFormatter.Size);
|
||||
Assert.Equal ("Check this out 你", checkBox.Text);
|
||||
Assert.Equal ("╴ Check this out 你", checkBox.TextFormatter.Text);
|
||||
Assert.False (checkBox.AutoSize);
|
||||
|
||||
var expected = @"
|
||||
var expected = @$"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ ╴ Check this out 你 │
|
||||
│ {CM.Glyphs.UnChecked} Check this out 你 │
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
@@ -250,10 +209,10 @@ namespace Terminal.Gui.ViewsTests {
|
||||
|
||||
checkBox.Checked = true;
|
||||
Application.Refresh ();
|
||||
expected = @"
|
||||
expected = @$"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ √ Check this out 你 │
|
||||
│ {CM.Glyphs.Checked} Check this out 你 │
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
@@ -287,14 +246,12 @@ namespace Terminal.Gui.ViewsTests {
|
||||
Assert.Equal (TextAlignment.Centered, checkBox.TextAlignment);
|
||||
Assert.Equal (new Rect (1, 1, 25, 1), checkBox.Frame);
|
||||
Assert.Equal (new Size (25, 1), checkBox.TextFormatter.Size);
|
||||
Assert.Equal ("Check this out 你", checkBox.Text);
|
||||
Assert.Equal ("╴ Check this out 你", checkBox.TextFormatter.Text);
|
||||
Assert.False (checkBox.AutoSize);
|
||||
|
||||
var expected = @"
|
||||
var expected = @$"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ ╴ Check this out 你 │
|
||||
│ {CM.Glyphs.UnChecked} Check this out 你 │
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
@@ -304,10 +261,10 @@ namespace Terminal.Gui.ViewsTests {
|
||||
|
||||
checkBox.Checked = true;
|
||||
Application.Refresh ();
|
||||
expected = @"
|
||||
expected = @$"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ √ Check this out 你 │
|
||||
│ {CM.Glyphs.Checked} Check this out 你 │
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
@@ -349,21 +306,15 @@ namespace Terminal.Gui.ViewsTests {
|
||||
Assert.Equal (TextAlignment.Justified, checkBox1.TextAlignment);
|
||||
Assert.Equal (new Rect (1, 1, 25, 1), checkBox1.Frame);
|
||||
Assert.Equal (new Size (25, 1), checkBox1.TextFormatter.Size);
|
||||
Assert.Equal ("Check first out 你", checkBox1.Text);
|
||||
Assert.Equal ("╴ Check first out 你", checkBox1.TextFormatter.Text);
|
||||
Assert.False (checkBox1.AutoSize);
|
||||
Assert.Equal (TextAlignment.Justified, checkBox2.TextAlignment);
|
||||
Assert.Equal (new Rect (1, 2, 25, 1), checkBox2.Frame);
|
||||
Assert.Equal (new Size (25, 1), checkBox2.TextFormatter.Size);
|
||||
Assert.Equal ("Check second out 你", checkBox2.Text);
|
||||
Assert.Equal ("╴ Check second out 你", checkBox2.TextFormatter.Text);
|
||||
Assert.False (checkBox2.AutoSize);
|
||||
|
||||
var expected = @"
|
||||
var expected = @$"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ ╴ Check first out 你 │
|
||||
│ ╴ Check second out 你 │
|
||||
│ {CM.Glyphs.UnChecked} Check first out 你 │
|
||||
│ {CM.Glyphs.UnChecked} Check second out 你 │
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
@@ -378,11 +329,11 @@ namespace Terminal.Gui.ViewsTests {
|
||||
Assert.Equal (new Rect (1, 2, 25, 1), checkBox2.Frame);
|
||||
//Assert.Equal (new Size (25, 1), checkBox2.TextFormatter.Size);
|
||||
Application.Refresh ();
|
||||
expected = @"
|
||||
expected = @$"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ √ Check first out 你 │
|
||||
│ √ Check second out 你 │
|
||||
│ {CM.Glyphs.Checked} Check first out 你 │
|
||||
│ {CM.Glyphs.Checked} Check second out 你 │
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
@@ -416,14 +367,12 @@ namespace Terminal.Gui.ViewsTests {
|
||||
Assert.Equal (TextAlignment.Right, checkBox.TextAlignment);
|
||||
Assert.Equal (new Rect (1, 1, 25, 1), checkBox.Frame);
|
||||
Assert.Equal (new Size (25, 1), checkBox.TextFormatter.Size);
|
||||
Assert.Equal ("Check this out 你", checkBox.Text);
|
||||
Assert.Equal ("Check this out 你 ╴", checkBox.TextFormatter.Text);
|
||||
Assert.False (checkBox.AutoSize);
|
||||
|
||||
var expected = @"
|
||||
var expected = @$"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ Check this out 你 ╴ │
|
||||
│ Check this out 你 {CM.Glyphs.UnChecked} │
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
@@ -433,10 +382,10 @@ namespace Terminal.Gui.ViewsTests {
|
||||
|
||||
checkBox.Checked = true;
|
||||
Application.Refresh ();
|
||||
expected = @"
|
||||
expected = @$"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ Check this out 你 √ │
|
||||
│ Check this out 你 {CM.Glyphs.Checked} │
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
@@ -466,10 +415,10 @@ namespace Terminal.Gui.ViewsTests {
|
||||
|
||||
Application.Begin (Application.Top);
|
||||
((FakeDriver)Application.Driver).SetBufferSize (30, 5);
|
||||
var expected = @"
|
||||
var expected = @$"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ ╴ Check this out 你│
|
||||
│ {CM.Glyphs.UnChecked} Check this out 你│
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
@@ -480,10 +429,10 @@ namespace Terminal.Gui.ViewsTests {
|
||||
checkBox.Text = "Check this out 你 changed";
|
||||
Assert.True (checkBox.AutoSize);
|
||||
Application.Refresh ();
|
||||
expected = @"
|
||||
expected = @$"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ ╴ Check this out 你 changed│
|
||||
│ {CM.Glyphs.UnChecked} Check this out 你 changed│
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
@@ -512,10 +461,10 @@ namespace Terminal.Gui.ViewsTests {
|
||||
|
||||
Application.Begin (Application.Top);
|
||||
((FakeDriver)Application.Driver).SetBufferSize (30, 5);
|
||||
var expected = @"
|
||||
var expected = @$"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ ╴ Check this out 你│
|
||||
│ {CM.Glyphs.UnChecked} Check this out 你│
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
@@ -526,10 +475,10 @@ namespace Terminal.Gui.ViewsTests {
|
||||
checkBox.Text = "Check this out 你 changed";
|
||||
Assert.True (checkBox.AutoSize);
|
||||
Application.Refresh ();
|
||||
expected = @"
|
||||
expected = @$"
|
||||
┌┤Test Demo 你├──────────────┐
|
||||
│ │
|
||||
│ ╴ Check this out 你 changed│
|
||||
│ {CM.Glyphs.UnChecked} Check this out 你 changed│
|
||||
│ │
|
||||
└────────────────────────────┘
|
||||
";
|
||||
@@ -555,8 +504,8 @@ namespace Terminal.Gui.ViewsTests {
|
||||
Assert.True (checkBox.ProcessKey (new KeyEvent (Key.Space, new KeyModifiers ())));
|
||||
Assert.Null (checkBox.Checked);
|
||||
Application.Refresh ();
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
⍰ Check this out 你", output);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
||||
{CM.Glyphs.NullChecked} Check this out 你", output);
|
||||
Assert.True (checkBox.MouseEvent (new MouseEvent () { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }));
|
||||
Assert.True (checkBox.Checked);
|
||||
Assert.True (checkBox.ProcessKey (new KeyEvent (Key.Space, new KeyModifiers ())));
|
||||
|
||||
Reference in New Issue
Block a user