Terminal.Gui
Terminal.Gui copied to clipboard
Externalize `TestHelpers.AssertDriverContentsAre` as `Application.ToString` - aka Render as text / Print Screen
Is your feature request related to a problem? Please describe. I am looking for a way to export the screen state as text (to send it to external devices like serial terminals, dot-matrix printers, etc..), kind of like what the old print-screen key would have done in old computers.
Describe the solution you'd like
A new method on the Application
object could be a solution, or ideally usable on any widget ? RenderAsText
or something like this ? Ideally the application would not have to be running on a real tty but would allow to directly render it as text (with a given terminal/page width/height)
Describe alternatives you've considered I tried to look at others libraries like table formatting libs for console apps but it's far from being as complete as needed for this kind of need unfortunately.
We have some unit tests that basically do what you are describing e.g.
https://github.com/migueldeicaza/gui.cs/blob/d8fc1d0e85e346f2633d4b814c88bff0a2fef147/UnitTests/GraphViewTests.cs#L823-L835
They spin up a FakeDriver
, add some Views and then call Redraw
and check the Contents
field.
The class is public as is its Contents
property. Although I think that was a recent change so might not be public in the current NuGet release package (if not you can still get contents
using reflection until it is released). You can look at AssertDriverContentsAre
to see how to interpret the array as chars and colors.
Ideally the application would not have to be running on a real tty
The FakeDriver isn't blocking and doesn't have to actually run which sounds ideal