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

I need to parse the corresponding character style from a piece of ansi string #166

Open
BppleMan opened this issue May 18, 2023 · 1 comment

Comments

@BppleMan
Copy link

I get the ansi string from another process and display it in my rich text box, so I need to parse the ansi control codes.
Now I use AnsiCodeIterator to get each element, is there a way to parse it to get what kind of style it is?

fn main() {
    let ansi_str = style("Hello world!").force_styling(true).red().on_blue().bold().to_string();
    println!("{:?}", ansi_str);
    AnsiCodeIterator::new(&ansi_str).for_each(|ansi_code| {
        println!("{:?}", ansi_code.0);
        // how to convert ansi code to style?
        // such as let style = Style::from_ansi_code(ansi_code.0);
        // but this method is not implemented
    });
}
@BppleMan
Copy link
Author

I create pr #167

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

1 participant