:computer: C++ Functional Terminal User Interface. :heart:

FTXUI

travis issues license contributors

Functional Terminal (X) User interface

A simple C++ library for terminal based user interface.

Demo:

Demo image

Feature

  • Functional style. Inspired by [1] and React
  • Simple and elegant syntax (in my opinion).
  • Support for UTF8 and fullwidth chars (→ 测试)
  • No dependencies.
  • Cross platform (mostly). Linux (main target), Windows (experimental), Mac.

Example:

  vbox({
    hbox({
      text(L"left") | border,
      text(L"middle") | border | flex,
      text(L"right") | border,
    }),
    gauge(0.5) | border,
  });
┌────┐┌───────────────────────────────────────────────────────────────┐┌─────┐
│left││middle                                                         ││right│
└────┘└───────────────────────────────────────────────────────────────┘└─────┘
┌────────────────────────────────────────────────────────────────────────────┐
│██████████████████████████████████████                                      │
└────────────────────────────────────────────────────────────────────────────┘

Documentation:

Project using FTXUI

Feel free to add your projects here:

Hosted on:

Owner
Arthur Sonzogni
Love C++. - Image rendering / analysis. - Ascii art / TUI. - Games
Arthur Sonzogni
Comments
  • [BUG] Input fields get random symbols like

    [BUG] Input fields get random symbols like "[B[AA1" or "B" and others pasted in on every action

    Input fields get random symbols like "[B[AA1" or "B" and others pasted in on every action like typing, using the arrow keys and moving the mouse

  • WIP: Port to Win32 and MSVC

    WIP: Port to Win32 and MSVC

    Hi,

    I really like your library, however I would like to use it for a project which currently requires windows support. So here is a quick WIP-version of a windows port.

    I am planning to do some more cleanup before this is ready to merge but sofar it looks good, however before I spend too much time cleaning up my branch I first wanted to check if you are willing to accept a windows port.

    The blocker for merging (IMHO) is that focus handling seems broken in the sense that I cannot move between checkboxes (or list items) in any of the examples. I ran the print_key_press example and pressed ⬅⬆➡⬇, this was the output I got for that:

    ( 27 91 68 ) -> (special)
    ( 27 91 65 ) -> (special)
    ( 27 91 67 ) -> (special)
    ( 27 91 66 ) -> (special)
    
    • [x] Refactor: event translation into separate file
      • currently the Console API event mapping is living inside the read_char thread lambda in screen_interactive.cpp, as this code is a bit longer than the original (which is just a oneliner) my plan is to move it to a separate function in a separate file or ifdef guarded inside event.cpp
    • [x] Bug: Focus handling not working
      • in the examples (e.g. checkbox.cpp) I can toggle the individual checkboxes but I cannot move between items, I tried to understand the focus implementation but am I unsure which keypresses would move focus between different components
    • [ ] Annoyance: Flickering
      • screen_interactive.cpp redraws the screen which causes the output to flicker (on Windows at least), I was thinking about only redrawing the screen if it has changed (i.e. dirty tracking)

    Screenshot:

    image

  • Feature request: Support multi-paragraph text layout

    Feature request: Support multi-paragraph text layout

    I was enjoying the amazing library when I got crazy to find out that...

    There is no proper way I can make two paragraphs (with word wrap) adjacent!

    I've tried... this:
    	auto si = ScreenInteractive::Fullscreen();
    	
    	auto ui = Renderer([]() {
    		return vbox({
    			text("... title goes here ..."),
    			hflow(paragraph("    To celebrate Dragon Boat Festival, an underwater dance performance titled Pray was aired on Henan TV last Saturday night, the first day of the holiday.")),
    			hflow(paragraph("    Featuring the goddess of Luo River – a mysterious beauty best known in the poetry of Cao Zhi during the Three Kingdoms period, the dancer Haohao He, a former synchronized swimmer, recreated the elegance of this ancient Chinese goddess.")),
    		});
    	});
    
    	si.Loop(ui);
    

    ... which spares the vertical space evenly for the two paragraphs, and this:

    	auto ui = Container::Vertical({
    		Renderer([]() { return text("... title goes here ..."); }),
    		Renderer([]() {
    			return vbox({
    				hflow(paragraph("    To celebrate Dragon Boat Festival, an underwater dance performance titled Pray was aired on Henan TV last Saturday night, the first day of the holiday.")),
    				hflow(paragraph("    Featuring the goddess of Luo River – a mysterious beauty best known in the poetry of Cao Zhi during the Three Kingdoms period, the dancer Haohao He, a former synchronized swimmer, recreated the elegance of this ancient Chinese goddess.")),
    			});
    		})
    	});
    

    ... where paragraphs collapse and only one line is visible, with a weird g at the top left corner:

    g.. title goes here ...                                                         
        To celebrate Dragon Boat Festival, an underwater dance performance titled   
        Featuring the goddess of Luo River – a mysterious beauty best known in the  
    

    And I notices this: https://github.com/ArthurSonzogni/FTXUI/issues/68#issuecomment-762807087

    So FTXUI is missing an important and very basic feature for displaying longer texts, and the solution seems not clear.

    I think a discussion about solution is needed here.

  • Arrow keys not working they way they should on Microsoft terminal

    Arrow keys not working they way they should on Microsoft terminal

    When switching between input fields the arrow key sometimes paste in symbols (text doesnt anymore and mouse movement either, thats fixed). When switching between checkboxes and pressing ENTER while switching between them, the arrow keys dont work anymore either (or the switching functionallity doesnt work anymore)

    EDIT: When mouse selecting is enabled (When you can select stuff with your mouse e.g. buttons), symbols also get copied in. Just the text part was fixed in the previous fix

  • Window doesn't update on adding a element to Elements

    Window doesn't update on adding a element to Elements

    I am adding data to Elements output from a separate thread, data is added correctly, but the screen isn't updated on adding a new element, i need to move the focus area with arrow keys for the UI to update, how can i make it update everytime a new element is added to Elements output

  • Is it possible to have on_enter method for Toggle component?

    Is it possible to have on_enter method for Toggle component?

    Hey, is it possible to add on_enter() for toggle component? Since, this framework doesn't have buttons. Toggle is a pretty good way to emulate buttons.

    I am more than happy to contribute for this feature.

  • on_enter callback doesn't work

    on_enter callback doesn't work

    Normally, it works well。 in ubuntu, when I use bind command to start my program based on FTXUI. the on_enter callback of input doesn,t work. like this. add "bind -x '"\C-g":<my_program>" to ~/.bashrc. so I can use 'ctrl+g' to start my program.

  • Customize menu items

    Customize menu items

    Hello, and thanks for the lib again) Is there any built-in way to customize (i.e. change color ) particular item in menu ?

    First approach on my mind is to add MenuOptions for each entry, but it implies some changes in MenuBase. If it is a necessary feature I can later send code for review, of course if it is not already implemented.

    Thanks!

  • Windows can not be used normally

    Windows can not be used normally

    image

    std::string reset_position;
        auto document =
                ftxui::vbox({
                                    ftxui::text(L"GNU Affero General Public License v3.0") | ftxui::bold | color(ftxui::Color::Green) | ftxui::border,
                             hflow(
                                     ftxui::paragraph(L"The GNU Affero General Public License is a free, copyleft license for"
                                               L"software and other kinds of works, specifically designed to ensure"
                                               L"cooperation with the community in the case of network server software."
                                               L"The licenses for most software and other practical works are designed"
                                               L"to take away your freedom to share and change the works.  By contrast,"
                                               L"our General Public Licenses are intended to guarantee your freedom to"
                                               L"share and change all versions of a program--to make sure it remains free"
                                               L"software for all its users.\n"
                                               L"When we speak of free software, we are referring to freedom, not"
                                               L"price.  Our General Public Licenses are designed to make sure that you"
                                               L"have the freedom to distribute copies of free software (and charge for"
                                               L"them if you wish), that you receive source code or can get it if you"
                                               L"want it, that you can change the software or use pieces of it in new"
                                               L"free programs, and that you know you can do these things.  "
                                               L"Developers that use our General Public Licenses protect your rights"
                                               L"with two steps: (1) assert copyright on the software, and (2) offer"
                                               L"you this License which gives you legal permission to copy, distribute"
                                               L"and/or modify the software.")) |
                                     ftxui::border,
                     });
    
        auto screen = ftxui::Screen::Create(ftxui::Dimension::Full());
        Render(screen, document);
        std::cout << reset_position << screen.ToString() << std::flush;
        reset_position = screen.ResetPosition();
        getchar();
        return 0;
    
  • Errors when trying to build the lib

    Errors when trying to build the lib

    Hey, i m trying to build ftxui in a project(vs19) and then link the lib. Im getting unresolved external errors on the color class tho, saying smth like this: LNK2001 unresolved external symbol "class std::function<class std::shared_ptr __cdecl(class std::shared_ptr)> __cdecl ftxui::color(class ftxui::Color)" ([email protected]@@[email protected][email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@@[email protected]@@Z) Could this be due to the 2 files which are both named "color.cpp"?

  • Crash on exit

    Crash on exit

    Often, when exiting from main, I get this crash:

    AdminConsole.exe!std::_Iterator_base12::_Adopt_unlocked(std::_Container_proxy * _Parent_proxy=0xdddddddddddddddd) Line 1190 C++ Symbols loaded. AdminConsole.exe!std::_Iterator_base12::_Adopt_locked(std::_Container_proxy * _Parent_proxy=0xdddddddddddddddd) Line 1198 C++ Symbols loaded. AdminConsole.exe!std::_Iterator_base12::_Adopt(const std::_Container_base12 * _Parent=0x000002f48d016108) Line 1147 C++ Symbols loaded. AdminConsole.exe!std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<std::shared_ptrftxui::ComponentBase>>>::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<std::shared_ptrftxui::ComponentBase>>>(std::shared_ptrftxui::ComponentBase * _Parg=0xdddddddddddddddd, const std::_Container_base12 * _Pvector=0x000002f48d016108) Line 44 C++ Symbols loaded. AdminConsole.exe!std::_Vector_iterator<std::_Vector_val<std::_Simple_types<std::shared_ptrftxui::ComponentBase>>>::_Vector_iterator<std::_Vector_val<std::_Simple_types<std::shared_ptrftxui::ComponentBase>>>(std::shared_ptrftxui::ComponentBase *) C++ Symbols loaded. AdminConsole.exe!std::vector<std::shared_ptrftxui::ComponentBase,std::allocator<std::shared_ptrftxui::ComponentBase>>::end() Line 1486 C++ Symbols loaded. AdminConsole.exe!std::end<std::vector<std::shared_ptrftxui::ComponentBase,std::allocator<std::shared_ptrftxui::ComponentBase>>>(std::vector<std::shared_ptrftxui::ComponentBase,std::allocator<std::shared_ptrftxui::ComponentBase>> & _Cont={...}) Line 1927 C++ Symbols loaded. AdminConsole.exe!ftxui::ComponentBase::Detach() Line 139 C++ Symbols loaded. AdminConsole.exe!ftxui::ComponentBase::~ComponentBase() Line 23 C++ Symbols loaded. AdminConsole.exe!ftxui::ContainerBase::~ContainerBase() Line 23 C++ Symbols loaded. AdminConsole.exe!ftxui::ContainerBase::`scalar deleting destructor'(unsigned int) C++ Symbols loaded. AdminConsole.exe!std::_Destroy_in_placeftxui::ContainerBase(ftxui::ContainerBase & _Obj={...}) Line 313 C++ Symbols loaded. AdminConsole.exe!std::_Ref_count_obj2ftxui::ContainerBase::_Destroy() Line 2048 C++ Symbols loaded. AdminConsole.exe!std::_Ref_count_base::_Decref() Line 1110 C++ Symbols loaded. AdminConsole.exe!std::_Ptr_baseftxui::ComponentBase::_Decref() Line 1341 C++ Symbols loaded. AdminConsole.exe!std::shared_ptrftxui::ComponentBase::~shared_ptrftxui::ComponentBase() Line 1629 C++ Symbols loaded.

  • Featre: Support ctrl+arrow in input.

    Featre: Support ctrl+arrow in input.

    CTRL+LEFT: Move the cursor to the beginning of the word. CTRL+RIGHT: Move the cursor to the beginning of the word.

    This was requested by: https://github.com/ArthurSonzogni/FTXUI/issues/490

  • [Windows] F1-F4 events can't be used

    [Windows] F1-F4 events can't be used

    Looks like on Windows F1-F4 keys generates slightly different codes:

    (27 79 80) F1
    (27 79 81) F2
    (27 79 82) F3
    (27 79 83) F4
    

    While predefined values are:

    (27 91 79 80) F1
    (27 91 79 81) F2
    (27 91 79 82) F3
    (27 91 79 83) F4
    

    For F5-F12 it is the same, except that F11 produces ( 27 91 50 51 126 ).

  • Feature request: Support text selection and word skip when input

    Feature request: Support text selection and word skip when input

    I really like FTXUI, but I've run into some issues that are not conducive to productivity.

    The first is the selection of text, in FTXUI I can't seem to select and copy text in the TUI by mouse movement, which makes me have to type based on what I see when I need text in TUI.

    Secondly, there is no word skipping ability, in many terminals (I use Windows terminal, ubuntu terminal and mac terminal) can quickly move the cursor in the text via CTRL+Left/RightArrow key, which seems impossible to do in FTXUI (I did not see the relevant content in the Input component documentation), which will reduce the input efficiency when using the input component (if you need to move the cursor frequently)

    I don't know if these two features will be implemented, but either way, thank you very much for developing such an awesome project❤️

  • Any way to handle error in FTXUI?

    Any way to handle error in FTXUI?

    Hi, @ArthurSonzogni, CC: @SAtacker

    I have try using C++ exceptions in FTXUI, but it doesn't work properly. Any recommendation to handle errors in FTXUI.

    Thanks

  • Radiobox doesn't accept enter event

    Radiobox doesn't accept enter event

    RadioboxBase::OnEvent returns false for Event::Return: https://github.com/ArthurSonzogni/FTXUI/blob/24e04faf36bf0954272200b0bf51c4305e8b8dfc/src/ftxui/component/radiobox.cpp#L107

  • No access to rgb values of ftxui::Color

    No access to rgb values of ftxui::Color

    I am trying to calculate some contrast color value for certain color and facing issue that R G B values are in private section of Color class. ColorInfo might help here, but there is no way to get it from variable color.

Spitfire is a basic terminal language that can exicute code via the terminal.

Spitfire is a basic terminal language that can exicute code via the terminal. It is easy to learn and runs fast, considering that its just a 300 line c++ file.

Nov 18, 2021
Collection of human friendly terminal interface for git.
Collection of human friendly terminal interface for git.

A collection of human friendly terminal user interface for git.

Sep 24, 2022
ImTui: Immediate Mode Text-based User Interface
ImTui: Immediate Mode Text-based User Interface

imtui ImTui is an immediate mode text-based user interface library. Supports 256 ANSI colors and mouse/keyboard input. Live demo in the browser Eventh

Sep 23, 2022
Fire for C++: Create fully functional CLIs using function signatures

Fire for C++ Fire for C++, inspired by python-fire, is a single header library that creates a command line interface from a function signature. Here's

Sep 24, 2022
A wrapper of C++ std::vector for functional programming

Say hello to functional C++ vectors A wrapper for C++ std::vector geared towards functional programming and fluent APIs. The primary focus is readabil

Jul 26, 2022
Small header only C++ library for writing multiplatform terminal applications

Terminal Terminal is small header only library for writing terminal applications. It works on Linux, macOS and Windows (in the native cmd.exe console)

Sep 22, 2022
A little UNIX-inspired terminal application for the Numworks Calculator (not using escher).
A little UNIX-inspired terminal application for the Numworks Calculator (not using escher).

L.E. Terminal (let for short) is a little UNIX-inspired terminal for the Numworks Calculator.

Aug 31, 2022
Draw sequence diagram in text from terminal.

sequence-diagram-cli Draw seqence diagram from terminal.

Aug 4, 2022
Terminal calculator made for programmers working with multiple number representations, sizes, and overall close to the bits
Terminal calculator made for programmers working with multiple number representations, sizes, and overall close to the bits

Programmer calculator The programmer calculator is a simple terminal tool designed to give maximum efficiency and flexibility to the programmer workin

Sep 28, 2022
X terminal emulator rendering through OpenGL ES Compute Shaders

Zutty is a terminal emulator for the X Window System, functionally similar to several other X terminal emulators such as xterm, rxvt and countless others

Sep 27, 2022
The new Windows Terminal and the original Windows console host, all in the same place!

The new Windows Terminal and the original Windows console host, all in the same place!

Sep 28, 2022
n³ The unorthodox terminal file manager
n³ The unorthodox terminal file manager

n³ The unorthodox terminal file manager

Sep 29, 2022
Graphs the activity of a chia harvester in a linux terminal.
Graphs the activity of a chia harvester in a linux terminal.

Chia Harvest Graph Monitor for Chia Harvesting Introduction The chiaharvestgraph tool will graph Chia Harvesting activity in a linux terminal. Use a 2

Sep 21, 2022
a simple to use linux terminal

a simple to use linux terminal

Feb 17, 2022
Simple benchmark for terminal output

TermBench This is a simple timing utility you can use to see how slow your terminal program is at parsing escape-sequence-coded color output. It can b

Sep 24, 2022
tinytetris - 80x23 terminal tetris
tinytetris - 80x23 terminal tetris

tinytetris - 80x23 terminal tetris

Sep 30, 2022
Contour - A modern C++ Terminal Emulator
 Contour - A modern C++ Terminal Emulator

contour is a modern terminal emulator, for everyday use. It is aiming for power users with a modern feature mindset.

Oct 2, 2022
A C, C++ and Rust library to draw graphics with pixels in the terminal
A C, C++ and Rust library to draw graphics with pixels in the terminal

A library to draw graphics with pixels in the terminal Who needs a GUI when you have a terminal ? Building To generate libpluto.a, run: $ make To ins

Sep 3, 2022
📺🗿 Terminal graphics for the 21st century.
📺🗿 Terminal graphics for the 21st century.

???? Chafa is a command-line utility that converts all kinds of images, including animated GIFs, into sixel or ANSI/Unicode character output that can be displayed in a terminal.

Sep 24, 2022