-
Notifications
You must be signed in to change notification settings - Fork 31
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
ConsoleTest in new Windows Terminal #30
Comments
SamplesChecked the sources... The process list sample tries to set buffer and window width, but only in debug mode with an attached debugger and ignores if it throws (iirc, one of these throw on Linux). The table is width-independent, so in theory it should work. Unless the new terminal lies about the buffer width. The console test sample uses lower level API, so I can see how it can fail to align at least some of the text. The rest relies on absolute sizes a lot, but uses high level API which reads current console buffer width before rendering, so that part should work correctly. Please let me know what exactly works incorrectly. I expect the first part of ConsoleTest to be messy, but the rest should work fine. CompatibilityLast time I checked, it worked fine on Linux. There were some incompatibilities in XAML, but I suspect most devs don't even use it, so they shouldn't see notice differences. The biggest problem you may face is performance. Linux terminals rely on ANSI codes, but there's no way to use the character sequences directly using .NET API, so the library relies on standard API for colors and such. The same thing with Windows, but for slightly different reasons. There's a platform-specific low level API that provides access to console buffer for faster rendering, but the library relies on standard .NET API instead which causes a lot of WinAPI calls underneath. So if you don't use colors and want to produce huge walls of text, you may want to render to a text buffer and write the huge string to console in one go. If you target a specific Linux terminal, you can use ANSI renderer too, which would allow using the same approach while preserving colors (the reason I say it's limited to a specific terminal is because you'll have to manually provide ANSI codes which aren't cross-platform or even cross-terminal). The library relies on standard .NET API, so has the same features and limitations regarding formatting. If there're major issues with formatting, you'd get the same by using standard .NET API, most likely (detection of ANSI codes in .NET is fragile in particular, last time I checked). If a platform happens to lie about console buffer width, you'll have the same problems with formatting and line wrapping when doing them manually. Technical detailsBy default, Windows console wraps text automatically when reaching the last position in line. (Or .NET enforces that option, I don't remember precisely.) So if you print 80 spaces and "\n" in a console window having 80 character width, you get two line feeds. This is why the library doesn't produce line wrap characters, even though technically it would make sense and avoid some of the issues. There's a WinAPI function which changes that behavior, so if you want, you can experiment with customizing line wrapping behavior. I don't see much reason for this though. ConclusionThe library completely relies on standard .NET API without any platform-specific calls, so in general it should be as cross-platform as it gets. I haven't tested the library on Linux heavily, but what I've tested worked fine. |
This video shows the output in the new Windows Terminal. |
Hm... Something is wrong specifically with the |
I always get unauthorized access error when running the ProcessManager. :( |
Replaced setting with getting: Console.WriteLine($"Console.BufferWidth = {Console.BufferWidth}");
Console.WriteLine($"Console.WindowWidth = {Console.WindowWidth}"); There's a problem with the Windows Terminal app. Sometimes it forgets to resize the buffer and .NET sees buffer and window width being 80 when they aren't. Opening a new tab and/or clearing with Considering .NET (and below that, WinAPI function If using this terminal is a priority, you can bypass this problem by formatting at
This is due to a relative path which the app doesn't make sure exists: |
Hello,
I was able to execute the ConsoleTest application to see how it performed with the new Windows Terminal. It appears you are setting the terminal width prior to rendering the text which is not being honored by the new Windows Terminal. Because of that the text rendering does not line up properly and word wraps. Do you expect this library to work well in the new Windows Terminal? Can any tweaks be done to make it compatible? Classic command console seems to be fine.
Also, do you expect the library to perform well in a dotnet core / linux environment?
My goal is to add this library to a console application I am building which will run on dotnet core and non-windows machines. I have a lot of tables and formatting in my output and would very much like to use a library like this.
Thank you.
The text was updated successfully, but these errors were encountered: