Create Graphical Programs in Terminal with FTXUI
A C++ library for creating graphical applications in the terminal.
We have some blog articles with publishing apps that were made with FTXUI:
How to install FTXUI
For example installation in your distro we will use Ubuntu as a reference, example of installation of dependencies in Ubuntu:
Use ‘search’ in your distro’s package manager or operating system to find the corresponding package names.
The installation will only serve to facilitate the use of Intelissense from your IDE or easier local copies, we will see more details below. To install, first…
FTXUI has 3 Modules which are:
dom- This is the main module, mandatory even if it is a
Hello, World!of life;
screen- Display the elements defined in the dom to display on the screen, also mandatory for any project;
component- This module is optional and it has components such as: user input, widgets, and so on.
Creating a basic project
Let’s create a simple project that will only print “Hello, World!” on the screen and let’s call it 01-ftxui:
- Example 01:
Basic Hello, World! with rounded corners.
- Compiling and running
Optimizing repository clone when compiling
Note that the line:
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui it downloads from the repository on GitHub, but suppose you are offline, you can use the repository itself on your machine. Example:
- First clone the repository to a system directory:
The installed directory won’t work because it doesn’t have a
If you want to save to your normal user, choose a location in
/home/$USERand don’t use
Now change the corresponding line of your
CMakeLists.txt and indicate the location of the repository you cloned:
To test from scratch, remove
build/ and redo the process:
Another example with more than one box
If you want the box to take up the remaining space, send the output to
Or all together!
You can still add colors, for example:
Note that for
color()you can choose not to use the
namespace, or if you want to specify you can also use it, in addition to also using
bgcolorfor inner padding.
And among several other resources such as: Button, Input, Checkbox and among many others that can be found in documentation, in addition to other examples .
- Repository: https://github.com/ArthurSonzogni/ftxui
- Website: https://arthursonzogni.github.io/FTXUI/
- Documentation: https://arthursonzogni.github.io/FTXUI/index.html#introduction
- Examples: https://arthursonzogni.github.io/FTXUI/examples_2component_2button_8cpp-example.html
Watch the video
The video below is in Portuguese, but you can see how all the concepts mentioned in this article work.