How to support horizontal overflow? #1006
-
Hi! I'm trying to render a window of syntax highlighted text and I'm running into a problem where text is squashed if the lines are too long to fit in the window. I would like to have the equivalent of #include <ftxui/dom/elements.hpp>
#include <ftxui/screen/screen.hpp>
#include <ftxui/screen/string.hpp>
int main()
{
using namespace ftxui;
auto content = hbox({
text("this "),
text("will "),
text("end up "),
text("being longer "),
text("than "),
text("the window "),
text("so "),
text("it should overflow "),
text("rather than squishing "),
text("the other lines "),
text("all text should be readable "),
text("up until the cutoff for the overflow"),
});
auto document = window(text("title"), content);
document = document | size(WIDTH, LESS_THAN, 80);
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document);
std::cout << screen.ToString();
return 0;
} Here's how it looks: I've been digging through the flex support, flexbox configs, issues, discussions, and didn't find anything related to Need the separate tokensI know that I can get what I want, in this simple example, if I just use one auto content = hbox({
text("this will end up being longer than the window so it should overflow "
"rather than squishing the other lines all of the text should be readable "
"up until the cutoff for the overflow"),
}); It looks like this: However, having a bunch of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Hi @jeaye, For this particular example, maybe you can wrap the content into a #include <ftxui/dom/elements.hpp>
#include <ftxui/screen/screen.hpp>
#include <ftxui/screen/string.hpp>
int main()
{
using namespace ftxui;
auto content = hbox({
text("this "),
text("will "),
text("end up "),
text("being longer "),
text("than "),
text("the window "),
text("so "),
text("it should overflow "),
text("rather than squishing "),
text("the other lines "),
text("all text should be readable "),
text("up until the cutoff for the overflow"),
});
content |= xframe;
auto document = window(text("title"), content);
document = document | size(WIDTH, LESS_THAN, 80);
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document);
std::cout << screen.ToString();
return 0;
} Output: ╭title───────────────────────────────────────────────────────────────────────────╮
│this will end up being longer than the window so it should overflow rather than │
╰────────────────────────────────────────────────────────────────────────────────╯ |
Beta Was this translation helpful? Give feedback.
Hi @jeaye,
For this particular example, maybe you can wrap the content into a
xframe
? This way, the elements won't be constrained on the width.