12 Commits

Author SHA1 Message Date
ArthurSonzogni
0200632555 Update CHANGELOG for v4.2 2023-07-26 00:04:11 +02:00
ArthurSonzogni
ce252ff92e Add missing includes for gcc
Bug:https://github.com/ArthurSonzogni/FTXUI/issues/695
2023-07-25 23:55:41 +02:00
cblack-dev
afb03620da Resolve unused varaible warning in _WIN32 builds of screen_interactive.cpp (#693)
Marks constexpr int timeout_microseconds on line 73 as [[maybe_unused]] to resolve unused variable warning on _WIN32 builds.
2023-07-25 23:54:51 +02:00
Stefan Ravn van Overeem
de6749fed7 Improve unicode codepoint Bisearch performance (#691)
Improve the performance of the functions for searching for codepoints
in a table by passing the table array in as a reference instead of copying
it.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-07-25 23:54:45 +02:00
Stefan Ravn van Overeem
2bcdb9ac54 Support Fn keys for every terminal standards (#689)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-07-25 23:54:39 +02:00
Arthur Sonzogni
2ed61a9d31 Support F1-F5 from OS terminal (#687)
Bug:https://github.com/ArthurSonzogni/FTXUI/issues/685
2023-07-25 23:53:20 +02:00
Arthur Sonzogni
46042ce74a Feature: hyperlink support. (#665)
See the [OSC 8 page](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda).
FTXUI support proposed by @aaleino in [#662](https://github.com/ArthurSonzogni/FTXUI/issues/662).

API:
```cpp
auto link = text("Click here") | hyperlink("https://github.com/FTXUI")
```

Fixed:https://github.com/ArthurSonzogni/FTXUI/issues/662
2023-07-25 23:35:55 +02:00
Prokop Randáček
1651ae56ca fix some warnings (#660)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-07-25 23:26:41 +02:00
Henrik S. Gaßmann
f64e1e128e build: Properly escape paths which may contain spaces 2023-05-30 09:03:49 +02:00
Henrik S. Gaßmann
3483022703 build: Remove redundant cmake version check
The main `CMakelists.txt` already asserts a minimum version of `3.12`
which renders the condition `cmake <= 3.11.4` to be always false.
2023-05-30 09:03:44 +02:00
Henrik S. Gaßmann
7f5aed1e66 build(install): Remove redundant install settings 2023-05-30 09:03:38 +02:00
Henrik S. Gaßmann
438a7dc842 build(install): Fix pkgconfig install directory
`pkg-config` finds configs within `$prefix/lib/pkgconfig`, but not in
`$prefix/lib`.

See-Also: https://linux.die.net/man/1/pkg-config
2023-05-30 09:03:33 +02:00
97 changed files with 440 additions and 112 deletions

View File

@@ -1,6 +1,27 @@
Changelog
=========
4.2
---
### Component
- Bugfix: Support Fn keys for every terminal specifications.
### Dom
- Feature: Add `hyperlink` decorator. For instance:
```cpp
auto link = text("Click here") | hyperlink("https://github.com/FTXUI")
```
See the [OSC 8 page](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda).
FTXUI support proposed by @aaleino in [#662](https://github.com/ArthurSonzogni/FTXUI/issues/662).
### Screen
- Fix huge performance bug affecting some compilers about unicode bisection.
### Build
- Check version compatibility when using cmake find_package()
- Fix missing includes for some gcc versions.
4.1.1
-----

View File

@@ -52,6 +52,7 @@ add_library(dom
src/ftxui/dom/automerge.cpp
src/ftxui/dom/blink.cpp
src/ftxui/dom/bold.cpp
src/ftxui/dom/hyperlink.cpp
src/ftxui/dom/border.cpp
src/ftxui/dom/box_helper.cpp
src/ftxui/dom/box_helper.hpp

View File

@@ -127,6 +127,7 @@ An element can be decorated using the functions:
- `strikethrough`
- `color`
- `bgcolor`
- `hyperlink`
[Example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2style_gallery_8cpp-example.html)

View File

@@ -4,5 +4,5 @@ add_library(ftxui::component ALIAS component)
export(
TARGETS screen dom component
NAMESPACE ftxui::
FILE ${PROJECT_BINARY_DIR}/ftxui-targets.cmake
FILE "${PROJECT_BINARY_DIR}/ftxui-targets.cmake"
)

View File

@@ -27,7 +27,7 @@ set(BUILD_GMOCK OFF CACHE INTERNAL "")
set(INSTALL_GTEST OFF CACHE INTERNAL "")
set(gtest_force_shared_crt ON CACHE INTERNAL "")
add_subdirectory(
${googletest_SOURCE_DIR}
${googletest_BINARY_DIR}
"${googletest_SOURCE_DIR}"
"${googletest_BINARY_DIR}"
EXCLUDE_FROM_ALL
)

View File

@@ -11,13 +11,11 @@ include(CMakePackageConfigHelpers)
install(
TARGETS screen dom component
EXPORT ftxui-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
DIRECTORY include/ftxui
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
# ------------------------------------------------------------------------------
@@ -26,7 +24,7 @@ install(
install(
EXPORT ftxui-targets
NAMESPACE ftxui::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ftxui"
)
# ------------------------------------------------------------------------------
@@ -34,21 +32,21 @@ install(
# needed to support users of find_package()
# ------------------------------------------------------------------------------
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/ftxui-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/ftxui/cmake
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/ftxui-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/ftxui/cmake"
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config-version.cmake
"${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config-version.cmake"
VERSION ${PACKAGE_VERSION}
COMPATIBILITY SameMajorVersion
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
"${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ftxui"
)
# ------------------------------------------------------------------------------
@@ -57,6 +55,6 @@ install(
# ------------------------------------------------------------------------------
configure_file(ftxui.pc.in ${CMAKE_CURRENT_BINARY_DIR}/ftxui.pc @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/ftxui.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}
FILES "${CMAKE_CURRENT_BINARY_DIR}/ftxui.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
)

View File

@@ -1,5 +1,4 @@
if (NOT FTXUI_BUILD_TESTS OR
NOT ${CMAKE_VERSION} VERSION_GREATER "3.11.4")
if (NOT FTXUI_BUILD_TESTS)
return()
endif()
@@ -37,6 +36,7 @@ add_executable(ftxui-tests
src/ftxui/dom/gauge_test.cpp
src/ftxui/dom/gridbox_test.cpp
src/ftxui/dom/hbox_test.cpp
src/ftxui/dom/hyperlink_test.cpp
src/ftxui/dom/linear_gradient_test.cpp
src/ftxui/dom/scroll_indicator_test.cpp
src/ftxui/dom/separator_test.cpp

View File

@@ -1,7 +1,7 @@
find_program(iwyu_path NAMES include-what-you-use iwyu)
if(iwyu_path)
set_property(TARGET ${lib}
PROPERTY ${iwyu_path} -Xiwyu
--mapping_file ${CMAKE_CURRENT_SOURCE_DIR}/iwyu.imp
PROPERTY "${iwyu_path}" -Xiwyu
--mapping_file "${CMAKE_CURRENT_SOURCE_DIR}/iwyu.imp"
)
endif()

View File

@@ -9,7 +9,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
int value = 50;
// The tree of components. This defines how to navigate using the keyboard.

View File

@@ -11,7 +11,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
int value = 50;
// The tree of components. This defines how to navigate using the keyboard.

View File

@@ -11,7 +11,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
int counter = 0;
auto on_click = [&] { counter++; };

View File

@@ -10,7 +10,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
int value = 0;
auto action = [&] { value++; };
auto action_renderer =

View File

@@ -14,7 +14,7 @@
#include "ftxui/dom/canvas.hpp" // for Canvas
#include "ftxui/screen/color.hpp" // for Color, Color::Red, Color::Blue, Color::Green, ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
int mouse_x = 0;

View File

@@ -8,12 +8,12 @@
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, vscroll_indicator, HEIGHT, LESS_THAN
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
Component input_list = Container::Vertical({});
std::vector<std::string> items(100, "");
for (int i = 0; i < items.size(); ++i) {
for (size_t i = 0; i < items.size(); ++i) {
input_list->Add(Input(&(items[i]), "placeholder " + std::to_string(i)));
}

View File

@@ -10,7 +10,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::array<bool, 30> states;
auto container = Container::Vertical({});

View File

@@ -26,7 +26,7 @@ Component Empty() {
return std::make_shared<ComponentBase>();
}
int main(int argc, const char* argv[]) {
int main() {
auto component =
Collapsible("Collapsible 1",
Inner({

View File

@@ -11,7 +11,7 @@ using namespace ftxui;
// An example of how to compose multiple components into one and maintain their
// interactiveness.
int main(int argc, const char* argv[]) {
int main() {
auto left_count = 0;
auto right_count = 0;

View File

@@ -11,7 +11,7 @@
#include "ftxui/component/loop.hpp" // for Loop
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::FitComponent();

View File

@@ -5,7 +5,7 @@
#include "ftxui/component/component.hpp" // for Dropdown, Horizontal, Vertical
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
std::vector<std::string> entries = {

View File

@@ -13,7 +13,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::Fullscreen();
int direction_index = 0;

View File

@@ -31,7 +31,7 @@ Element make_grid() {
return gridbox(rows);
};
int main(int argc, const char* argv[]) {
int main() {
float focus_x = 0.5f;
float focus_y = 0.5f;

View File

@@ -19,7 +19,7 @@ Component Instance(std::string label, Decorator focusCursor) {
});
};
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::Fullscreen();
screen.Loop(Container::Vertical({
Instance("focus", focus),

View File

@@ -23,7 +23,7 @@ Component Wrap(std::string name, Component component) {
});
}
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::FitComponent();
// -- Menu

View File

@@ -24,7 +24,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::Fullscreen();
// ---------------------------------------------------------------------------

View File

@@ -9,7 +9,7 @@
#include "ftxui/dom/elements.hpp" // for text, hbox, separator, Element, operator|, vbox, border
#include "ftxui/util/ref.hpp" // for Ref
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
std::string first_name;

View File

@@ -9,7 +9,7 @@
#include "ftxui/component/component.hpp" // for Slider, Renderer, Vertical
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::Fullscreen();

View File

@@ -10,7 +10,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> entries = {
"entry 1",
"entry 2",

View File

@@ -8,7 +8,7 @@
#include "ftxui/component/component_options.hpp" // for MenuOption
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::TerminalOutput();

View File

@@ -10,7 +10,7 @@
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/elements.hpp" // for text, separator, bold, hcenter, vbox, hbox, gauge, Element, operator|, border
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::TerminalOutput();

View File

@@ -28,7 +28,7 @@ MenuEntryOption Colored(ftxui::Color c) {
return option;
}
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::TerminalOutput();
int selected = 0;

View File

@@ -24,7 +24,7 @@ MenuEntryOption Colored(ftxui::Color c) {
return option;
}
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::TerminalOutput();
int selected = 0;

View File

@@ -10,7 +10,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> entries;
int selected = 0;

View File

@@ -17,7 +17,7 @@ Component Window(std::string title, Component component) {
});
}
int main(int argc, const char* argv[]) {
int main() {
int menu_selected[] = {0, 0, 0};
std::vector<std::vector<std::string>> menu_entries = {
{

View File

@@ -30,7 +30,7 @@ Component HMenu3(std::vector<std::string>* entries, int* selected);
Component HMenu4(std::vector<std::string>* entries, int* selected);
Component HMenu5(std::vector<std::string>* entries, int* selected);
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::TerminalOutput();
std::vector<std::string> entries{

View File

@@ -27,7 +27,7 @@ Component Text(const std::string& t) {
return Renderer([t] { return text(t) | borderEmpty; });
}
int main(int argc, const char* argv[]) {
int main() {
using namespace std::literals;
std::vector<std::string> tab_values{
"Tab 1", "Tab 2", "Tab 3", "A very very long tab", "",

View File

@@ -8,7 +8,7 @@
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, Element, filler, text, hbox, separator, center, vbox, bold, border, clear_under, dbox, size, GREATER_THAN, HEIGHT
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::TerminalOutput();

View File

@@ -35,7 +35,7 @@ void Nested(std::string path) {
screen.Loop(renderer);
}
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::FitComponent();
auto button_quit = Button("Quit", screen.ExitLoopClosure());
auto button_nested = Button("Nested", [] { Nested(""); });

View File

@@ -134,7 +134,7 @@ std::string Stringify(Event event) {
return out;
}
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::TerminalOutput();
std::vector<Event> keys;

View File

@@ -7,7 +7,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> radiobox_list = {
"Use gcc",
"Use clang",

View File

@@ -10,7 +10,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> entries;
int selected = 0;

View File

@@ -7,7 +7,7 @@
#include "ftxui/dom/elements.hpp" // for operator|, Element, text, bold, border, center, color
#include "ftxui/screen/color.hpp" // for Color, Color::Red
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::FitComponent();

View File

@@ -8,7 +8,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::Fullscreen();
auto middle = Renderer([] { return text("middle") | center; });

View File

@@ -4,7 +4,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::TerminalOutput();
int value = 50;
auto slider = Slider("Value:", &value, 0, 100, 1);

View File

@@ -12,7 +12,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::TerminalOutput();
std::array<int, 30> values;
for (int i = 0; i < values.size(); ++i) {
@@ -20,10 +20,10 @@ int main(int argc, const char* argv[]) {
}
auto layout_horizontal = Container::Horizontal({});
for (int i = 0; i < values.size(); ++i) {
for (auto& value : values) {
// In C++17:
SliderOption<int> option;
option.value = &values[i];
option.value = &value;
option.max = 100;
option.increment = 5;
option.direction = GaugeDirection::Up;

View File

@@ -23,7 +23,7 @@ Element ColorString(int red, int green, int blue) {
);
}
int main(int argc, const char* argv[]) {
int main() {
int red = 128;
int green = 25;
int blue = 100;

View File

@@ -10,7 +10,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> tab_values{
"tab_1",
"tab_2",

View File

@@ -10,7 +10,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> tab_values{
"tab_1",
"tab_2",

View File

@@ -10,7 +10,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> toggle_1_entries = {
"On",
"Off",

View File

@@ -27,6 +27,7 @@ example(style_bold)
example(style_color)
example(style_dim)
example(style_gallery)
example(style_hyperlink)
example(style_inverted)
example(style_strikethrough)
example(style_underlined)

View File

@@ -6,7 +6,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto make_boxed = [] {

View File

@@ -6,7 +6,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = vbox({

View File

@@ -8,7 +8,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for Color, Color::Red, Color::Blue, Color::Green, ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto c = Canvas(100, 100);

View File

@@ -10,7 +10,7 @@
using namespace ftxui;
#include "./color_info_sorted_2d.ipp" // for ColorInfoSorted2D
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::vector<ColorInfo>> info_columns = ColorInfoSorted2D();
// Draw every columns

View File

@@ -6,7 +6,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for Color, ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
int saturation = 255;

View File

@@ -6,7 +6,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for Color, ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
int saturation = 255;

View File

@@ -5,7 +5,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = dbox({
vbox({

View File

@@ -8,7 +8,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
using namespace std::chrono_literals;

View File

@@ -8,7 +8,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
using namespace std::chrono_literals;

View File

@@ -6,7 +6,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto cell = [](const char* t) { return text(t) | border; };
auto document = //

View File

@@ -6,7 +6,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto make_box = [](int dimx, int dimy) {
std::string title = std::to_string(dimx) + "x" + std::to_string(dimy);

View File

@@ -9,7 +9,7 @@
#include "ftxui/screen/box.hpp" // for ftxui
#include "ftxui/screen/color.hpp" // for Color, Color::Red
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
using namespace std::chrono_literals;

View File

@@ -6,7 +6,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for Color, Color::DeepPink1, Color::DeepSkyBlue1, Color::Yellow, ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = text("gradient") | center;

View File

@@ -12,7 +12,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for Color, Color::Green, Color::Red, Color::RedLight, ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
struct Task {

View File

@@ -10,13 +10,13 @@
#include "ftxui/screen/box.hpp" // for ftxui
using namespace std::chrono_literals;
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
std::string p =
R"(In probability theory and statistics, Bayes' theorem (alternatively Bayes' law or Bayes' rule) describes the probability of an event, based on prior knowledge of conditions that might be related to the event. For example, if cancer is related to age, then, using Bayes' theorem, a person's age can be used to more accurately assess the probability that they have cancer, compared to the assessment of the probability of cancer made without knowledge of the person's age. One of the many applications of Bayes' theorem is Bayesian inference, a particular approach to statistical inference. When applied, the probabilities involved in Bayes' theorem may have different probability interpretations. With the Bayesian probability interpretation the theorem expresses how a subjective degree of belief should rationally change to account for availability of related evidence. Bayesian inference is fundamental to Bayesian statistics.)";
std::string reset_position;
for (int i = 0;; ++i) {
while (true) {
auto document = vbox({
hflow(paragraph(p)),
separator(),

View File

@@ -5,7 +5,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = hbox({
text("left-column"),

View File

@@ -6,7 +6,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/box.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = vbox({

View File

@@ -7,7 +7,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto make_box = [](const std::string& title) {
return window(text(title) | hcenter | bold,

View File

@@ -10,7 +10,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
using namespace std::chrono_literals;

View File

@@ -5,7 +5,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = //
hbox({

View File

@@ -5,7 +5,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = //
hbox({

View File

@@ -6,7 +6,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for Color, operator""_rgb, Color::Black, Color::Blue, Color::BlueLight, Color::Cyan, Color::CyanLight, Color::DeepSkyBlue4, Color::Default, Color::GrayDark, Color::GrayLight, Color::Green, Color::GreenLight, Color::Magenta, Color::MagentaLight, Color::Red, Color::RedLight, Color::SkyBlue1, Color::White, Color::Yellow, Color::YellowLight, ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = hbox({
vbox({

View File

@@ -5,7 +5,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = //
hbox({

View File

@@ -5,7 +5,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for Color, Color::Blue, ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
// clang-format off
auto document =
@@ -19,7 +19,8 @@ int main(int argc, const char* argv[]) {
text("blink") | blink , text(" ") ,
text("strikethrough") | strikethrough , text(" ") ,
text("color") | color(Color::Blue) , text(" ") ,
text("bgcolor") | bgcolor(Color::Blue) ,
text("bgcolor") | bgcolor(Color::Blue) , text(" ") ,
text("hyperlink") | hyperlink("https://github.com/ArthurSonzogni/FTXUI"),
});
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));

View File

@@ -0,0 +1,25 @@
#include <ftxui/dom/elements.hpp> // for text, operator|, bold, Fit, hbox, Element
#include <ftxui/screen/screen.hpp> // for Full, Screen
#include <memory> // for allocator
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main() {
using namespace ftxui;
auto document = //
hbox({
text("This text is an "),
text("hyperlink") | hyperlink("https://www.google.com"),
text(". Do you like it?"),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document);
screen.Print();
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.

View File

@@ -5,7 +5,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = hbox({
text("This text is "),

View File

@@ -5,7 +5,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = //
hbox({

View File

@@ -5,7 +5,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = //
hbox({

View File

@@ -5,7 +5,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = //
hbox({

View File

@@ -8,7 +8,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::Cyan, Color::White, ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto table = Table({

View File

@@ -6,7 +6,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = //
vbox({

View File

@@ -6,7 +6,7 @@
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto make_box = [](int dimx, int dimy) {
std::string title = std::to_string(dimx) + "x" + std::to_string(dimy);

View File

@@ -110,6 +110,8 @@ Element bgcolor(const LinearGradient&, Element);
Decorator focusPosition(int x, int y);
Decorator focusPositionRelative(float x, float y);
Element automerge(Element child);
Decorator hyperlink(std::string link);
Element hyperlink(std::string link, Element child);
// --- Layout is
// Horizontal, Vertical or stacked set of elements.

View File

@@ -1,8 +1,9 @@
#ifndef FTXUI_SCREEN_SCREEN_HPP
#define FTXUI_SCREEN_SCREEN_HPP
#include <cstdint> // for uint8_t
#include <memory>
#include <string> // for string, allocator, basic_string
#include <string> // for string, basic_string, allocator
#include <vector> // for vector
#include "ftxui/screen/box.hpp" // for Box
@@ -20,6 +21,10 @@ struct Pixel {
// like: a⃦, this can potentially contains multiple codepoitns.
std::string character = " ";
// The hyperlink associated with the pixel.
// 0 is the default value, meaning no hyperlink.
uint8_t hyperlink = 0;
// Colors:
Color background_color = Color::Default;
Color foreground_color = Color::Default;
@@ -99,6 +104,11 @@ class Screen {
Cursor cursor() const { return cursor_; }
void SetCursor(Cursor cursor) { cursor_ = cursor; }
// Store an hyperlink in the screen. Return the id of the hyperlink. The id is
// used to identify the hyperlink when the user click on it.
uint8_t RegisterHyperlink(std::string link);
const std::string& Hyperlink(uint8_t id) const;
Box stencil;
protected:
@@ -106,6 +116,7 @@ class Screen {
int dimy_;
std::vector<std::vector<Pixel>> pixels_;
Cursor cursor_;
std::vector<std::string> hyperlinks_ = {""};
};
} // namespace ftxui

View File

@@ -2,6 +2,7 @@
#define FTXUI_SCREEN_STRING_HPP
#include <stddef.h> // for size_t
#include <cstdint> // for uint8_t
#include <string> // for string, wstring, to_string
#include <vector> // for vector

View File

@@ -14,6 +14,32 @@
{ include: ["<gtest/gtest-printers.h>", "private", "<gtest/gtest.h>", "public" ] },
{ include: ["<gtest/gtest-test-part.h>", "private", "<gtest/gtest.h>", "public" ] },
{ include: ["<gtest/gtest-typed-test.h>", "private", "<gtest/gtest.h>", "public" ] },
{ include: ["<assert.h>", "private", "<cassert>", "public" ] },
{ include: ["<complex.h>", "private", "<ccomplex>", "public" ] },
{ include: ["<ctype.h>", "private", "<cctype>", "public" ] },
{ include: ["<errno.h>", "private", "<cerrno>", "public" ] },
{ include: ["<fenv.h>", "private", "<cfenv>", "public" ] },
{ include: ["<float.h>", "private", "<cfloat>", "public" ] },
{ include: ["<inttypes.h>", "private", "<cinttypes>", "public" ] },
{ include: ["<iso646.h>", "private", "<ciso646>", "public" ] },
{ include: ["<limits.h>", "private", "<climits>", "public" ] },
{ include: ["<locale.h>", "private", "<clocale>", "public" ] },
{ include: ["<math.h>", "private", "<cmath>", "public" ] },
{ include: ["<setjmp.h>", "private", "<csetjmp>", "public" ] },
{ include: ["<signal.h>", "private", "<csignal>", "public" ] },
{ include: ["<stdalign.h>", "private", "<cstdalign>", "public" ] },
{ include: ["<stdarg.h>", "private", "<cstdarg>", "public" ] },
{ include: ["<stdbool.h>", "private", "<cstdbool>", "public" ] },
{ include: ["<stddef.h>", "private", "<cstddef>", "public" ] },
{ include: ["<stdint.h>", "private", "<cstdint>", "public" ] },
{ include: ["<stdio.h>", "private", "<cstdio>", "public" ] },
{ include: ["<stdlib.h>", "private", "<cstdlib>", "public" ] },
{ include: ["<string.h>", "private", "<cstring>", "public" ] },
{ include: ["<tgmath.h>", "private", "<ctgmath>", "public" ] },
{ include: ["<time.h>", "private", "<ctime>", "public" ] },
{ include: ["<uchar.h>", "private", "<cuchar>", "public" ] },
{ include: ["<wchar.h>", "private", "<cwchar>", "public" ] },
{ include: ["<wctype.h>", "private", "<cwctype>", "public" ] },
{ symbol: ["ftxui", "private", "", "public" ] },
{ symbol: ["char_traits", "private", "<string>", "public" ] },
{ symbol: ["ECHO", "private", "<termios.h>", "public" ] },

View File

@@ -1,5 +1,6 @@
#include <algorithm> // for max, min
#include <cstddef> // for size_t
#include <cstdint> // for uint32_t
#include <functional> // for function
#include <memory> // for shared_ptr
#include <string> // for string, allocator

View File

@@ -70,7 +70,8 @@ void Flush() {
}
constexpr int timeout_milliseconds = 20;
constexpr int timeout_microseconds = timeout_milliseconds * 1000;
[[maybe_unused]] constexpr int timeout_microseconds =
timeout_milliseconds * 1000;
#if defined(_WIN32)
void EventListener(std::atomic<bool>* quit, Sender<Task> out) {

View File

@@ -1,4 +1,5 @@
#include <algorithm> // for max, min
#include <algorithm> // for max, min
#include <cstdint> // for uint8_t, uint16_t, uint32_t, uint64_t
#include <ftxui/component/component_options.hpp> // for SliderOption
#include <string> // for allocator
#include <utility> // for move

View File

@@ -44,6 +44,47 @@ const std::map<std::string, std::string> g_uniformize = {
{"\x1BOH", "\x1B[H"}, // HOME
{"\x1BOF", "\x1B[F"}, // END
// Variations around the FN keys.
// Internally, we are using:
// vt220, xterm-vt200, xterm-xf86-v44, xterm-new, mgt, screen
// See: https://invisible-island.net/xterm/xterm-function-keys.html
// For linux OS console (CTRL+ALT+FN), who do not belong to any
// real standard.
// See: https://github.com/ArthurSonzogni/FTXUI/issues/685
{"\x1B[[A", "\x1BOP"}, // F1
{"\x1B[[B", "\x1BOQ"}, // F2
{"\x1B[[C", "\x1BOR"}, // F3
{"\x1B[[D", "\x1BOS"}, // F4
{"\x1B[[E", "\x1B[15~"}, // F5
// xterm-r5, xterm-r6, rxvt
{"\x1B[11~", "\x1BOP"}, // F1
{"\x1B[12~", "\x1BOQ"}, // F2
{"\x1B[13~", "\x1BOR"}, // F3
{"\x1B[14~", "\x1BOS"}, // F4
// vt100
{"\x1BOt", "\x1B[15~"}, // F5
{"\x1BOu", "\x1B[17~"}, // F6
{"\x1BOv", "\x1B[18~"}, // F7
{"\x1BOl", "\x1B[19~"}, // F8
{"\x1BOw", "\x1B[20~"}, // F9
{"\x1BOx", "\x1B[21~"}, // F10
// scoansi
{"\x1B[M", "\x1BOP"}, // F1
{"\x1B[N", "\x1BOQ"}, // F2
{"\x1B[O", "\x1BOR"}, // F3
{"\x1B[P", "\x1BOS"}, // F4
{"\x1B[Q", "\x1B[15~"}, // F5
{"\x1B[R", "\x1B[17~"}, // F6
{"\x1B[S", "\x1B[18~"}, // F7
{"\x1B[T", "\x1B[19~"}, // F8
{"\x1B[U", "\x1B[20~"}, // F9
{"\x1B[V", "\x1B[21~"}, // F10
{"\x1B[W", "\x1B[23~"}, // F11
{"\x1B[X", "\x1B[24~"}, // F12
};
TerminalInputParser::TerminalInputParser(Sender<Task> out)
@@ -291,9 +332,16 @@ TerminalInputParser::Output TerminalInputParser::ParseCSI() {
continue;
}
if (Current() >= ' ' && Current() <= '~' && Current() != '<') {
// CSI is terminated by a character in the range 0x400x7E
// (ASCII @AZ[\]^_`az{|}~),
if (Current() >= '@' && Current() <= '~' &&
// Note: I don't remember why we exclude '<'
Current() != '<' &&
// To handle F1-F4, we exclude '['.
Current() != '[') {
arguments.push_back(argument);
argument = 0; // NOLINT
switch (Current()) {
case 'M':
return ParseMouse(altered, true, std::move(arguments));

View File

@@ -384,6 +384,41 @@ TEST(Event, Special) {
{str("\x1B[23~"), Event::F11},
{str("\x1B[24~"), Event::F12},
// Function keys for virtual terminal:
{str("\x1B[[A"), Event::F1},
{str("\x1B[[B"), Event::F2},
{str("\x1B[[C"), Event::F3},
{str("\x1B[[D"), Event::F4},
{str("\x1B[[E"), Event::F5},
// Function keys for xterm-r5, xterm-r6, rxvt
{str("\x1B[11~"), Event::F1},
{str("\x1B[12~"), Event::F2},
{str("\x1B[13~"), Event::F3},
{str("\x1B[14~"), Event::F4},
// Function keys for vt100
{str("\x1BOt"), Event::F5},
{str("\x1BOu"), Event::F6},
{str("\x1BOv"), Event::F7},
{str("\x1BOl"), Event::F8},
{str("\x1BOw"), Event::F9},
{str("\x1BOx"), Event::F10},
// Function keys for scoansi
{str("\x1B[M"), Event::F1},
{str("\x1B[N"), Event::F2},
{str("\x1B[O"), Event::F3},
{str("\x1B[P"), Event::F4},
{str("\x1B[Q"), Event::F5},
{str("\x1B[R"), Event::F6},
{str("\x1B[S"), Event::F7},
{str("\x1B[T"), Event::F8},
{str("\x1B[U"), Event::F9},
{str("\x1B[V"), Event::F10},
{str("\x1B[W"), Event::F11},
{str("\x1B[X"), Event::F12},
// Page up and down:
{str("\x1B[5~"), Event::PageUp},
{str("\x1B[6~"), Event::PageDown},

View File

@@ -29,6 +29,19 @@ static void BencharkBasic(benchmark::State& state) {
}
BENCHMARK(BencharkBasic)->DenseRange(0, 256, 16);
static void BencharkText(benchmark::State& state) {
while (state.KeepRunning()) {
std::string content = " world ";
for (int i = 0; i < state.range(0); ++i) {
content += content;
}
auto document = paragraph(content);
Screen screen(200, 200);
Render(screen, document);
}
}
BENCHMARK(BencharkText)->DenseRange(0, 10, 1);
} // namespace ftxui
// Copyright 2021 Arthur Sonzogni. All rights reserved.

View File

@@ -0,0 +1,72 @@
#include <cstdint> // for uint8_t
#include <memory> // for make_shared
#include <string> // for string
#include <utility> // for move
#include "ftxui/dom/elements.hpp" // for Element, Decorator, hyperlink
#include "ftxui/dom/node_decorator.hpp" // for NodeDecorator
#include "ftxui/screen/box.hpp" // for Box
#include "ftxui/screen/screen.hpp" // for Screen, Pixel
namespace ftxui {
class Hyperlink : public NodeDecorator {
public:
Hyperlink(Element child, std::string link)
: NodeDecorator(std::move(child)), link_(link) {}
void Render(Screen& screen) override {
uint8_t hyperlink_id = screen.RegisterHyperlink(link_);
for (int y = box_.y_min; y <= box_.y_max; ++y) {
for (int x = box_.x_min; x <= box_.x_max; ++x) {
screen.PixelAt(x, y).hyperlink = hyperlink_id;
}
}
NodeDecorator::Render(screen);
}
std::string link_;
};
/// @brief Make the rendered area clickable using a web browser.
/// The link will be opened when the user click on it.
/// This is supported only on a limited set of terminal emulator.
/// List: https://github.com/Alhadis/OSC8-Adoption/
/// @param link The link
/// @param child The input element.
/// @return The output element with the link.
/// @ingroup dom
///
/// ### Example
///
/// ```cpp
/// Element document =
/// hyperlink("https://github.com/ArthurSonzogni/FTXUI", "link");
/// ```
Element hyperlink(std::string link, Element child) {
return std::make_shared<Hyperlink>(std::move(child), link);
}
/// @brief Decorate using an hyperlink.
/// The link will be opened when the user click on it.
/// This is supported only on a limited set of terminal emulator.
/// List: https://github.com/Alhadis/OSC8-Adoption/
/// @param link The link to redirect the users to.
/// @return The Decorator applying the hyperlink.
/// @ingroup dom
///
/// ### Example
///
/// ```cpp
/// Element document =
/// text("red") | hyperlink("https://github.com/Arthursonzogni/FTXUI");
/// ```
Decorator hyperlink(std::string link) {
return [link](Element child) { return hyperlink(link, std::move(child)); };
}
} // namespace ftxui
// Copyright 2023 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@@ -0,0 +1,43 @@
#include <gtest/gtest.h> // for Test, EXPECT_EQ, Message, TestPartResult, TestInfo (ptr only), TEST
#include <string> // for allocator, string
#include "ftxui/dom/elements.hpp" // for text, hyperlink, operator|, Element, hbox
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/screen.hpp" // for Screen, Pixel
namespace ftxui {
TEST(HyperlinkTest, Basic) {
auto element = hbox({
text("text 1") | hyperlink("https://a.com"),
text("text 2") | hyperlink("https://b.com"),
text("text 3"),
text("text 4") | hyperlink("https://c.com"),
});
Screen screen(6 * 4, 1);
Render(screen, element);
EXPECT_EQ(screen.PixelAt(0, 0).hyperlink, 1u);
EXPECT_EQ(screen.PixelAt(5, 0).hyperlink, 1u);
EXPECT_EQ(screen.PixelAt(6, 0).hyperlink, 2u);
EXPECT_EQ(screen.PixelAt(11, 0).hyperlink, 2u);
std::string output = screen.ToString();
EXPECT_EQ(output,
"\x1B]8;;https://a.com\x1B\\"
"text 1"
"\x1B]8;;https://b.com\x1B\\"
"text 2"
"\x1B]8;;\x1B\\"
"text 3"
"\x1B]8;;https://c.com\x1B\\"
"text 4"
"\x1B]8;;\x1B\\");
}
} // namespace ftxui
// Copyright 2023 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@@ -2,6 +2,7 @@
#include <array> // for array
#include <cmath>
#include <cstdint>
#include <string_view> // for literals
#include "ftxui/screen/color_info.hpp" // for GetColorInfo, ColorInfo

View File

@@ -1,7 +1,7 @@
#include <cstdint> // for uint8_t
#include <cstdint> // for size_t
#include <iostream> // for operator<<, stringstream, basic_ostream, flush, cout, ostream
#include <map> // for _Rb_tree_const_iterator, map, operator!=, operator==
#include <memory> // for allocator
#include <memory> // for allocator, allocator_traits<>::value_type
#include <sstream> // IWYU pragma: keep
#include <utility> // for pair
@@ -50,11 +50,13 @@ void WindowsEmulateVT100Terminal() {
#endif
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
void UpdatePixelStyle(std::stringstream& ss,
void UpdatePixelStyle(const Screen* screen,
std::stringstream& ss,
Pixel& previous,
const Pixel& next) {
if (next == previous) {
return;
// See https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
if (next.hyperlink != previous.hyperlink) {
ss << "\x1B]8;;" << screen->Hyperlink(next.hyperlink) << "\x1B\\";
}
if ((!next.bold && previous.bold) || //
@@ -435,20 +437,20 @@ std::string Screen::ToString() {
for (int y = 0; y < dimy_; ++y) {
if (y != 0) {
UpdatePixelStyle(ss, previous_pixel, final_pixel);
UpdatePixelStyle(this, ss, previous_pixel, final_pixel);
ss << "\r\n";
}
bool previous_fullwidth = false;
for (const auto& pixel : pixels_[y]) {
if (!previous_fullwidth) {
UpdatePixelStyle(ss, previous_pixel, pixel);
UpdatePixelStyle(this, ss, previous_pixel, pixel);
ss << pixel.character;
}
previous_fullwidth = (string_width(pixel.character) == 2);
}
}
UpdatePixelStyle(ss, previous_pixel, final_pixel);
UpdatePixelStyle(this, ss, previous_pixel, final_pixel);
return ss.str();
}
@@ -517,6 +519,10 @@ void Screen::Clear() {
}
cursor_.x = dimx_ - 1;
cursor_.y = dimy_ - 1;
hyperlinks_ = {
"",
};
}
// clang-format off
@@ -545,9 +551,28 @@ void Screen::ApplyShader() {
}
}
}
// clang-format on
uint8_t Screen::RegisterHyperlink(std::string link) {
for (size_t i = 0; i < hyperlinks_.size(); ++i) {
if (hyperlinks_[i] == link) {
return i;
}
}
if (hyperlinks_.size() == 255) {
return 0;
}
hyperlinks_.push_back(link);
return hyperlinks_.size() - 1;
}
const std::string& Screen::Hyperlink(uint8_t id) const {
if (id >= hyperlinks_.size()) {
return hyperlinks_[0];
}
return hyperlinks_[id];
}
} // namespace ftxui
// Copyright 2020 Arthur Sonzogni. All rights reserved.

View File

@@ -1480,7 +1480,7 @@ const std::array<WordBreakPropertyInterval, 1288> g_word_break_intervals = {{
// Find a codepoint inside a sorted list of Interval.
template <size_t N>
bool Bisearch(uint32_t ucs, const std::array<Interval, N> table) {
bool Bisearch(uint32_t ucs, const std::array<Interval, N>& table) {
if (ucs < table.front().first || ucs > table.back().last) { // NOLINT
return false;
}
@@ -1503,7 +1503,7 @@ bool Bisearch(uint32_t ucs, const std::array<Interval, N> table) {
// Find a value inside a sorted list of Interval + property.
template <class C, size_t N>
bool Bisearch(uint32_t ucs, const std::array<C, N> table, C* out) {
bool Bisearch(uint32_t ucs, const std::array<C, N>& table, C* out) {
if (ucs < table.front().first || ucs > table.back().last) { // NOLINT
return false;
}

View File

@@ -1,4 +1,4 @@
// Copyright 2022 Arthur Sonzogni. All rights reserved.
// Copyright 2023 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.