Closed askovpen closed 4 years ago
The way in which the ConsoleManager.CompatibilityMode = true
works is that it takes the rgb color of the character produced by a control and transforms it to the "nearest" ConsoleColor
enum value using this formula:
int index = (color.Red > 128 | color.Green > 128 | color.Blue > 128) ? 8 : 0;
index |= (color.Red > 64) ? 4 : 0;
index |= (color.Green > 64) ? 2 : 0;
index |= (color.Blue > 64) ? 1 : 0;
return (ConsoleColor)index;
So to get a specific color from that list you will have to revert that formula.
But thinking about this I will probably add a new constructor to the Color
that accepts a ConsoleColor
enum value.
Fixed in 9b53cd669603555eb57dc8cdd6a49a8c3ff0c90d
Now you can use values of the ConsoleColor
enum directly whenever a values of the Color
struct is required.
ConsoleColor in linux don't have highlight colors:
I actually didn't know that there were issues like this, thanks for sharing ;) After a short investigation it seems that it is considered to be a bug in the dotnet core. Related issue: https://github.com/dotnet/corefx/issues/23381 But is also seems that they are not planning on fixing that. I wanted to avoid adding dependencies on external projects but it seems that it might be the only way to resolve that. What terminal are you using? The main thing I want to determine is if adding the support for 4-bit XTerm palette is even worth considering.
But the more I think about this, the more I like the idea of using the https://github.com/david-tamar/ansi-term. But I have to experiment with it a little bit. The README says that the W10 terminal support is in the TODO list, so I assume it's currently not fully supported. And for me it's a must-have.
TERM=linux (ssh connection)
I was not familiar with ANSITerm. I mainly use Crayon. What is the advantage to ANSITerm, other than it has a cooler landing page?
On Mon, Dec 23, 2019 at 12:05 PM Alexander Skovpen notifications@github.com wrote:
maybe use forlinux like this https://github.com/xunit/xunit/blob/master/src/common/ConsoleHelper.cs?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/TomaszRewak/C-sharp-console-gui-framework/issues/18?email_source=notifications&email_token=AADNH7JDXRNNSQ23RSYSJTTQ2DVUFA5CNFSM4J6IZS52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHRQYQQ#issuecomment-568527938, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADNH7IHKKPG6BWUVCPDLADQ2DVUFANCNFSM4J6IZS5Q .
Christmas time is over, it's time for some changes :P
So I was playing with different approaches and the 3939d08ec53ebadac4898bee2633e88e01d83b2d is the solution I've came up with.
I've completely removed the CompatibilityMode
and the DontPrintTheLastCharacter
properties. Instead, I've introduced the IConsole
interface. It's a very simple way to override the default behavior of the console if the StandardConsole
is not sufficient. To make the process even simpler, the StandardConsole
declares all its methods as virtual
so one can inherit it and override only the void Write(Position, Character)
method.
With this change all the edge cases should be covered. Also, if someone really wants to do it, he can implement a file API and print the output there (though there is probably no point in doing that :D).
In your case all you have to do is to combine the code from the https://github.com/xunit/xunit/blob/master/src/common/ConsoleHelper.cs and the StandardConsole
. Take a look at the SimplifiedConsole
for reference.
If you think it's a good idea to include the support for 4-bit XTerm palette as a part of this library, I'm open to PRs (I will not implement it myself as I don't have a way to test it).
I will update the README and release a new package shortly.
Nice, it also allows for simple high level testing i presume
Indeed, one could create a dummy Console
which could be used for top-level testing.
But, well,
how to use color in linux from second column? btw, in windows Color.White from second column, in linux - from primary column. (
ConsoleManager.CompatibilityMode = true
)