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

Expose Editor in the API #5

Merged
merged 1 commit into from
May 18, 2024

Conversation

define-null
Copy link
Contributor

This commit makes it possible to use Editor directly. My main motivation was to provide the possibility to access ExternalPrinter. This is mainly
needed for scenarios where additional threads are spawned from the repl and start printing output. In case those threads do not use external printer the output is mixed with the input that the user might be writing. On the other hand, if external printer is used, the console is updates and if the use has written something already, this line remains intact.

Example of how this is used:

    let mut rl = ClapEditor::<ReplCommand>::new_with_prompt(">> ");
    let mut printer =
        rl.get_editor().create_external_printer().unwrap();

    let (tx, rx) = std::sync::mpsc::channel();
    thread::spawn(move|| {
        for received in rx {
            printer.print(received).unwrap()
        }
    });
   ...

@HKalbasi HKalbasi merged commit 27f0e03 into HKalbasi:main May 18, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants