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

Reading/writing in the terminal #5

Open
JMLX42 opened this issue Dec 18, 2024 · 2 comments
Open

Reading/writing in the terminal #5

JMLX42 opened this issue Dec 18, 2024 · 2 comments

Comments

@JMLX42
Copy link
Contributor

JMLX42 commented Dec 18, 2024

Hello,

I need to be able to:

  1. write a string/a vector of chars to the terminal
  2. read the terminal

For 2., here is what I came up with:

fn read_terminal(&self) -> String {
        self.terminal_backend
            .last_content()
            .grid
            .iter_from(Point::new(Line(0), Column(0)))
            .map(|cell| cell.c)
            .collect::<String>()
    }

For 1., I think using TerminalBackend::process_command() is the right option, but BackendCommand is not exposed by lib.rs so this method cannot be called.

@JMLX42 JMLX42 changed the title Accessing stdin/stdout Reading/writing in the terminal Dec 18, 2024
@Harzu
Copy link
Owner

Harzu commented Dec 19, 2024

Hi! Thanks for interesting of my project. I've plan to convert this crate and my another my crate (iced_term) to one crate that providing all you need to create terminal emulator, but right now:

  • For 1 - I can create the method that provide current terminal emulator content. It will be fit for you?
  • For 2 - I can just accept your PR

@JMLX42
Copy link
Contributor Author

JMLX42 commented Dec 19, 2024

write a string/a vector of chars to the terminal

I have implemented my own "fake" Pty instead. And I give that Pty to the TerminalBackend. I'll finish, clean up and provide a PR.

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

2 participants