FTXUI
FTXUI copied to clipboard
color/bgcolor only works on text?
I've gone through everywhere the Color
enum is called as per here and it appears to only ever be used on a text
element. I'm trying to change the background of an Input in the below code (ideally to transparent, but that doesn't seem to be an option) but it the pipe'd in bgcolor doesn't appear to have any effect. I've copy-pasted the terminal_info section from the example to make sure that my terminal isn't missing anything and I get all "yes" answers on them
void init_editor() {
using namespace ftxui;
std::string view;
Component textarea = Input(&view);
// Taken straight from color_gallery.cpp
auto terminal_info =
vbox({
Terminal::ColorSupport() >= Terminal::Color::Palette16
? text(" 16 color palette support : Yes")
: text(" 16 color palette support : No"),
Terminal::ColorSupport() >= Terminal::Color::Palette256
? text("256 color palette support : Yes")
: text("256 color palette support : No"),
Terminal::ColorSupport() >= Terminal::Color::TrueColor
? text(" True color support : Yes")
: text(" True color support : No"),
}) |
border;
Component editor = Renderer([&] {
return vbox({
textarea->Render() | bgcolor(Color::Green),
separator(),
terminal_info,
}) | border;
});
ScreenInteractive screen = ScreenInteractive::Fullscreen();
screen.Loop(editor);
}
Running the above code gives me this output:
OS: Pop_OS 22.04 Terminal: Gnome-terminal (although I get the same result in both Alacritty and Wezterm) Tested in both c++17 and c++20
I found the input_options page, which doesn't appear to be listed on the enum page I linked. I don't know how to update doxygen to display this, but if you let me know, I'm happy to put in a PR.
bgcolor
apply a background color, and defer to the decorated element.See implementation.
It means the wrapped element always "wins" if it uses a bgcolor too. This is similar to CSS.
The Input component default implementation applies a | bgcolor(Color::GrayDark);
This explains what you see.
About the documentation:
- Enable the cmake option:
FTXUI_BUILD_DOCS
- Run
make doc
- The website appears under
./doc/doxygen/html/index.html
I think there is a page about InputOption
, but obviously it appears to be difficult to discover. If you have ideas, PRs are welcomes! Thanks for proposing it!