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

Adds ANSIDriver to replace WindowsDriver (use Console Virtual Terminal Sequences) #2940

Draft
wants to merge 59 commits into
base: v2_develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
0436019
Fixes #2616. Support combining sequences that don't normalize
BDisp Oct 24, 2023
f1a8308
Merge branch 'v2_develop' into v2_combining-normalize-fix_2616
tig Oct 25, 2023
475a89e
Decouples Application from ConsoleDriver in TestHelpers
tig Oct 25, 2023
860ceb1
Updates driver tests to match new arch
tig Oct 25, 2023
5e3edce
Start on making all driver tests test all drivers
tig Oct 25, 2023
3867df4
Merge pull request #161 from tig/BDisp-v2_combining-normalize-fix_2616
BDisp Oct 25, 2023
fc26a31
Improves handling if combining marks.
BDisp Oct 25, 2023
b491845
Fix unit tests fails.
BDisp Oct 25, 2023
f555243
Fix unit tests fails.
BDisp Oct 25, 2023
917a84f
Fix merge conflicts.
BDisp Oct 25, 2023
6f99b09
Handling combining mask.
BDisp Oct 25, 2023
cda0f01
Tying to fix this unit test that sometimes fail.
BDisp Oct 25, 2023
0293f6a
Add support for combining mask on NetDriver.
BDisp Oct 25, 2023
41cd364
Enable CombiningMarks as List<Rune>.
BDisp Oct 26, 2023
877190b
Prevents combining marks on invalid runes default and space.
BDisp Oct 26, 2023
abcc5f9
Merge branch 'v2_develop' into v2_combining-normalize-fix_2616
tig Oct 27, 2023
0e9b036
Formatting for CI tests.
BDisp Oct 27, 2023
621c68a
Fix non-normalized combining mark to add 1 to Col.
BDisp Oct 27, 2023
9a9e970
Reformatting for retest the CI.
BDisp Oct 27, 2023
6893af5
Forces non-normalized CMs to be ignored.
tig Oct 27, 2023
b14c652
Initial experiment
tig Oct 29, 2023
e1a963e
merge
tig Oct 29, 2023
6df914a
Created ANSiDriver. Updated UI Catalog command line handling
tig Oct 30, 2023
963a23f
Fixed ForceDriver logic
tig Oct 30, 2023
d6c3a81
Fixed ForceDriver logic
tig Oct 30, 2023
93a3c44
Updating P/Invoke
tig Oct 31, 2023
2eb81a3
Force16 colors WIP
tig Nov 1, 2023
d3c0e94
Fixed 16 colo mode
tig Nov 2, 2023
3c5d5df
Updated unit tests
tig Nov 2, 2023
59322fe
UI catalog tweak
tig Nov 2, 2023
c5477e2
Added chinese scenario from bdisp
tig Nov 2, 2023
3cf52e4
Merged but something is broke
tig Dec 16, 2023
0689a93
Fixed merge
tig Dec 16, 2023
8719b85
Disabled AnsiDriver unit tests for now.
tig Dec 16, 2023
9951a43
Merge branch 'v2_develop' into v2_fixes_2610_WT_VTS
tig Dec 27, 2023
c7a67d2
Merge v2_develop
tig Dec 27, 2023
df4f0a4
Code cleanup
tig Dec 27, 2023
c7e2914
Removed resharper settings from editorconfig
tig Jan 10, 2024
fa4337c
Merge branch 'v2_develop' of tig:gui-cs/Terminal.Gui into v2_develop
tig Jan 10, 2024
7ee17d8
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 13, 2024
15b36b5
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 13, 2024
e26a463
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 13, 2024
9bd93ca
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 13, 2024
4cdf647
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 14, 2024
19a95b3
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 14, 2024
18a99e7
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 14, 2024
6b06e92
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 14, 2024
8666c6f
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 14, 2024
08909e1
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 16, 2024
23b0914
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 16, 2024
81ad703
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 16, 2024
e9f98cf
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 16, 2024
1b1b442
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 16, 2024
a975b05
Merged v2_develop
tig Jan 16, 2024
60e5583
Finished merge
tig Jan 16, 2024
218a3c0
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 19, 2024
958e777
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 23, 2024
e985b5b
Merge branch 'v2_develop' of github.com:gui-cs/Terminal.Gui into v2_d…
tig Jan 24, 2024
0e93a49
Merged v2_develop
tig Jan 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1,399 changes: 1,399 additions & 0 deletions Terminal.Gui/ConsoleDrivers/ANSIDriver.cs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Terminal.Gui/NativeMethods.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Windows.Win32.System.Console
3 changes: 3 additions & 0 deletions Terminal.Gui/Terminal.Gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
<!-- Dependencies -->
<!-- =================================================================== -->
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.49-beta">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
<PackageReference Include="System.IO.Abstractions" Version="20.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.1" />
Expand Down
4 changes: 4 additions & 0 deletions UICatalog/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"commandName": "Project",
"commandLineArgs": "--driver NetDriver"
},
"UICatalog --driver ANSIDriver": {
"commandName": "Project",
"commandLineArgs": "--driver ANSIDriver"
},
"UICatalog --driver WindowsDriver": {
"commandName": "Project",
"commandLineArgs": "--driver WindowsDriver"
Expand Down
2 changes: 1 addition & 1 deletion UnitTests/ConsoleDrivers/AddRuneTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public AddRuneTests (ITestOutputHelper output)
[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
//[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void AddRune (Type driverType)
Expand Down
80 changes: 40 additions & 40 deletions UnitTests/ConsoleDrivers/ClipRegionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ namespace Terminal.Gui.DriverTests;
public class ClipRegionTests {
readonly ITestOutputHelper output;

public ClipRegionTests (ITestOutputHelper output)
{
ConsoleDriver.RunningUnitTests = true;
this.output = output;
}

[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
//[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void IsValidLocation (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
Application.Init (driver);
Application.Driver.Rows = 10;
Application.Driver.Cols = 10;
public ClipRegionTests (ITestOutputHelper output)
{
ConsoleDriver.RunningUnitTests = true;
this.output = output;
}
[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void IsValidLocation (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
Application.Init (driver);
Application.Driver.Rows = 10;
Application.Driver.Cols = 10;

// positive
Assert.True (driver.IsValidLocation (0, 0));
Expand Down Expand Up @@ -65,16 +65,16 @@ public void IsValidLocation (Type driverType)
Application.Shutdown ();
}

[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
//[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void Clip_Set_To_Empty_AllInvalid (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
Application.Init (driver);
[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void Clip_Set_To_Empty_AllInvalid (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
Application.Init (driver);

// Define a clip rectangle
driver.Clip = Rect.Empty;
Expand All @@ -94,18 +94,18 @@ public void Clip_Set_To_Empty_AllInvalid (Type driverType)
Application.Shutdown ();
}

[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
//[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void AddRune_Is_Clipped (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
Application.Init (driver);
Application.Driver.Rows = 25;
Application.Driver.Cols = 80;
[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void AddRune_Is_Clipped (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
Application.Init (driver);
Application.Driver.Rows = 25;
Application.Driver.Cols = 80;

driver.Move (0, 0);
driver.AddRune ('x');
Expand Down
102 changes: 51 additions & 51 deletions UnitTests/ConsoleDrivers/ConsoleDriverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,38 @@ public ConsoleDriverTests (ITestOutputHelper output)
this.output = output;
}

[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
//[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void Init_Inits (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
var ml = driver.Init ();
Assert.NotNull (ml);
Assert.NotNull (driver.Clipboard);
Console.ForegroundColor = ConsoleColor.Red;
Assert.Equal (ConsoleColor.Red, Console.ForegroundColor);
Console.BackgroundColor = ConsoleColor.Green;
Assert.Equal (ConsoleColor.Green, Console.BackgroundColor);
[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void Init_Inits (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
var ml = driver.Init ();
Assert.NotNull (ml);
Assert.NotNull (driver.Clipboard);
Console.ForegroundColor = ConsoleColor.Red;
Assert.Equal (ConsoleColor.Red, Console.ForegroundColor);
Console.BackgroundColor = ConsoleColor.Green;
Assert.Equal (ConsoleColor.Green, Console.BackgroundColor);

driver.End ();
}

[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
//[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void End_Cleans_Up (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
driver.Init ();
driver.End ();
}
[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void End_Cleans_Up (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
driver.Init ();
driver.End ();
}

[Theory]
[InlineData (typeof (FakeDriver))]
Expand Down Expand Up @@ -184,29 +184,29 @@ public void FakeDriver_MockKeyPresses (Type driverType)

// Application.Run ();

// // Shutdown must be called to safely clean up Application if Init has been called
// Application.Shutdown ();
//}

[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
//[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void TerminalResized_Simulation (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
driver?.Init ();
driver.Cols = 80;
driver.Rows = 25;

bool wasTerminalResized = false;
driver.SizeChanged += (s, e) => {
wasTerminalResized = true;
Assert.Equal (120, e.Size.Width);
Assert.Equal (40, e.Size.Height);
};
// // Shutdown must be called to safely clean up Application if Init has been called
// Application.Shutdown ();
//}
[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void TerminalResized_Simulation (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
driver?.Init ();
driver.Cols = 80;
driver.Rows = 25;
var wasTerminalResized = false;
driver.SizeChanged += (s, e) => {
wasTerminalResized = true;
Assert.Equal (120, e.Size.Width);
Assert.Equal (40, e.Size.Height);
};

Assert.Equal (80, driver.Cols);
Assert.Equal (25, driver.Rows);
Expand Down
32 changes: 16 additions & 16 deletions UnitTests/ConsoleDrivers/ConsoleScrolllingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ namespace Terminal.Gui.DriverTests;
public class ConsoleScrollingTests {
readonly ITestOutputHelper output;

public ConsoleScrollingTests (ITestOutputHelper output)
{
ConsoleDriver.RunningUnitTests = true;
this.output = output;
}

[Theory]
[InlineData (typeof (FakeDriver))]
//[InlineData (typeof (NetDriver))]
//[InlineData (typeof (ANSIDriver))]
//[InlineData (typeof (WindowsDriver))]
//[InlineData (typeof (CursesDriver))]
public void Left_And_Top_Is_Always_Zero (Type driverType)
{
var driver = (FakeDriver)Activator.CreateInstance (driverType);
Application.Init (driver);
public ConsoleScrollingTests (ITestOutputHelper output)
{
ConsoleDriver.RunningUnitTests = true;
this.output = output;
}

[Theory]
[InlineData (typeof (FakeDriver))]
//[InlineData (typeof (NetDriver))]
//[InlineData (typeof (ANSIDriver))]
//[InlineData (typeof (WindowsDriver))]
//[InlineData (typeof (CursesDriver))]
public void Left_And_Top_Is_Always_Zero (Type driverType)
{
var driver = (FakeDriver)Activator.CreateInstance (driverType);
Application.Init (driver);

Assert.Equal (0, Console.WindowLeft);
Assert.Equal (0, Console.WindowTop);
Expand Down
2 changes: 1 addition & 1 deletion UnitTests/ConsoleDrivers/ContentsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void AddStr_With_Combining_Characters (Type driverType)
[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
//[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void Move_Bad_Coordinates (Type driverType)
Expand Down
42 changes: 21 additions & 21 deletions UnitTests/ConsoleDrivers/DriverColorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class DriverColorTests {
[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
//[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (CursesDriver))]
public void SetColors_Changes_Colors (Type driverType)
{
Expand All @@ -37,32 +37,32 @@ public void SetColors_Changes_Colors (Type driverType)
}


[Theory]
[InlineData (typeof (FakeDriver), false)]
[InlineData (typeof (NetDriver), true)]
//[InlineData (typeof (ANSIDriver), true)]
[InlineData (typeof (WindowsDriver), true)]
[InlineData (typeof (CursesDriver), false)]
public void SupportsTrueColor_Defaults (Type driverType, bool expectedSetting)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
driver.Init ();
[Theory]
[InlineData (typeof (FakeDriver), false)]
[InlineData (typeof (NetDriver), true)]
[InlineData (typeof (ANSIDriver), true)]
[InlineData (typeof (WindowsDriver), true)]
[InlineData (typeof (CursesDriver), false)]
public void SupportsTrueColor_Defaults (Type driverType, bool expectedSetting)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
driver.Init ();

Assert.Equal (expectedSetting, driver.SupportsTrueColor);

driver.End ();
}

[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
//[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void Force16Colors_Sets (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
driver.Init ();
[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
[InlineData (typeof (ANSIDriver))]
[InlineData (typeof (WindowsDriver))]
[InlineData (typeof (CursesDriver))]
public void Force16Colors_Sets (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
driver.Init ();

driver.Force16Colors = true;
Assert.True (driver.Force16Colors);
Expand Down