Skip to content

Commit

Permalink
Removed default ANSI escape code support on Windows 10's CMD.exe.
Browse files Browse the repository at this point in the history
Signed-off-by: David Tamar <[email protected]>
  • Loading branch information
davidvontamar committed Apr 30, 2019
1 parent fd21129 commit c6f8ae3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions ANSITerm/ANSITerm.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageVersion>0.1.2</PackageVersion>
<PackageVersion>0.1.3</PackageVersion>
<Title>ANSITerm</Title>
<Authors>David Tamar</Authors>
<Description>ANSI escape codes and true color formatting for .NET's console.</Description>
Expand All @@ -10,7 +10,7 @@
<RepositoryUrl>https://github.com/david-tamar/ANSITerm</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>console; ansi; terminal; escape-codes</PackageTags>
<PackageReleaseNotes>Enabled ANSI escape codes for the new Windows 10 Command Prompt.</PackageReleaseNotes>
<PackageReleaseNotes>Removed default ANSI escape code support on Windows 10 platforms due to inconsistent results in different IDEs.</PackageReleaseNotes>
<TargetFrameworks>netstandard2.0;netcoreapp2.2</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Tamar.ANSITerm</PackageId>
Expand Down
5 changes: 2 additions & 3 deletions ANSITerm/Console.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@ static Console()
}

// The Windows 10 Command Prompt supports ANSI escape codes with 24 bit colors.
if ((osVersion.Platform == PlatformID.Win32NT) && (osVersion.Version.Major >= 10))
/*if ((osVersion.Platform == PlatformID.Win32NT) && (osVersion.Version.Major >= 10))
{
TermSupportsEscapeCodes = true;
TermSupports256Colors = true;
TermSupportsTrueColor = true;
}
}*/

#if DEBUG

//TermSupportsEscapeCodes = true;
//TermSupports256Colors = true;
//TermSupportsTrueColor = true;
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ If escape codes are not supported either, then it will resort to .NET's basic sy
**True color support** is determined by the `truecolor` environment variable, which is supplied by the terminal emulator in question.

### Windows 10 Command Prompt
The new Windows 10 Command Prompt appears to be supporting properly both ANSI escape codes and 24-bit colors, so those features are enabled by default if the Windows 10 platform is detected regardless of which terminal emulator is being used (because this is a limitation of .NET Core).

In case this causes problems in your application, turn off ANSI escape codes altogether with `Console.EnableEscapeCodes = false;` for Windows 10's `Environment.OSVersion` which is `PlatformID.Win32NT` or just exclude `PlatformID.Unix` which appears to include Linux too under .NET Core 2.2.
I've tested CMD's escape code support on both Visual Studio and Rider and experienced different results thus ANSITerm won't support escape codes on the Windows CMD anymore.

## Example
#### Import ANSITerm.Console
Expand All @@ -46,7 +44,7 @@ using Console = Tamar.ANSITerm.Console;
```

#### Text formatting
Multiple formatting ANSI sequences can be applied simoultanously over the current state, and ANSI Console will run an SGR sequence update every time the formatting is being changed by color or by style (as long as the terminal is able to support escape codes).
Multiple formatting ANSI sequences can be applied simultaneously over the current state, and ANSI Console will run an SGR sequence update every time the formatting is being changed by color or by style (as long as the terminal is able to support escape codes).
```
Console.Italic = true;
Console.WriteLine("Italic text");
Expand Down

0 comments on commit c6f8ae3

Please sign in to comment.