Skip to content

How to output stdout into a box? #273

Answered by ArthurSonzogni
mscofield0 asked this question in Q&A
Discussion options

You must be logged in to vote

FTXUI reads from stdin, and write to stdout. So, if you write to stdout directly it would break the interface.

So I recommand not writting to stdout directly, but create your special set of function to write elsewhere.

(Note: One can also try to reroute file descriptor. For instance I redirected stdin here)

Let's say the data is stored into:

std::string data;

Then, you can update the data:

void Write(const std::string& new_data) {
  data += new_data;
}

Then you need an DOM Element drawing it:

auto element = text(data);

I guess, you want a component producing the DOM element for every new frame. You can use:

auto component = Renderer([&data] {
  return text(data)
});

A text only support d…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@nullbyto
Comment options

Answer selected by mscofield0
Comment options

You must be logged in to vote
1 reply
@nullbyto
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants