Fixes #92. Remove dependency on ustring. (#2620)

* Remove NStack and replace ustring to string.

* Add unit test and improving some code.

* Adjust code and fix all unit tests errors.

* Add XML Document and move the Rune folder into the Text folder.

* Improve unit tests with byte array on DecodeRune and DecodeLastRune.

* Fix unit test.

* 😂Code review

* Reduce unit tests code.

* Change StringExtensions.Make to StringExtensions.ToString and added some more unit tests.

* Fix merge errors.

* Remove GetTextWidth and calls replaced with StringExtensions.GetColumns.

* Hack to use UseSystemConsole passed in the command line arguments.

* Revert "Hack to use UseSystemConsole passed in the command line arguments."

This reverts commit b74d11c786.

* Remove Application.UseSystemConsole from the config file.

* Fix errors related by removing UseSystemConsole from the config file.

* Fixes #2633. DecodeEscSeq throw an exception if cki is null.

* Fix an exception if SelectedItem is -1.

* Set SelectedItem to 0 and remove unnecessary ToString.

* Using a unique ToString method for Rune and other for byte.

* Fix a bug where a wider rune is added with only a width of 1.

* Force the SelectedGlyph is the one that was typed after jumpList is executed.

* Added more InlineData to RuneTests.

* Reducing significantly the code by using Theory attribute in the TextFormatterTests.

* Override PositionCursor to handle the CharMap cursor position.

* Fix merge errors.

* Minor tweaks to API docs

---------

Co-authored-by: Tig Kindel <tig@users.noreply.github.com>
This commit is contained in:
BDisp
2023-05-20 18:35:32 +01:00
committed by GitHub
parent 474a1968fa
commit 713b2c4725
155 changed files with 4173 additions and 5526 deletions

View File

@@ -11,7 +11,7 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using NStack;
using System.Text;
namespace Terminal.Gui {
internal class NetWinVTConsole {
@@ -195,12 +195,13 @@ namespace Terminal.Gui {
isEscSeq = false;
break;
}
} else if (consoleKeyInfo.KeyChar == (char)Key.Esc && isEscSeq) {
} else if (consoleKeyInfo.KeyChar == (char)Key.Esc && isEscSeq && cki != null) {
DecodeEscSeq (ref newConsoleKeyInfo, ref key, cki, ref mod);
cki = null;
break;
} else {
GetConsoleInputType (consoleKeyInfo);
isEscSeq = false;
break;
}
}
@@ -668,14 +669,14 @@ namespace Terminal.Gui {
if (contents.Length != Rows * Cols * 3) {
return;
}
rune = MakePrintable (rune);
var runeWidth = Rune.ColumnWidth (rune);
rune = rune.MakePrintable ();
var runeWidth = rune.GetColumns ();
var validClip = IsValidContent (ccol, crow, Clip);
if (validClip) {
if (runeWidth == 0 && ccol > 0) {
var r = contents [crow, ccol - 1, 0];
var s = new string (new char [] { (char)r, (char)rune });
var s = new string (new char [] { (char)r, (char)rune.Value });
string sn;
if (!s.IsNormalized ()) {
sn = s.Normalize ();
@@ -689,12 +690,12 @@ namespace Terminal.Gui {
} else {
if (runeWidth < 2 && ccol > 0
&& Rune.ColumnWidth ((char)contents [crow, ccol - 1, 0]) > 1) {
&& ((Rune)(char)contents [crow, ccol - 1, 0]).GetColumns () > 1) {
contents [crow, ccol - 1, 0] = (int)(uint)' ';
} else if (runeWidth < 2 && ccol <= Clip.Right - 1
&& Rune.ColumnWidth ((char)contents [crow, ccol, 0]) > 1) {
&& ((Rune)(char)contents [crow, ccol, 0]).GetColumns () > 1) {
contents [crow, ccol + 1, 0] = (int)(uint)' ';
contents [crow, ccol + 1, 2] = 1;
@@ -703,7 +704,7 @@ namespace Terminal.Gui {
if (runeWidth > 1 && ccol == Clip.Right - 1) {
contents [crow, ccol, 0] = (int)(uint)' ';
} else {
contents [crow, ccol, 0] = (int)(uint)rune;
contents [crow, ccol, 0] = (int)(uint)rune.Value;
}
contents [crow, ccol, 1] = CurrentAttribute;
contents [crow, ccol, 2] = 1;
@@ -729,9 +730,9 @@ namespace Terminal.Gui {
}
}
public override void AddStr (ustring str)
public override void AddStr (string str)
{
foreach (var rune in str)
foreach (var rune in str.EnumerateRunes ())
AddRune (rune);
}
@@ -950,12 +951,12 @@ namespace Terminal.Gui {
output.Append (WriteAttributes (attr));
}
outputWidth++;
var rune = contents [row, col, 0];
var rune = (Rune)contents [row, col, 0];
char [] spair;
if (Rune.DecodeSurrogatePair ((uint)rune, out spair)) {
if (rune.DecodeSurrogatePair (out spair)) {
output.Append (spair);
} else {
output.Append ((char)rune);
output.Append ((char)rune.Value);
}
contents [row, col, 2] = 0;
}