Skip to content

Instantly share code, notes, and snippets.

@iglesias
Created December 18, 2023 15:05
Show Gist options
  • Save iglesias/1cc0c115aca8c8086751d392a28a8028 to your computer and use it in GitHub Desktop.
Save iglesias/1cc0c115aca8c8086751d392a28a8028 to your computer and use it in GitHub Desktop.
FTXUI
#include "ftxui/component/component.hpp" // for Renderer, CatchEvent, Horizontal, Menu, Tab
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include <ftxui/dom/elements.hpp> // for canvas, Element, separator, hbox, operator|, border
int main()
{
auto renderer_text = ftxui::Renderer([&] {
auto c = ftxui::Canvas(100, 100);
c.DrawText(0, 0, "A piece of text",
[](ftxui::Pixel& p) {
p.foreground_color = ftxui::Color::Blue;
p.underlined = true;
p.bold = true;
});
return canvas(std::move(c));
});
auto screen = ftxui::ScreenInteractive::FitComponent();
screen.Loop(renderer_text);
}
include = -IFTXUI/include
CXXFLAGS = -Wall -Wextra -pedantic -std=c++20 $(include)
LDFLAGS = -LFTXUI/build
LDLIBS = -lftxui-component -lftxui-dom -lftxui-screen
TARGET = learn_ftxui
all: $(TARGET)
$(TARGET): learn_ftxui.cpp
$(CXX) $(CXXFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
clean:
rm -f $(TARGET)
@iglesias
Copy link
Author

-> figure out automatic canvas updates to draw dynamics as in the htop, spinner, gauge examples shown at https://github.com/ArthurSonzogni/FTXUI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment