2022-12-20 01:51:25 +08:00
|
|
|
#include <ftxui/component/captured_mouse.hpp> // for ftxui
|
|
|
|
#include <string> // for allocator, operator+, char_traits, string
|
2022-11-11 21:09:53 +08:00
|
|
|
|
2022-12-20 01:51:25 +08:00
|
|
|
#include "ftxui/component/component.hpp" // for Renderer, Vertical
|
|
|
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive, Component
|
|
|
|
#include "ftxui/dom/elements.hpp" // for text, Decorator, focus, focusCursorBar, focusCursorBarBlinking, focusCursorBlock, focusCursorBlockBlinking, focusCursorUnderline, focusCursorUnderlineBlinking, hbox, Element
|
2022-11-11 21:09:53 +08:00
|
|
|
|
|
|
|
using namespace ftxui;
|
|
|
|
|
|
|
|
Component Instance(std::string label, Decorator focusCursor) {
|
|
|
|
return Renderer([=](bool focused) {
|
|
|
|
if (focused) {
|
|
|
|
return hbox({
|
|
|
|
text("> " + label + " "),
|
|
|
|
focusCursor(text(" ")),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return text(" " + label + " ");
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-06-03 19:59:39 +08:00
|
|
|
int main() {
|
2022-11-11 21:09:53 +08:00
|
|
|
auto screen = ScreenInteractive::Fullscreen();
|
|
|
|
screen.Loop(Container::Vertical({
|
|
|
|
Instance("focus", focus),
|
|
|
|
Instance("focusCursorBlock", focusCursorBlock),
|
|
|
|
Instance("focusCursorBlockBlinking", focusCursorBlockBlinking),
|
|
|
|
Instance("focusCursorBar", focusCursorBar),
|
|
|
|
Instance("focusCursorBarBlinking", focusCursorBarBlinking),
|
|
|
|
Instance("focusCursorUnderline", focusCursorUnderline),
|
|
|
|
Instance("focusCursorUnderlineBlinking", focusCursorUnderlineBlinking),
|
|
|
|
}));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
|
|
|
// Use of this source code is governed by the MIT license that can be found in
|
|
|
|
// the LICENSE file.
|