Skip to content

Track exclusive usage of stdout/stderr, or have a singleton for them #7

@sourcefrog

Description

@sourcefrog

It only ever makes sense for one View to be drawing to stdout or stderr at any time. If there's more than one, they'll probably scramble the screen state.

At the moment the application is responsible for at most one View being active at any time.

We could, instead, for example, panic if more than one View is in use. Or, perhaps, one of them should take over responsibility, leaving the others suspended. Or even, perhaps, they should all be drawn at the same time? That does get complicated if they're using different options.

It's OK for any number of captured views to be in use, and indeed necessary for Nutmeg's own test suite.

However, this might be complicated if Views are used during a program's test suite. Because of the way Rust's test suite captures println! they won't actually conflict. I'm not sure if this is directly detectable.

If this is done and we have a clear picture which View is active, that enables providing a write() or write_stderr() that sends text through the progress bar if there is one, or otherwise directly to stdout or stderr. There could even be a nutmeg::println!() that coordinates with whichever bar. This also opens the door to built in tracing integration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions