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

Fixes #2616. Support combining sequences that don't normalize. #3877

Draft
wants to merge 24 commits into
base: v2_develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
dbbe3f7
Fixes #2616. Support combining sequences that don't normalize.
BDisp Dec 3, 2024
cc5ca9e
Trying to deal with non-bmp.
BDisp Dec 5, 2024
42db5c9
Fix for WindowsDriver.
BDisp Dec 5, 2024
9b2f8b7
Re-enables ReplacementChar because it's more adequate.
BDisp Dec 5, 2024
84b337f
Prevents throwing an exception if the token was canceled after wait.
BDisp Dec 5, 2024
264cccb
Now it's rendering surrogate pairs better, but still needs to figure …
BDisp Dec 5, 2024
7d0a8c2
Merge branch 'v2_develop' into v2_2616_combining-marks
BDisp Dec 5, 2024
a25af7a
Merge branch 'v2_develop' into v2_2616_combining-marks
BDisp Dec 5, 2024
d5c7625
Remove unnecessary fields.
BDisp Dec 5, 2024
f95b237
Merge branch 'v2_develop' into v2_2616_combining-marks
tig Dec 5, 2024
0d4759c
Improve the NetDriver and CursesDriver.
BDisp Dec 5, 2024
9c0a2db
Merge branch 'v2_develop' into v2_2616_combining-marks
BDisp Dec 7, 2024
79746e9
Ensure using a valid cell to add combining marks.
BDisp Dec 8, 2024
d9e0ef6
Fix NetDriver and CursesDriver combining marks.
BDisp Dec 8, 2024
edd0545
Trying to fix WindowsDriver combining marks.
BDisp Dec 8, 2024
93d75c8
Add family glyph.
BDisp Dec 8, 2024
963797c
Remove unused variable.
BDisp Dec 8, 2024
519b452
Fix UnicodeCategory.Format with width zero because six columns can on…
BDisp Dec 8, 2024
b870647
Merge branch 'v2_develop' into v2_2616_combining-marks
BDisp Dec 13, 2024
17d3b0d
Fix combining marks issue if IgnoreIsCombiningMark is false.
BDisp Dec 13, 2024
7279a34
Fix combining marks in the Application.ToString method.
BDisp Dec 13, 2024
476a41d
Fix unit test that was sometime causing failure.
BDisp Dec 13, 2024
36f492f
Fix test that also was causing failing.
BDisp Dec 13, 2024
a9375e4
Always set ConsoleDriver.RunningUnitTests = true if Application.Init …
BDisp Dec 13, 2024
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
24 changes: 19 additions & 5 deletions Terminal.Gui/Application/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ public static string ToString (IConsoleDriver? driver)
{
sb.Append (sp);
}
else if (contents [r, c].CombiningMarks is { Count: > 0 })
{
// AtlasEngine does not support NON-NORMALIZED combining marks in a way
// compatible with the driver architecture. Any CMs (except in the first col)
// are correctly combined with the base char, but are ALSO treated as 1 column
// width codepoints E.g. `echo "[e`u{0301}`u{0301}]"` will output `[é ]`.
//
// For now, we just ignore the list of CMs.
string combine = rune.ToString ();
string? normalized = null;

foreach (Rune combMark in contents [r, c].CombiningMarks)
{
combine += combMark;
normalized = combine.Normalize (NormalizationForm.FormC);
}

sb.Append (normalized);
}
else
{
sb.Append ((char)rune.Value);
Expand All @@ -76,11 +95,6 @@ public static string ToString (IConsoleDriver? driver)
{
c++;
}

// See Issue #2616
//foreach (var combMark in contents [r, c].CombiningMarks) {
// sb.Append ((char)combMark.Value);
//}
}

sb.AppendLine ();
Expand Down
38 changes: 11 additions & 27 deletions Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,35 +208,19 @@ public void AddRune (Rune rune)
// b) Ignoring any CMs that don't normalize
if (Col > 0)
{
if (Contents [Row, Col - 1].CombiningMarks.Count > 0)
for (int i = Col; i > 0; i--)
{
// Just add this mark to the list
Contents [Row, Col - 1].CombiningMarks.Add (rune);

// Ignore. Don't move to next column (let the driver figure out what to do).
}
else
{
// Attempt to normalize the cell to our left combined with this mark
string combined = Contents [Row, Col - 1].Rune + rune.ToString ();

// Normalize to Form C (Canonical Composition)
string normalized = combined.Normalize (NormalizationForm.FormC);

if (normalized.Length == 1)
if (!Contents [Row, i - 1].Rune.IsCombiningMark () && Contents [Row, i - 1].Rune != Rune.ReplacementChar)
{
// It normalized! We can just set the Cell to the left with the
// normalized codepoint
Contents [Row, Col - 1].Rune = (Rune)normalized [0];

// Ignore. Don't move to next column because we're already there
}
else
{
// It didn't normalize. Add it to the Cell to left's CM list
Contents [Row, Col - 1].CombiningMarks.Add (rune);

// Ignore. Don't move to next column (let the driver figure out what to do).
if (Contents [Row, i - 1].CombiningMarks is null)
{
Contents [Row, i - 1].CombiningMarks = [];
}
// Just add this mark to the list
Contents [Row, i - 1].CombiningMarks.Add (rune);
Debug.Assert (Contents [Row, i - 1].CombiningMarks.Count > 0);

break;
}
}

Expand Down
11 changes: 6 additions & 5 deletions Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,18 +319,19 @@
Rune rune = Contents [row, col].Rune;
output.Append (rune);

if (Contents [row, col].CombiningMarks.Count > 0)
if (Contents [row, col].CombiningMarks is { Count: > 0 })
{
// AtlasEngine does not support NON-NORMALIZED combining marks in a way
// compatible with the driver architecture. Any CMs (except in the first col)
// are correctly combined with the base char, but are ALSO treated as 1 column
// width codepoints E.g. `echo "[e`u{0301}`u{0301}]"` will output `[é ]`.
//
// For now, we just ignore the list of CMs.
//foreach (var combMark in Contents [row, col].CombiningMarks) {
// output.Append (combMark);
//}
// WriteToConsole (output, ref lastCol, row, ref outputWidth);
foreach (var combMark in Contents [row, col].CombiningMarks)
{
output.Append (combMark);
}
WriteToConsole (output, ref lastCol, row, ref outputWidth);
}
else if (rune.IsSurrogatePair () && rune.GetColumns () < 2)
{
Expand Down Expand Up @@ -580,7 +581,7 @@

private Curses.Window? _window;
private UnixMainLoop? _mainLoopDriver;
private object _processInputToken;

Check warning on line 584 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_release

Non-nullable field '_processInputToken' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 584 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (ubuntu-latest)

Non-nullable field '_processInputToken' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

public override MainLoop Init ()
{
Expand Down Expand Up @@ -725,7 +726,7 @@

while (wch2 == Curses.KeyMouse)
{
Key kea = null;

Check warning on line 729 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_release

Converting null literal or possible null value to non-nullable type.

Check warning on line 729 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (ubuntu-latest)

Converting null literal or possible null value to non-nullable type.

ConsoleKeyInfo [] cki =
{
Expand All @@ -734,7 +735,7 @@
new ('<', 0, false, false, false)
};
code = 0;
HandleEscSeqResponse (ref code, ref k, ref wch2, ref kea, ref cki);

Check warning on line 738 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_release

Possible null reference assignment.

Check warning on line 738 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (ubuntu-latest)

Possible null reference assignment.
}

return;
Expand Down Expand Up @@ -791,7 +792,7 @@
k = KeyCode.AltMask | MapCursesKey (wch);
}

Key key = null;

Check warning on line 795 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_release

Converting null literal or possible null value to non-nullable type.

Check warning on line 795 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (ubuntu-latest)

Converting null literal or possible null value to non-nullable type.

if (code == 0)
{
Expand Down Expand Up @@ -821,7 +822,7 @@
[
new ((char)KeyCode.Esc, 0, false, false, false), new ((char)wch2, 0, false, false, false)
];
HandleEscSeqResponse (ref code, ref k, ref wch2, ref key, ref cki);

Check warning on line 825 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_release

Possible null reference assignment.

Check warning on line 825 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (ubuntu-latest)

Possible null reference assignment.

return;
}
Expand Down Expand Up @@ -952,7 +953,7 @@
EscSeqUtils.DecodeEscSeq (
ref consoleKeyInfo,
ref ck,
cki,

Check warning on line 956 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_release

Possible null reference argument for parameter 'cki' in 'void EscSeqUtils.DecodeEscSeq(ref ConsoleKeyInfo newConsoleKeyInfo, ref ConsoleKey key, ConsoleKeyInfo[] cki, ref ConsoleModifiers mod, out string c1Control, out string code, out string[] values, out string terminator, out bool isMouse, out List<MouseFlags> buttonState, out Point pos, out bool isResponse, Action<MouseFlags, Point>? continuousButtonPressedHandler)'.

Check warning on line 956 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (ubuntu-latest)

Possible null reference argument for parameter 'cki' in 'void EscSeqUtils.DecodeEscSeq(ref ConsoleKeyInfo newConsoleKeyInfo, ref ConsoleKey key, ConsoleKeyInfo[] cki, ref ConsoleModifiers mod, out string c1Control, out string code, out string[] values, out string terminator, out bool isMouse, out List<MouseFlags> buttonState, out Point pos, out bool isResponse, Action<MouseFlags, Point>? continuousButtonPressedHandler)'.
ref mod,
out _,
out _,
Expand All @@ -972,7 +973,7 @@
OnMouseEvent (new () { Flags = mf, Position = pos });
}

cki = null;

Check warning on line 976 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_release

Cannot convert null literal to non-nullable reference type.

Check warning on line 976 in Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (ubuntu-latest)

Cannot convert null literal to non-nullable reference type.

if (wch2 == 27)
{
Expand Down
11 changes: 6 additions & 5 deletions Terminal.Gui/ConsoleDrivers/NetDriver/NetDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,19 @@ public override bool UpdateScreen ()
Rune rune = Contents [row, col].Rune;
output.Append (rune);

if (Contents [row, col].CombiningMarks.Count > 0)
if (Contents [row, col].CombiningMarks is { Count: > 0 })
{
// AtlasEngine does not support NON-NORMALIZED combining marks in a way
// compatible with the driver architecture. Any CMs (except in the first col)
// are correctly combined with the base char, but are ALSO treated as 1 column
// width codepoints E.g. `echo "[e`u{0301}`u{0301}]"` will output `[é ]`.
//
// For now, we just ignore the list of CMs.
//foreach (var combMark in Contents [row, col].CombiningMarks) {
// output.Append (combMark);
//}
// WriteToConsole (output, ref lastCol, row, ref outputWidth);
foreach (var combMark in Contents [row, col].CombiningMarks)
{
output.Append (combMark);
}
WriteToConsole (output, ref lastCol, row, ref outputWidth);
}
else if (rune.IsSurrogatePair () && rune.GetColumns () < 2)
{
Expand Down
5 changes: 5 additions & 0 deletions Terminal.Gui/ConsoleDrivers/NetDriver/NetMainLoop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ private void NetInputHandler ()
_waitForProbe.Reset ();
}

if (_inputHandlerTokenSource.IsCancellationRequested)
{
return;
}

ProcessInputQueue ();
}
catch (OperationCanceledException)
Expand Down
9 changes: 9 additions & 0 deletions Terminal.Gui/ConsoleDrivers/WindowsDriver/WindowsConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ public bool WriteToConsole (Size size, ExtendedCharInfo [] charInfoBuffer, Coord
{
_stringBuilder.Append (info.Char);
}

if (info.CombiningMarks is { })
{
foreach (var combMark in info.CombiningMarks)
{
_stringBuilder.Append (combMark);
}
}
}
else
{
Expand Down Expand Up @@ -785,6 +793,7 @@ public struct ExtendedCharInfo
public char Char { get; set; }
public Attribute Attribute { get; set; }
public bool Empty { get; set; } // TODO: Temp hack until virtual terminal sequences
internal List<char>? CombiningMarks;

public ExtendedCharInfo (char character, Attribute attribute)
{
Expand Down
32 changes: 30 additions & 2 deletions Terminal.Gui/ConsoleDrivers/WindowsDriver/WindowsDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
private Point _pointMove;
private bool _processButtonClick;

public WindowsDriver ()

Check warning on line 43 in Terminal.Gui/ConsoleDrivers/WindowsDriver/WindowsDriver.cs

View workflow job for this annotation

GitHub Actions / build_release

Non-nullable field '_outputBuffer' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 43 in Terminal.Gui/ConsoleDrivers/WindowsDriver/WindowsDriver.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (ubuntu-latest)

Non-nullable field '_outputBuffer' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 43 in Terminal.Gui/ConsoleDrivers/WindowsDriver/WindowsDriver.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (macos-latest)

Non-nullable field '_outputBuffer' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
Expand Down Expand Up @@ -356,22 +356,50 @@

_outputBuffer [position].Empty = false;

if (Contents [row, col].CombiningMarks is { Count: > 0 })
{
_outputBuffer [position].CombiningMarks = [];

foreach (var combMark in Contents [row, col].CombiningMarks)
{
_outputBuffer [position].CombiningMarks!.Add ((char)combMark.Value);
}
}
else
{
_outputBuffer [position].CombiningMarks = null;
}

if (Contents [row, col].Rune.IsBmp)
{
_outputBuffer [position].Char = (char)Contents [row, col].Rune.Value;
}
else
{
//_outputBuffer [position].Empty = true;
_outputBuffer [position].Char = (char)Rune.ReplacementChar.Value;
//_outputBuffer [position].Char = (char)Rune.ReplacementChar.Value;
var rune = Contents [row, col].Rune;
char [] surrogatePair = rune.ToString ().ToCharArray ();
Debug.Assert (surrogatePair.Length == 2);
_outputBuffer [position].Char = surrogatePair [0];

if (_outputBuffer [position].CombiningMarks == null)
{
_outputBuffer [position].CombiningMarks = [];
_outputBuffer [position].CombiningMarks!.Add (surrogatePair [1]);
}
else
{
_outputBuffer [position].CombiningMarks!.Insert (0, surrogatePair [1]);
}

if (Contents [row, col].Rune.GetColumns () > 1 && col + 1 < Cols)
{
// TODO: This is a hack to deal with non-BMP and wide characters.
col++;
position = row * Cols + col;
_outputBuffer [position].Empty = false;
_outputBuffer [position].Char = ' ';
_outputBuffer [position].Char = '\0';
}
}
}
Expand Down
12 changes: 3 additions & 9 deletions Terminal.Gui/Drawing/Cell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// Represents a single row/column in a Terminal.Gui rendering surface (e.g. <see cref="LineCanvas"/> and
/// <see cref="IConsoleDriver"/>).
/// </summary>
public record struct Cell (Attribute? Attribute = null, bool IsDirty = false, Rune Rune = default)
public record struct Cell (Attribute? Attribute = null, bool IsDirty = false, Rune Rune = default, List<Rune> CombiningMarks = null)
{
/// <summary>The attributes to use when drawing the Glyph.</summary>
public Attribute? Attribute { get; set; } = Attribute;
Expand All @@ -23,13 +23,11 @@ public Rune Rune
get => _rune;
set
{
CombiningMarks.Clear ();
CombiningMarks = null;
_rune = value;
}
}

private List<Rune> _combiningMarks;

/// <summary>
/// The combining marks for <see cref="Rune"/> that when combined makes this Cell a combining sequence. If
/// <see cref="CombiningMarks"/> empty, then <see cref="CombiningMarks"/> is ignored.
Expand All @@ -38,11 +36,7 @@ public Rune Rune
/// Only valid in the rare case where <see cref="Rune"/> is a combining sequence that could not be normalized to a
/// single Rune.
/// </remarks>
internal List<Rune> CombiningMarks
{
get => _combiningMarks ?? [];
private set => _combiningMarks = value ?? [];
}
internal List<Rune> CombiningMarks { get; set; } = CombiningMarks;

/// <inheritdoc/>
public override string ToString () { return $"[{Rune}, {Attribute}]"; }
Expand Down
3 changes: 2 additions & 1 deletion Terminal.Gui/Text/RuneExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public static bool IsCombiningMark (this Rune rune)

return Rune.GetUnicodeCategory (rune) == UnicodeCategory.NonSpacingMark
|| category == UnicodeCategory.SpacingCombiningMark
|| category == UnicodeCategory.EnclosingMark;
|| category == UnicodeCategory.EnclosingMark
|| category == UnicodeCategory.Format;
}

/// <summary>Reports whether a rune is a surrogate code point.</summary>
Expand Down
53 changes: 37 additions & 16 deletions UICatalog/Scenarios/CombiningMarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,43 @@ public override void Main ()
var top = new Toplevel ();

top.DrawComplete += (s, e) =>
{
top.Move (0, 0);
top.AddStr ("Terminal.Gui only supports combining marks that normalize. See Issue #2616.");
top.Move (0, 2);
top.AddStr ("\u0301\u0301\u0328<- \"\\u301\\u301\\u328]\" using AddStr.");
top.Move (0, 3);
top.AddStr ("[a\u0301\u0301\u0328]<- \"[a\\u301\\u301\\u328]\" using AddStr.");
top.Move (0, 4);
top.AddRune ('[');
top.AddRune ('a');
top.AddRune ('\u0301');
top.AddRune ('\u0301');
top.AddRune ('\u0328');
top.AddRune (']');
top.AddStr ("<- \"[a\\u301\\u301\\u328]\" using AddRune for each.");
};
{
var i = -1;
top.Move (0, ++i);
top.AddStr ("Terminal.Gui only supports combining marks that normalize. See Issue #2616.");
top.Move (0, ++i);
top.AddStr ("\u0301\u0301\u0328<- \"\\u0301\\u0301\\u0328]\" using AddStr.");
top.Move (0, ++i);
top.AddStr ("[a\u0301\u0301\u0328]<- \"[a\\u0301\\u0301\\u0328]\" using AddStr.");
top.Move (0, ++i);
top.AddRune ('[');
top.AddRune ('a');
top.AddRune ('\u0301');
top.AddRune ('\u0301');
top.AddRune ('\u0328');
top.AddRune (']');
top.AddStr ("<- \"[a\\u0301\\u0301\\u0328]\" using AddRune for each.");
top.Move (0, ++i + 1);
top.AddStr ("[e\u0301\u0301\u0328]<- \"[e\\u0301\\u0301\\u0328]\" using AddStr.");
top.Move (0, ++i);
top.AddStr ("[e\u0301\u0328\u0301]<- \"[e\\u0301\\u0328\\u0301]\" using AddStr.");
top.Move (0, ++i);
top.AddStr ("[e\u0328\u0301]<- \"[e\\u0328\\u0301]\" using AddStr.");
i++;
top.Move (0, ++i);
top.AddStr ("From now on we are using TextFormatter");
TextFormatter tf = new () { Text = "[e\u0301\u0301\u0328]<- \"[e\\u0301\\u0301\\u0328]\" using TextFormatter." };
tf.Draw (new (0, ++i, tf.Text.Length, 1), top.ColorScheme.Normal, top.ColorScheme.Normal);
tf.Text = "[e\u0328\u0301]<- \"[e\\u0328\\u0301]\" using TextFormatter.";
tf.Draw (new (0, ++i, tf.Text.Length, 1), top.ColorScheme.Normal, top.ColorScheme.Normal);
i++;
top.Move (0, ++i);
top.AddStr ("From now on we are using Surrogate pairs with combining diacritics");
top.Move (0, ++i);
top.AddStr ("[\ud835\udc4b\u0302]<- \"[\\ud835\\udc4b\\u0302]\" using AddStr.");
top.Move (0, ++i);
top.AddStr ("[\ud83e\uddd1\u200d\ud83e\uddd2]<- \"[\\ud83e\\uddd1\\u200d\\ud83e\\uddd2]\" using AddStr.");
};

Application.Run (top);
top.Dispose ();
Expand Down
8 changes: 6 additions & 2 deletions UnitTests/ConsoleDrivers/AddRuneTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,19 @@ public void AddRune_Accented_Letter_With_Three_Combining_Unicode_Chars ()

text = "\u0103\u0301";
driver.AddStr (text);
Assert.Equal (expected, driver.Contents [0, 0].Rune);
Assert.Single (driver.Contents [0, 0].CombiningMarks);
string combined = driver.Contents [0, 0].Rune + driver.Contents [0, 0].CombiningMarks [0].ToString ();
Assert.Equal (expected, (Rune)combined.Normalize (NormalizationForm.FormC) [0]);
Assert.Equal ((Rune)' ', driver.Contents [0, 1].Rune);

driver.ClearContents ();
driver.Move (0, 0);

text = "\u0061\u0306\u0301";
driver.AddStr (text);
Assert.Equal (expected, driver.Contents [0, 0].Rune);
Assert.Equal (2, driver.Contents [0, 0].CombiningMarks.Count);
combined = driver.Contents [0, 0].Rune + driver.Contents [0, 0].CombiningMarks [0].ToString () + driver.Contents [0, 0].CombiningMarks [1];
Assert.Equal (expected, (Rune)combined.Normalize (NormalizationForm.FormC) [0]);
Assert.Equal ((Rune)' ', driver.Contents [0, 1].Rune);

// var s = "a\u0301\u0300\u0306";
Expand Down
8 changes: 4 additions & 4 deletions UnitTests/ConsoleDrivers/ContentsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,31 @@ public void AddStr_With_Combining_Characters (Type driverType)
// a + ogonek + acute = <U+0061, U+0328, U+0301> ( ą́ )
var ogonek = new Rune (0x0328); // Combining ogonek (a small hook or comma shape)
combined = "a" + ogonek + acuteaccent;
expected = ("a" + ogonek).Normalize (NormalizationForm.FormC); // See Issue #2616
expected = ("á" + ogonek).Normalize (NormalizationForm.FormC); // See Issue #2616

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

// e + ogonek + acute = <U+0061, U+0328, U+0301> ( ę́́ )
combined = "e" + ogonek + acuteaccent;
expected = ("e" + ogonek).Normalize (NormalizationForm.FormC); // See Issue #2616
expected = ("é" + ogonek).Normalize (NormalizationForm.FormC); // See Issue #2616

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

// i + ogonek + acute = <U+0061, U+0328, U+0301> ( į́́́ )
combined = "i" + ogonek + acuteaccent;
expected = ("i" + ogonek).Normalize (NormalizationForm.FormC); // See Issue #2616
expected = ("í" + ogonek).Normalize (NormalizationForm.FormC); // See Issue #2616

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

// u + ogonek + acute = <U+0061, U+0328, U+0301> ( ų́́́́ )
combined = "u" + ogonek + acuteaccent;
expected = ("u" + ogonek).Normalize (NormalizationForm.FormC); // See Issue #2616
expected = ("ú" + ogonek).Normalize (NormalizationForm.FormC); // See Issue #2616

driver.Move (0, 0);
driver.AddStr (combined);
Expand Down
Loading
Loading