FTXUI 6.1.9 C++ functional terminal UI.

Loading...
Searching...
No Matches
focus_cursor.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#include <ftxui/component/captured_mouse.hpp> // for ftxui
5#include <string> // for allocator, operator+, char_traits, string
6
7#include "ftxui/component/component.hpp" // for Renderer, Vertical
8#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive, Component
9#include "ftxui/dom/elements.hpp" // for text, Decorator, focus, focusCursorBar, focusCursorBarBlinking, focusCursorBlock, focusCursorBlockBlinking, focusCursorUnderline, focusCursorUnderlineBlinking, hbox, Element
10
11 using namespace ftxui;
12
13 Component Instance(std::string label, Decorator focusCursor) {
14 return Renderer([=](bool focused) {
15 if (focused) {
16 return hbox({
17 text("> " + label + " "),
18 focusCursor(text(" ")),
19 });
20 }
21 return text(" " + label + " ");
22 });
23};
24
25 int main() {
26 auto screen = ScreenInteractive::Fullscreen();
27 screen.Loop(Container::Vertical({
28 Instance("focus", focus),
29 Instance("focusCursorBlock", focusCursorBlock),
30 Instance("focusCursorBlockBlinking", focusCursorBlockBlinking),
31 Instance("focusCursorBar", focusCursorBar),
32 Instance("focusCursorBarBlinking", focusCursorBarBlinking),
33 Instance("focusCursorUnderline", focusCursorUnderline),
34 Instance("focusCursorUnderlineBlinking", focusCursorUnderlineBlinking),
35 }));
36 return 0;
37}
captured_mouse.hpp
component.hpp
elements.hpp
Instance
Component Instance(std::string label, Decorator focusCursor)
Definition focus_cursor.cpp:13
main
int main()
Definition focus_cursor.cpp:25
ftxui::ScreenInteractive::Fullscreen
static ScreenInteractive Fullscreen()
Definition screen_interactive.cpp:376
ftxui::Renderer
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Definition src/ftxui/component/renderer.cpp:61
ftxui::text
Element text(std::wstring text)
Display a piece of unicode text.
Definition text.cpp:160
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
ftxui::Decorator
std::function< Element(Element)> Decorator
Definition elements.hpp:24
ftxui::hbox
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition hbox.cpp:94
ftxui::Component
std::shared_ptr< ComponentBase > Component
Definition component_base.hpp:24
screen_interactive.hpp