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

How to highlight text inside ftxui::text() or ftxui::paragraph() #876

Open
DanuulKa03 opened this issue Jun 4, 2024 · 1 comment
Open

Comments

@DanuulKa03
Copy link

I know that you can colorize the font like this

ftxui::text("TEXT.") | ftxui::color(ftxui::Color::Red) | ftxui::bgcolor(ftxui::Color::Yellow)

Let's say that I made a Renderer() of this text somewhere.

int main() {
    auto document = vbox({
        ftxui::text("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.")
    });

    auto screen = Screen::Create(Dimension::Full(), Dimension::Fit);
    Render(screen, document);
    screen.Print();

    return 0;
}

If I want to highlight the name "Ipsum is simply", is this the only way I can do it?

int main() {
    auto document = vbox({
        ftxui::text("Lorem"), ftxui::text("Ipsum is simply") | ftxui::color(ftxui::Color::Red) | ftxui::bgcolor(ftxui::Color::Yellow), ftxui::text("dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.") | ftxui::color(ftxui::Color::Red) | ftxui::bgcolor(ftxui::Color::Yellow)
    });

    auto screen = Screen::Create(Dimension::Full(), Dimension::Fit);
    Render(screen, document);
    screen.Print();

    return 0;
}

This method doesn't work for me, so I would like to know if there is a way to highlight already pasted text?

@ArthurSonzogni
Copy link
Owner

Unfortunately, there isn't any builtin tools for this.

You can write your own Element and directly assign colors to cells, but I understand this would be a lot of work.

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