runWith<T> static method
Runs body with terminal installed as current.
The previous context is restored when body returns or throws. If the
context was uninitialized before this call, it is restored to that same
uninitialized state.
Implementation
static T runWith<T>(Terminal terminal, T Function() body) {
final previous = capture();
current = terminal;
try {
return body();
} finally {
previous.restore();
}
}