Multiline console update
I would like to use NConsole to deliver such command line experience like curl or wget are doing.
$ curl -O http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
28 3762k 28 1085k 0 0 72771 0 0:00:52 0:00:15 0:00:37 54267
In the example above only the last line can be updated. In my feature request I would like to be able to update all previously written lines to simulate multiple downloaded files at the same time.
Is this even possible with System.Console? Do we just need a new method on IConsoleHost, eg ReplaceLine(offset, message)? Can you create a PR?
Currently without abstraction I use quite often:
Console.SetCursorPosition(0, 5);
Console.WriteLine("...");
which produces the behaviour described by the request. One of the solution could be like you wrote, but I am open for any solution which looks nice and produces desired result.
Currently you can just use Console.SetCursorPosition directly (not via IConsoleHost). Isn't this an option?
There are two problems when adding this new method:
- We are breaking existing users because the interface has changed
- What to do if SetCursorPosition is not supported for a specific IConsoleHost? Throw an exception? Do we need an additional property to check this? e.g. CanSetCursorPosition on IConsoleHost?
Or create a new interface, IConsoleCursorPositionHost, that has a SetCursorPosition method.