Open EliSchleifer opened 2 years ago
I need to improve the paragraph
.
In the meantime, you could render a vbox
of text
.
Elements Split(std::string the_text) {
Elements output;
std::stringstream ss(the_text);
std::string word;
while (std::getline(ss, word, ' \n'))
output.push_back(text(word));
return output;
}
Element nonWrappingParagraph(std::string the_text) {
Elements lines;
for(auto& line : Split(std::move(the_text))
lines.push_back(text(line));
return vbox(std::move(lines));
}
Nevertheless, you would lose text wrapping.
I have a similar issue with some pre-formatted text that includes both newlines and some ANSI color codes. The above workaround works for the newlines but not the colors. Would it be possible to create some sort of "verbatim" element that doesn't format the code?
I have a similar issue with some pre-formatted text that includes both newlines and some ANSI color codes. The above workaround works for the newlines but not the colors. Would it be possible to create some sort of "verbatim" element that doesn't format the code?
I doubt a lot of people have pre-formatted text. The 'verbatim' element sounds hard to do implement.
Out of curiosity, could you explain more your use case and post the text you want to render?
I can probably not add verbatim
, but I can probably provide alternatives.
I have a separate tool that generates a table where certain rows are highlighted based on their significance. The raw string literal ends up looking something like
"| \033[1;31mFOO\033[0m | \033[1;31mBAR\033[0m |\n"
for each highlighted row. I was hoping to just be able to spit raw table out into a window, but that seems like it won't work.
Also this can save time when you try to show an output of another programm ( colored output of ls i.e.), but still I'm doubt about adding a new element. One way to approach this is to make raw Pixel array from string, and pack it somehow. This is just some quick thoughts.
I see! Thanks!
What is this tool? If somehow, the other program can output something digestible so that you can get the raw data instead of the formatted one, you could display them using an ftxui:: Table
:
https://arthursonzogni.com/FTXUI/examples/?file=dom/table
https://github.com/ArthurSonzogni/FTXUI/blob/master/examples/dom/table.cpp
Trying to parse the formatted output from the other program seems difficult. FTXUI is a terminal client. Here to parse the output of the other program, I would have to implement the terminal server too.
It's some in-house tool. It's possible I might be able to reformat the output as JSON and parse it into a Table
. I'll give it a shot. Thanks!
I have found that removing the IsControl check in the Utf8ToGlyphs function allows displaying ANSI colors correctly. But it may introduce other issues
Looking to render a piece of ASCII Art in a box but the library seems to be stripping white space when using the paragraph element (understandable), or text component seems to be only single line.
Is there some formatting I am missing, or do I need to stack a bunch of text objects on top of each other to force compliance with the styling?