Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Printing to stdout while replxx is active #33

Closed
Naios opened this issue Dec 30, 2018 · 6 comments
Closed

Question: Printing to stdout while replxx is active #33

Naios opened this issue Dec 30, 2018 · 6 comments

Comments

@Naios
Copy link
Contributor

Naios commented Dec 30, 2018

Hello,
I was experimenting with the replxx example andthe following question came up:
While asking replxx for some input using rx.input(prompt); is it possible to
print something to stdout meanwhile?

For instance when developing a server application which regularly prints something to stdout
could replxx be used as command line interface such that a console logger stays active
while replxx is still usable?

My own tests have shown that printing interferes with the repl:

  std::thread t([&] {
    while (true) {
      rx.print("some stuff\n");
      std::this_thread::sleep_for(std::chrono::seconds(2));
    }
  });
@AmokHuginnsson
Copy link
Owner

Hello.

Right now replxx does not support feature you are mentioning.
I am open to accept a pull request for the code adding this feature.
I imagine it would involve adding this functionality to Replxx::print() method,
but it requires adding some wake up mechanism to character reading functions
(io.cxx) that would allow to update screen after each Replxx::print() invocation.
So that the replxx prompt and replxx user input is always refreshed from the Replxx::input() thread.
It could be worthwhile to code Replxx::print() the same way, I mean, prints from other threads always
push messages to Replxx message queue (which would have to be implemented in proposed patch).

@doug-moen
Copy link
Contributor

I would use this feature if it were available.

@Naios
Copy link
Contributor Author

Naios commented Dec 31, 2018

@AmokHuginnsson Thank you for your answer, I would also look forward that anyone would propose a PR for this.

@api-Hypernova
Copy link

Great idea, would definitely use this in my application if available.

@AmokHuginnsson
Copy link
Owner

@doug-moen, @api-Hypernova, @yury, @Naios
Can you guys check if current master provides requested feature for you?

@AmokHuginnsson
Copy link
Owner

Requested feature is implemented on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants