Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1186 Make compatible with ftxui 5.0.0 #1188

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/mon/mon_tui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ target_include_directories(${PROJECT_NAME}
PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>)

target_compile_definitions(${PROJECT_NAME}
PRIVATE $<$<BOOL:${MSVC}>:PCRE_STATIC;_UNICODE>)
PRIVATE
$<$<BOOL:${MSVC}>:PCRE_STATIC;_UNICODE>
FTXUI_VERSION_MAJOR=${ftxui_VERSION_MAJOR}
)

create_targets_protobuf()

Expand Down
22 changes: 20 additions & 2 deletions app/mon/mon_tui/src/tui/style_sheet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ struct StyleSheet
default: return nothing;
}
};
sheet.tab.entries.transform = [](EntryState state)
#if FTXUI_VERSION_MAJOR >= 5
sheet.tab.entries_option.transform =
#else
sheet.tab.entries.transform =
#endif
[](EntryState state)
{
if(state.active)
{
Expand All @@ -110,7 +115,11 @@ struct StyleSheet
}
return text(state.label);
};
#if FTXUI_VERSION_MAJOR >= 5
sheet.tab.direction = Direction::Right;
#else
sheet.tab.direction = MenuOption::Right;
#endif
sheet.tab.elements_prefix = [] {
return text(" ");
};
Expand Down Expand Up @@ -202,14 +211,23 @@ struct StyleSheet
default: return nothing;
}
};
sheet.tab.entries.transform = [](EntryState state) {
#if FTXUI_VERSION_MAJOR >= 5
sheet.tab.entries_option.transform =
#else
sheet.tab.entries.transform =
#endif
[](EntryState state) {
if(state.active)
{
return text(state.label) | inverted;
}
return text(state.label);
};
#if FTXUI_VERSION_MAJOR >= 5
sheet.tab.direction = Direction::Right;
#else
sheet.tab.direction = MenuOption::Right;
#endif
sheet.tab.elements_prefix = [] {
return text(" ");
};
Expand Down
9 changes: 9 additions & 0 deletions thirdparty/build-ftxui.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
option(FTXUI_BUILD_EXAMPLES "Set to ON to build examples" OFF)

add_subdirectory(thirdparty/ftxui EXCLUDE_FROM_ALL)

# Set ftxui_VERSION_MAJOR, because it's only defined in the subdirectory scope and we cannot access it
# Reading it automatically is less error prone than setting itt by hand
file(READ thirdparty/ftxui/CMakeLists.txt content)
if(content MATCHES "VERSION ([0-9]+)\\.[0-9]+\\.[0-9]+")
set(ftxui_VERSION_MAJOR "${CMAKE_MATCH_1}")
else()
message(FATAL_ERROR "Couldn't read version info")
endif()
Loading