Warning
This project is a work in progress and should not be considered production-ready.
A C++ TUI framework inspired by tkinter, easy to learn, fast to code, beginner friendly.
- Documentation: Click here!
- Source: Click here!
CroissanTUI is an easy-to-use C++ Text User Interface (TUI) framework for cross-platform applications, inspired by Python's tkinter. It's perfect for smaller projects.
- Keyword Arguments: instead of
data objectslikestruct ButtonConfigto configure widgets, CroissanTUI useskeyword argumentsinspired by Python's**kwargs. - Text Modifiers: different characters and words inside a
Labelcan be rendered with different colors without having to create separate widgets, usingTextStreams as a way to store text data.root.make_child<Label>( text << "Normal text | " << Color::RED << "Red Text | " << GraphicMod::ITALIC << "Italic red text |" << GraphicMod::RESETALL << "Normal text") // <- Argument evaluates to a TextStream - Live Updates via Lambdas:
TextStreamtokens can also bestd::function<std::string()>, letting aLabeldisplay live values by capturing a reference to an outside object — e.g.[&score]() { return std::to_string(score); }so the displayed value can change without recreating the widget.root.make_child<Label>( text << "Score: " << [&score]() { return std::to_string(score); }, align = End);
| Object | Source build | Precompiled Build | Usage |
|---|---|---|---|
| C++ Language | C++20 or newer | C++17 | Compilation |
| Python | 3.4.x or newer | N/A | Header Generation |
| libgrapheme | Vendored | N/A | Codepoint Iteration |
| utf8proc | Submodule | N/A | Char-Width Calculation |
Note: The library implementation uses C++20 features internally. The public API is compatible with C++17, so applications linking against the precompiled library only require a C++17 compiler.
- Clone the repository into your
third-party/vendordirectory recursively.
git clone --recursive https://github.com/Aintdev/CroissanTUI.git- Choose your preferred installation method
Install into your project
After cloning the repository, add the project to your CMakeLists.txt. Note: replace ${CMAKE_CURRENT_SOURCE_DIR}/third-party/CroissanTUI with the path to the CroissanTUI repository.
# Add CroissanTUI
add_subdirectory(
"${CMAKE_CURRENT_SOURCE_DIR}/third-party/CroissanTUI"
"${CMAKE_CURRENT_BINARY_DIR}/CroissanTUI"
)
# Link CroissanTUI
target_link_libraries(MyApp PRIVATE CroissanTUI)Then, run your project's CMake configuration/build.
Install via Sample Project
After cloning the repository, navigate to CroissanTUI/Scripts/ and run the appropriate setup script for your platform:
- Linux:
Sample-Setup-Linux.sh - Windows:
Sample-Setup-Windows.bat
Once CMake has finished configuring the project, navigate to CroissanTUI/Sample/build/. You will find the generated project files for your CMake-compatible IDE there.
- Include the generated header file in a translation unit.
#include <ctui_c.h>Note: Your IDE may not find the header file at first. This is not a problem since it will be created at build time of the library.
- Begin coding
Expand/Collapse code
#include <ctui_c.h>
using namespace ctui;
using enum Align;
int main()
{
auto screen = Screen::make();
auto root = screen->make_child<VStack>(
pady = 2,
halign = Center,
fill = true
);
auto my_label = root->make_child<Label>(
text << "Normal text | "
<< Color::RED << "Red Text | "
<< GraphicMod::ITALIC << "Italic red text | "
<< GraphicMod::RESET_ALL << "Normal text"
<< "\n☺️☺️☺️☺️☺️☺️☺️☺️\n|",
halign = End
);
screen->run();
}