Tyrrrz/CliFx

Add console dimensions to `IConsole`

thegreatco opened this issue · 3 comments

Can we add some way of determining the height/width of the output for IConsole. Similar to Console.WindowHeight and Console.WindowWidth? I've got a console app that needs to know how wide the window is that it is writing to.

Since this is abstracted, maybe we can either return null or NotImplementedException for implementations that don't support it? I don't have particularly strong feelings either way, but null could make for a better user experience, IConsole.Width.GetValueOrDefault(80) is nicer than trying to catch an exception.

Ideally I think we'd also wan to add SupportedOSPlatform and UnsupportedOSPlatform attributes where appropriate.

Should be fine to add. Nullable property makes the most sense.

On the other hand, I think returning default instead of null makes more sense for consistency reasons, because we already have IConsole.CursorLeft/IConsole.CursorTop that are not nullable and also depend on the presence of a terminal window.

Thanks @Tyrrrz!