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

Overview

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:

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

    opened by Creapermann 28
  • 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

    opened by mauve 26
  • 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.

    enhancement help wanted 
    opened by Zjl37 24
  • 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

    opened by Creapermann 20
  • 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

    opened by VedantParanjape 20
  • 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.

    good first issue 
    opened by VedantParanjape 13
  • 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.

    opened by brokensword2018 12
  • 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!

    enhancement 
    opened by MattBystrin 12
  • 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;
    
    opened by YuzukiTsuru 12
  • 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)" (?color@ftxui@@YA?AV?$function@$$A6A?AV?$shared_ptr@VNode@ftxui@@@std@@V12@@Z@std@@VColor@1@@Z) Could this be due to the 2 files which are both named "color.cpp"?

    opened by Creapermann 11
  • 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.

    opened by MichaelGoulding 11
  • Serial port support?

    Serial port support?

    Hi! FTXUI is great and it works flawlessy on "modern" terminals. However using an application via minicom/teraterm results in scrambled stdout, like if the cursor will not go back before rendering the new UI. The only application I have been able to use FTXUI with is MobaXTerm. Anyone noticed this issue?

    opened by fmntf 0
  • Scrollable paragraph

    Scrollable paragraph

    Hello. I sincerely apologize for using issues as helpdesk but cannot figure out how to make a thing which looks trivial: scrollable paragraph frame. Meaning, I need to display quite a wall of text and want to let user to scroll it with arrows/mouse wheel. I checked the other issues and the code of git-tui and chrome-log-beautifier, but they seem to operate with lists, not paragraphs. Or there is no easy builtin way to do that, and I need to write a component for this purpose from scratch?

    image

    Thanks in advance, the library is very neat and handy!

    opened by archydragon 3
  • Braille and Box Characters Not Appearing

    Braille and Box Characters Not Appearing

    Hi, I was trying to run the "Canvas_Animated.cpp" file but Braille and Box characters appear as "?" blocks. Is there a solution to this?

    opened by ZclipseCode 2
  • [Question] How to render dynamic list of interactive components?

    [Question] How to render dynamic list of interactive components?

    I want to render a list (of interactive components) that can grow or shrink depending on if the vector of some dynamic data grows or shrinks. I have tried the following 2 (and some related) approaches to achieve this behavior, but both approaches don't produce the desired result.

    Component DynalicListComponent(std::vector<Data> &dynamic_data) {
      return Renderer([&] {
        std::vector<Element> interactive_components;
        for (auto &data : dynamic_data)
          interactive_components.emplace_back(InteractiveComponent(data)->Render());
    
        return vbox(interactive_components)
          | yframe
          | border;
      });
    }
    

    With this approach the list looks dynamic, i.e., when data is added or removed from the dynamic data the DynalicListComponent grows or shrinks to reflect that. But I can't interact with any inner InteractiveComponent because I have not passed them as an inner component to the Renderer function.

    Component DynalicListComponent(std::vector<Data> &dynamic_data) {
      std::vector<Component> interactive_components;
      for (auto &data : dynamic_data)
        interactive_components.emplace_back(InteractiveComponent(data));
    
      return Container::Vertical(interactive_components)
        | yframe
        | border;
    }
    

    This approach maintains the interactivity of the inner components in the list, but the list doesn't react to changes to the dynamic data anymore. Thus, adding or removing data from the dynamic data does not make the DynamicListComponent re-execute the code to construct the interactive components list to reflect the change.

    Is there any simple way to have both a dynamic list as well as inner components' interactivity with just "functional components" as shown above?

    opened by srijan-nayak 1
  • 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❤️

    enhancement 
    opened by twinkles-twinstar 1
Releases(v3.0.0)
Owner
Arthur Sonzogni
Love C++. - Image rendering / analysis. - Ascii art / TUI. - Games
Arthur Sonzogni
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.

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

A collection of human friendly terminal user interface for git.

Arthur Sonzogni 76 Dec 30, 2022
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

Georgi Gerganov 2.1k Jan 5, 2023
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

Kristjan Kongas 439 Dec 31, 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

null 19 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)

Jupyter Xeus 274 Jan 2, 2023
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.

Cacahuète Sans Sel 20 Aug 31, 2022
Draw sequence diagram in text from terminal.

sequence-diagram-cli Draw seqence diagram from terminal.

null 44 Dec 20, 2022
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

romes 183 Dec 24, 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

Tom Szilagyi 259 Dec 24, 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!

Microsoft 86.8k Dec 29, 2022
n³ The unorthodox terminal file manager

n³ The unorthodox terminal file manager

Mischievous Meerkat 15.5k Jan 1, 2023
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

Bram Stolk 215 Dec 11, 2022
a simple to use linux terminal

a simple to use linux terminal

notaweeb 7 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

Casey Muratori 174 Dec 4, 2022
tinytetris - 80x23 terminal tetris

tinytetris - 80x23 terminal tetris

Conor Taylor 2k Jan 3, 2023
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.

Contour Terminal Emulator 1.1k Dec 28, 2022
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

null 69 Nov 7, 2022
📺🗿 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.

Hans Petter Jansson 1.8k Dec 31, 2022