Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially Addresses #2616. Support combining sequences that don't normalize #2932

Merged
merged 21 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ public void AddRune (Rune rune)
Contents [Row, Col - 1].Attribute = CurrentAttribute;
Contents [Row, Col - 1].IsDirty = true;

//Col--;
if (normalized.Length > 1) {
Contents [Row, Col].Runes = new List<Rune> { (Rune)normalized [1] }; ;
Contents [Row, Col].Attribute = CurrentAttribute;
Contents [Row, Col].IsDirty = true;
}
} else {
Contents [Row, Col].Attribute = CurrentAttribute;
Contents [Row, Col].IsDirty = true;
Expand Down
36 changes: 18 additions & 18 deletions UnitTests/ConsoleDrivers/ContentsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,40 @@
this.output = output;
}

[Theory]
[Theory, AutoInitShutdown]
tig marked this conversation as resolved.
Show resolved Hide resolved
[InlineData (typeof (FakeDriver))]
//[InlineData (typeof (NetDriver))]
//[InlineData (typeof (CursesDriver))]
//[InlineData (typeof (WindowsDriver))]
public void AddStr_With_Combining_Characters (Type driverType)

Check warning on line 25 in UnitTests/ConsoleDrivers/ContentsTests.cs

View workflow job for this annotation

GitHub Actions / build_and_test

Theory method 'AddStr_With_Combining_Characters' on test class 'ContentsTests' does not use parameter 'driverType'. Use the parameter, or remove the parameter and associated data. (https://xunit.net/xunit.analyzers/rules/xUnit1026)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
Application.Init (driver);
// driver.Init (null);
Application.Init ();
tig marked this conversation as resolved.
Show resolved Hide resolved

var acuteaccent = new System.Text.Rune (0x0301); // Combining acute accent (é)
var combined = "e" + acuteaccent;
var expected = "é";

driver.AddStr (combined);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);

#if false // Disabled Until #2616 is fixed
Application.Driver.AddStr (combined);
TestHelpers.AssertDriverContentsAre (expected, output);

// 3 char combine
// a + ogonek + acute = <U+0061, U+0328, U+0301> ( ǫ́ )
// a + ogonek + acute = <U+0061, U+0328, U+0301> ( ą́ )
var ogonek = new System.Text.Rune (0x0328); // Combining ogonek (a small hook or comma shape)
combined = "a" + ogonek + acuteaccent;
expected = "ǫ́";
expected = "ą́";

driver.Move (0, 0);
driver.AddStr (combined);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Application.Driver.Move (0, 0);
Application.Driver.AddStr (combined);
TestHelpers.AssertDriverContentsAre (expected, output);

#endif

// Shutdown must be called to safely clean up Application if Init has been called
Application.Shutdown ();
// o + ogonek + acute = <U+0061, U+0328, U+0301> ( ǫ́ )
ogonek = new System.Text.Rune (0x0328); // Combining ogonek (a small hook or comma shape)
combined = "o" + ogonek + acuteaccent;
expected = "ǫ́";

Application.Driver.Move (0, 0);
Application.Driver.AddStr (combined);
TestHelpers.AssertDriverContentsAre (expected, output);
}

[Theory]
Expand Down Expand Up @@ -91,7 +91,7 @@
}

// TODO: Add these unit tests

// AddRune moves correctly

// AddRune with wide characters are handled correctly
Expand Down
Loading