Description
It would be helpful to have an API for printing to a region inside of a collection of Views as if you were just printing to the console. The result of writing a line to this region would be similar to that of calling Console.Out.WriteLine
in a typical application.
An example of the rendering behavior I would expect from such a construct would be similar to that of apt
on Ubuntu. When invoked to install a package, the console starts printing output with a status bar at the bottom while the log grows upwards, e.g.,
oldest log message ^
older log message |
newer log message |- direction of logs
newest log message
[|||||||||||| 25% ] <-- stationary
I would expect the API for using this region to be a drop in replacement for printing to the console using the Console.{Out|Error}.WriteLine
APIs. If the view isn't inside an explicitly sized region, it should continue to grow in the appropriate direction, pushing the the bottom of the console buffer out to accommodate. If the view is inside a region with a set height/width, I would expect the region to stay the same size and the text to "fall off the edge" of the region in the appropriate direction. To achieve something like the apt
example above, I could imagine an API like:
var stackLayout = new StackLayout(/* configured without an explicit region */);
var scrollingView = new ScrollingView(new Region(x1,y1,x2,y2), ScrollDirection.Up);
var statusBar = StatusBarView.FromObservable<float>(progressObservable); // doesn't exist but would also be convenient
stackLayout.Add(scrollingView);
stackLayout.Add(statusBar);
//...
foreach (var dependency in packageToInstall.Dependencies)
{
// ...
scrollingView.WriteLine($"Installed {dependency.Name} to {installDir}");
}
I know the APIs above don't 100% map to the current APIs, but hopefully my example explains the desired API and expected results. Please let me know if there is anything I can clarify. I could imagine this API being useful inside TableView
s for putting log output to actions taken in another pane of the table.
Currently, to achieve a semblance of this behavior, I have been creating ContentView
s from Observable<string>
s and then updating the string
with new lines of text.