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
11using namespace ftxui;
12
13Component 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
25int 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}
Component Instance(std::string label, Decorator focusCursor)
int main()
static ScreenInteractive Fullscreen()
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Element text(std::wstring text)
Display a piece of unicode text.
Definition text.cpp:160
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
std::function< Element(Element)> Decorator
Definition elements.hpp:24
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition hbox.cpp:94
std::shared_ptr< ComponentBase > Component