TomaszRewak / C-sharp-console-gui-framework

A GUI framework for C# console applications
MIT License
1.08k stars 45 forks source link

Sadly not working under Linux / JetBrains Rider #3

Closed bpiepiora closed 4 years ago

bpiepiora commented 4 years ago

It just puts out an unhandled exception:

Unhandled exception. System.PlatformNotSupportedException: Operation is not supported on this platform.GUI.Example/bin/Debug/netcoreapp3.0/ConsoleGUI.Example.dll at System.ConsolePal.SetWindowPosition(Int32 left, Int32 top) at System.Console.SetWindowPosition(Int32 left, Int32 top) at ConsoleGUI.ConsoleManager.ResizeBuffer(Int32 width, Int32 height) in /home/benjamin.piepiora/Downloads/C-sharp-console-gui-framework-master/ConsoleGUI/ConsoleManager.cs:line 139 at ConsoleGUI.ConsoleManager.Setup() in /home/benjamin.piepiora/Downloads/C-sharp-console-gui-framework-master/ConsoleGUI/ConsoleManager.cs:line 124 at ConsoleGUI.Example.Program.Main() in /home/benjamin.piepiora/Downloads/C-sharp-console-gui-framework-master/ConsoleGUI.Example/Program.cs:line 266

Is it possible to work around that?

TomaszRewak commented 4 years ago

Thanks for testing and the stacktrace! I didn't realize that the SetWindowPosition method was platform specific. I've just pushed a change that adds exception handling around those calls. Could you please try it again? Thanks!

bpiepiora commented 4 years ago

Bildschirmfoto von 2019-10-30 09-53-15

It works now! Very nice! Is it possible to detect size changes of the console and update the content accordingly?

jzabroski commented 4 years ago

@bpiepiora It seems that handling console window size changes is not safe: https://stackoverflow.com/a/34208406 @jnm2 you're everywhere!

jnm2 commented 4 years ago

@jzabroski That's news to me! :D

TomaszRewak commented 4 years ago

@bpiepiora Thanks! @jzabroski Yeah, unfortunately that's the case. But actually thinking about it I could add a new method to the ConsoleManager that the user would have to call each "frame" (the same way it's currently implemented for keyboard input handling) that would simply check if the size of the window has changed as compared to the value from the previous frame. It wouldn't be 100% foolproof (because if the window size would change to a different value and back to the initial value during one frame it might break the layout), but it would still be better than nothing.

Cheers guys!