mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 02:34:21 +08:00
Casting and documentation fixes (#608)
Add `-wDocumentation` option. Fix the documentation. Fix c++20/c++17 confusion in tests. Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
parent
eed7e2ea70
commit
896c0f2f6e
@ -1,5 +1,7 @@
|
|||||||
---
|
---
|
||||||
Checks: "*,
|
Checks: "*,
|
||||||
|
-*-narrowing-conversions
|
||||||
|
-*-uppercase-literal-suffix,
|
||||||
-abseil-*,
|
-abseil-*,
|
||||||
-altera-*,
|
-altera-*,
|
||||||
-android-*,
|
-android-*,
|
||||||
@ -7,7 +9,6 @@ Checks: "*,
|
|||||||
-cppcoreguidelines-non-private-member-variables-in-classes,
|
-cppcoreguidelines-non-private-member-variables-in-classes,
|
||||||
-fuchsia-*,
|
-fuchsia-*,
|
||||||
-google-*,
|
-google-*,
|
||||||
-hicpp-uppercase-literal-suffix,
|
|
||||||
-llvm*,
|
-llvm*,
|
||||||
-misc-no-recursion,
|
-misc-no-recursion,
|
||||||
-misc-non-private-member-variables-in-classes,
|
-misc-non-private-member-variables-in-classes,
|
||||||
@ -19,7 +20,6 @@ Checks: "*,
|
|||||||
-readability-implicit-bool-conversion,
|
-readability-implicit-bool-conversion,
|
||||||
-readability-non-const-parameter,
|
-readability-non-const-parameter,
|
||||||
-readability-static-accessed-through-instance,
|
-readability-static-accessed-through-instance,
|
||||||
-readability-uppercase-literal-suffix,
|
|
||||||
-zircon-*,
|
-zircon-*,
|
||||||
"
|
"
|
||||||
WarningsAsErrors: ''
|
WarningsAsErrors: ''
|
||||||
|
@ -5,21 +5,18 @@ endif()
|
|||||||
set(CMAKE_C_COMPILER clang)
|
set(CMAKE_C_COMPILER clang)
|
||||||
set(CMAKE_CXX_COMPILER clang++)
|
set(CMAKE_CXX_COMPILER clang++)
|
||||||
|
|
||||||
function(fuzz name)
|
function(fuzz source)
|
||||||
|
set(name "ftxui-${source}")
|
||||||
add_executable(${name}
|
add_executable(${name}
|
||||||
src/ftxui/component/${name}.cpp
|
src/ftxui/component/${source}.cpp
|
||||||
)
|
)
|
||||||
target_include_directories(${name}
|
target_include_directories(${name} PRIVATE src)
|
||||||
PRIVATE src
|
target_link_libraries(${name} PRIVATE component)
|
||||||
)
|
target_compile_options(${name} PRIVATE -fsanitize=fuzzer,address)
|
||||||
target_link_libraries(${name}
|
target_link_libraries(${name} PRIVATE -fsanitize=fuzzer,address)
|
||||||
PRIVATE component
|
set_target_properties(${name} PROPERTIES
|
||||||
)
|
CXX_STANDARD 20
|
||||||
target_compile_options(${name}
|
CXX_EXTENSIONS OFF
|
||||||
PRIVATE -fsanitize=fuzzer,address
|
|
||||||
)
|
|
||||||
target_link_libraries(${name}
|
|
||||||
PRIVATE -fsanitize=fuzzer,address
|
|
||||||
)
|
)
|
||||||
endfunction(fuzz)
|
endfunction(fuzz)
|
||||||
|
|
||||||
|
@ -68,14 +68,25 @@ function(ftxui_set_options library)
|
|||||||
target_compile_definitions(${library} PRIVATE UNICODE _UNICODE)
|
target_compile_definitions(${library} PRIVATE UNICODE _UNICODE)
|
||||||
else()
|
else()
|
||||||
target_compile_options(${library} PRIVATE "-Wall")
|
target_compile_options(${library} PRIVATE "-Wall")
|
||||||
target_compile_options(${library} PRIVATE "-Wextra")
|
|
||||||
target_compile_options(${library} PRIVATE "-pedantic")
|
|
||||||
target_compile_options(${library} PRIVATE "-Werror")
|
target_compile_options(${library} PRIVATE "-Werror")
|
||||||
target_compile_options(${library} PRIVATE "-Wmissing-declarations")
|
target_compile_options(${library} PRIVATE "-Wextra")
|
||||||
|
|
||||||
|
target_compile_options(${library} PRIVATE "-Wcast-align")
|
||||||
target_compile_options(${library} PRIVATE "-Wdeprecated")
|
target_compile_options(${library} PRIVATE "-Wdeprecated")
|
||||||
|
target_compile_options(${library} PRIVATE "-Wmissing-declarations")
|
||||||
|
target_compile_options(${library} PRIVATE "-Wnon-virtual-dtor")
|
||||||
|
target_compile_options(${library} PRIVATE "-Wnull-dereference")
|
||||||
|
target_compile_options(${library} PRIVATE "-Woverloaded-virtual")
|
||||||
|
target_compile_options(${library} PRIVATE "-Wpedantic")
|
||||||
target_compile_options(${library} PRIVATE "-Wshadow")
|
target_compile_options(${library} PRIVATE "-Wshadow")
|
||||||
|
target_compile_options(${library} PRIVATE "-Wunused")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
target_compile_options(${library} PRIVATE "-Wdocumentation")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if (FTXUI_MICROSOFT_TERMINAL_FALLBACK)
|
if (FTXUI_MICROSOFT_TERMINAL_FALLBACK)
|
||||||
target_compile_definitions(${library}
|
target_compile_definitions(${library}
|
||||||
PRIVATE "FTXUI_MICROSOFT_TERMINAL_FALLBACK")
|
PRIVATE "FTXUI_MICROSOFT_TERMINAL_FALLBACK")
|
||||||
|
@ -57,8 +57,15 @@ target_link_libraries(ftxui-tests
|
|||||||
target_include_directories(ftxui-tests
|
target_include_directories(ftxui-tests
|
||||||
PRIVATE src
|
PRIVATE src
|
||||||
)
|
)
|
||||||
ftxui_set_options(ftxui-tests)
|
set_target_properties(ftxui-tests PROPERTIES
|
||||||
target_compile_features(ftxui-tests PUBLIC cxx_std_20)
|
CXX_STANDARD 20
|
||||||
|
CXX_EXTENSIONS OFF
|
||||||
|
)
|
||||||
|
|
||||||
|
if (FTXUI_MICROSOFT_TERMINAL_FALLBACK)
|
||||||
|
target_compile_definitions(ftxui-tests
|
||||||
|
PRIVATE "FTXUI_MICROSOFT_TERMINAL_FALLBACK")
|
||||||
|
endif()
|
||||||
|
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
gtest_discover_tests(ftxui-tests
|
gtest_discover_tests(ftxui-tests
|
||||||
|
@ -9,7 +9,7 @@ function(example name)
|
|||||||
file(RELATIVE_PATH dir ${EXAMPLES_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
file(RELATIVE_PATH dir ${EXAMPLES_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
set_property(GLOBAL APPEND PROPERTY FTXUI::EXAMPLES ${dir}/${name})
|
set_property(GLOBAL APPEND PROPERTY FTXUI::EXAMPLES ${dir}/${name})
|
||||||
set_target_properties(ftxui_example_${name} PROPERTIES
|
set_target_properties(ftxui_example_${name} PROPERTIES
|
||||||
CXX_STANDARD 20
|
CXX_STANDARD 17
|
||||||
)
|
)
|
||||||
endfunction(example)
|
endfunction(example)
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ bool ComponentBase::OnEvent(Event event) { // NOLINT
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Called in response to an animation event.
|
/// @brief Called in response to an animation event.
|
||||||
/// @param animation_params the parameters of the animation
|
/// @param params the parameters of the animation
|
||||||
/// The default implementation dispatch the event to every child.
|
/// The default implementation dispatch the event to every child.
|
||||||
/// @ingroup component
|
/// @ingroup component
|
||||||
void ComponentBase::OnAnimation(animation::Params& params) {
|
void ComponentBase::OnAnimation(animation::Params& params) {
|
||||||
@ -166,7 +166,7 @@ bool ComponentBase::Focused() const {
|
|||||||
/// @brief Make the |child| to be the "active" one.
|
/// @brief Make the |child| to be the "active" one.
|
||||||
/// @param child the child to become active.
|
/// @param child the child to become active.
|
||||||
/// @ingroup component
|
/// @ingroup component
|
||||||
void ComponentBase::SetActiveChild(ComponentBase* /*child*/) {}
|
void ComponentBase::SetActiveChild([[maybe_unused]] ComponentBase* child) {}
|
||||||
|
|
||||||
/// @brief Make the |child| to be the "active" one.
|
/// @brief Make the |child| to be the "active" one.
|
||||||
/// @param child the child to become active.
|
/// @param child the child to become active.
|
||||||
@ -187,7 +187,7 @@ void ComponentBase::TakeFocus() {
|
|||||||
|
|
||||||
/// @brief Take the CapturedMouse if available. There is only one component of
|
/// @brief Take the CapturedMouse if available. There is only one component of
|
||||||
/// them. It represents a component taking priority over others.
|
/// them. It represents a component taking priority over others.
|
||||||
/// @param event
|
/// @param event The event
|
||||||
/// @ingroup component
|
/// @ingroup component
|
||||||
CapturedMouse ComponentBase::CaptureMouse(const Event& event) { // NOLINT
|
CapturedMouse ComponentBase::CaptureMouse(const Event& event) { // NOLINT
|
||||||
if (event.screen_) {
|
if (event.screen_) {
|
||||||
|
@ -96,8 +96,7 @@ MenuOption GeneratorMenuOption(const char* data, size_t size) {
|
|||||||
MenuOption option;
|
MenuOption option;
|
||||||
option.underline = GeneratorUnderlineOption(data, size);
|
option.underline = GeneratorUnderlineOption(data, size);
|
||||||
option.entries = GeneratorMenuEntryOption(data, size);
|
option.entries = GeneratorMenuEntryOption(data, size);
|
||||||
option.direction =
|
option.direction = static_cast<Direction>(GeneratorInt(data, size) % 4);
|
||||||
static_cast<MenuOption::Direction>(GeneratorInt(data, size) % 4);
|
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ Component Dropdown(ConstStringListRef entries, int* selected) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Element Render() override {
|
Element Render() override {
|
||||||
*selected_ = util::clamp(*selected_, 0, (int)entries_.size() - 1);
|
*selected_ = util::clamp(*selected_, 0, int(entries_.size()) - 1);
|
||||||
title_ = entries_[static_cast<size_t>(*selected_)];
|
title_ = entries_[static_cast<size_t>(*selected_)];
|
||||||
if (show_) {
|
if (show_) {
|
||||||
const int max_height = 12;
|
const int max_height = 12;
|
||||||
|
@ -26,8 +26,8 @@ void Post(std::function<void()> f) {
|
|||||||
|
|
||||||
/// @brief Wrap a component. Gives the ability to know if it is hovered by the
|
/// @brief Wrap a component. Gives the ability to know if it is hovered by the
|
||||||
/// mouse.
|
/// mouse.
|
||||||
/// @param component: The wrapped component.
|
/// @param component The wrapped component.
|
||||||
/// @param hover: The value to reflect whether the component is hovered or not.
|
/// @param hover The value to reflect whether the component is hovered or not.
|
||||||
/// @ingroup component
|
/// @ingroup component
|
||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
@ -68,10 +68,10 @@ Component Hoverable(Component component, bool* hover) {
|
|||||||
return Make<Impl>(component, hover);
|
return Make<Impl>(component, hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Wrap a component. Gives the ability to know if it is hovered by the
|
/// @brief Wrap a component. Uses callbacks.
|
||||||
/// mouse.
|
/// @param component The wrapped component.
|
||||||
/// @param component: The wrapped component.
|
/// @param on_enter Callback OnEnter
|
||||||
/// @param hover: The value to reflect whether the component is hovered or not.
|
/// @param on_leave Callback OnLeave
|
||||||
/// @ingroup component
|
/// @ingroup component
|
||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
@ -126,7 +126,7 @@ Component Hoverable(Component component,
|
|||||||
|
|
||||||
/// @brief Wrap a component. Gives the ability to know if it is hovered by the
|
/// @brief Wrap a component. Gives the ability to know if it is hovered by the
|
||||||
/// mouse.
|
/// mouse.
|
||||||
/// @param hover: The value to reflect whether the component is hovered or not.
|
/// @param hover The value to reflect whether the component is hovered or not.
|
||||||
/// @ingroup component
|
/// @ingroup component
|
||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
|
@ -187,7 +187,7 @@ class InputBase : public ComponentBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event == Event::ArrowRight &&
|
if (event == Event::ArrowRight &&
|
||||||
cursor_position() < (int)content_->size()) {
|
cursor_position() < static_cast<int>(content_->size())) {
|
||||||
cursor_position()++;
|
cursor_position()++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -242,7 +242,7 @@ class InputBase : public ComponentBase {
|
|||||||
|
|
||||||
void HandleRightCtrl() {
|
void HandleRightCtrl() {
|
||||||
auto properties = Utf8ToWordBreakProperty(*content_);
|
auto properties = Utf8ToWordBreakProperty(*content_);
|
||||||
const int max = (int)properties.size();
|
const int max = properties.size();
|
||||||
|
|
||||||
// Move right, as long as right is not a word character.
|
// Move right, as long as right is not a word character.
|
||||||
while (cursor_position() < max &&
|
while (cursor_position() < max &&
|
||||||
@ -280,7 +280,7 @@ class InputBase : public ComponentBase {
|
|||||||
size_t original_cell = 0;
|
size_t original_cell = 0;
|
||||||
for (size_t i = 0; i < mapping.size(); i++) {
|
for (size_t i = 0; i < mapping.size(); i++) {
|
||||||
if (mapping[i] == original_glyph) {
|
if (mapping[i] == original_glyph) {
|
||||||
original_cell = (int)i;
|
original_cell = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,8 +289,8 @@ class InputBase : public ComponentBase {
|
|||||||
}
|
}
|
||||||
const int target_cell =
|
const int target_cell =
|
||||||
int(original_cell) + event.mouse().x - cursor_box_.x_min;
|
int(original_cell) + event.mouse().x - cursor_box_.x_min;
|
||||||
int target_glyph = target_cell < (int)mapping.size() ? mapping[target_cell]
|
int target_glyph = target_cell < int(mapping.size()) ? mapping[target_cell]
|
||||||
: (int)mapping.size();
|
: int(mapping.size());
|
||||||
target_glyph = util::clamp(target_glyph, 0, GlyphCount(*content_));
|
target_glyph = util::clamp(target_glyph, 0, GlyphCount(*content_));
|
||||||
if (cursor_position() != target_glyph) {
|
if (cursor_position() != target_glyph) {
|
||||||
cursor_position() = target_glyph;
|
cursor_position() = target_glyph;
|
||||||
|
@ -356,7 +356,7 @@ class MenuBase : public ComponentBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UpdateColorTarget() {
|
void UpdateColorTarget() {
|
||||||
if (size() != (int)animation_background_.size()) {
|
if (size() != int(animation_background_.size())) {
|
||||||
animation_background_.resize(size());
|
animation_background_.resize(size());
|
||||||
animation_foreground_.resize(size());
|
animation_foreground_.resize(size());
|
||||||
animator_background_.clear();
|
animator_background_.clear();
|
||||||
@ -518,7 +518,7 @@ Component Menu(ConstStringListRef entries,
|
|||||||
/// @brief An horizontal list of elements. The user can navigate through them.
|
/// @brief An horizontal list of elements. The user can navigate through them.
|
||||||
/// @param entries The list of selectable entries to display.
|
/// @param entries The list of selectable entries to display.
|
||||||
/// @param selected Reference the selected entry.
|
/// @param selected Reference the selected entry.
|
||||||
/// @param See also |Menu|.
|
/// See also |Menu|.
|
||||||
/// @ingroup component
|
/// @ingroup component
|
||||||
Component Toggle(ConstStringListRef entries, int* selected) {
|
Component Toggle(ConstStringListRef entries, int* selected) {
|
||||||
return Menu(entries, selected, MenuOption::Toggle());
|
return Menu(entries, selected, MenuOption::Toggle());
|
||||||
|
@ -135,7 +135,7 @@ class ResizableSplitBase : public ComponentBase {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
/// @brief A split in between two components.
|
/// @brief A split in between two components.
|
||||||
/// @param options: all the parameters.
|
/// @param options all the parameters.
|
||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
///
|
///
|
||||||
|
@ -309,7 +309,7 @@ Component Slider(ConstStringRef label,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief A slider in any direction.
|
/// @brief A slider in any direction.
|
||||||
/// @param option The options
|
/// @param options The options
|
||||||
/// ### Example
|
/// ### Example
|
||||||
///
|
///
|
||||||
/// ```cpp
|
/// ```cpp
|
||||||
|
@ -51,7 +51,7 @@ unsigned char TerminalInputParser::Current() {
|
|||||||
|
|
||||||
bool TerminalInputParser::Eat() {
|
bool TerminalInputParser::Eat() {
|
||||||
position_++;
|
position_++;
|
||||||
return position_ < (int)pending_.size();
|
return position_ < static_cast<int>(pending_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerminalInputParser::Send(TerminalInputParser::Output output) {
|
void TerminalInputParser::Send(TerminalInputParser::Output output) {
|
||||||
|
@ -321,11 +321,11 @@ void Canvas::DrawPointEllipse(int x,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Draw an ellipse made of braille dots.
|
/// @brief Draw an ellipse made of braille dots.
|
||||||
/// @param x the x coordinate of the center of the ellipse.
|
/// @param x1 the x coordinate of the center of the ellipse.
|
||||||
/// @param y the y coordinate of the center of the ellipse.
|
/// @param y1 the y coordinate of the center of the ellipse.
|
||||||
/// @param r1 the radius of the ellipse along the x axis.
|
/// @param r1 the radius of the ellipse along the x axis.
|
||||||
/// @param r2 the radius of the ellipse along the y axis.
|
/// @param r2 the radius of the ellipse along the y axis.
|
||||||
/// @param style the style of the ellipse.
|
/// @param s the style of the ellipse.
|
||||||
void Canvas::DrawPointEllipse(int x1,
|
void Canvas::DrawPointEllipse(int x1,
|
||||||
int y1,
|
int y1,
|
||||||
int r1,
|
int r1,
|
||||||
@ -361,8 +361,8 @@ void Canvas::DrawPointEllipse(int x1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Draw a filled ellipse made of braille dots.
|
/// @brief Draw a filled ellipse made of braille dots.
|
||||||
/// @param x the x coordinate of the center of the ellipse.
|
/// @param x1 the x coordinate of the center of the ellipse.
|
||||||
/// @param y the y coordinate of the center of the ellipse.
|
/// @param y1 the y coordinate of the center of the ellipse.
|
||||||
/// @param r1 the radius of the ellipse along the x axis.
|
/// @param r1 the radius of the ellipse along the x axis.
|
||||||
/// @param r2 the radius of the ellipse along the y axis.
|
/// @param r2 the radius of the ellipse along the y axis.
|
||||||
void Canvas::DrawPointEllipseFilled(int x1, int y1, int r1, int r2) {
|
void Canvas::DrawPointEllipseFilled(int x1, int y1, int r1, int r2) {
|
||||||
@ -370,8 +370,8 @@ void Canvas::DrawPointEllipseFilled(int x1, int y1, int r1, int r2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Draw a filled ellipse made of braille dots.
|
/// @brief Draw a filled ellipse made of braille dots.
|
||||||
/// @param x the x coordinate of the center of the ellipse.
|
/// @param x1 the x coordinate of the center of the ellipse.
|
||||||
/// @param y the y coordinate of the center of the ellipse.
|
/// @param y1 the y coordinate of the center of the ellipse.
|
||||||
/// @param r1 the radius of the ellipse along the x axis.
|
/// @param r1 the radius of the ellipse along the x axis.
|
||||||
/// @param r2 the radius of the ellipse along the y axis.
|
/// @param r2 the radius of the ellipse along the y axis.
|
||||||
/// @param color the color of the ellipse.
|
/// @param color the color of the ellipse.
|
||||||
@ -385,11 +385,11 @@ void Canvas::DrawPointEllipseFilled(int x1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Draw a filled ellipse made of braille dots.
|
/// @brief Draw a filled ellipse made of braille dots.
|
||||||
/// @param x the x coordinate of the center of the ellipse.
|
/// @param x1 the x coordinate of the center of the ellipse.
|
||||||
/// @param y the y coordinate of the center of the ellipse.
|
/// @param y1 the y coordinate of the center of the ellipse.
|
||||||
/// @param r1 the radius of the ellipse along the x axis.
|
/// @param r1 the radius of the ellipse along the x axis.
|
||||||
/// @param r2 the radius of the ellipse along the y axis.
|
/// @param r2 the radius of the ellipse along the y axis.
|
||||||
/// @param style the style of the ellipse.
|
/// @param s the style of the ellipse.
|
||||||
void Canvas::DrawPointEllipseFilled(int x1,
|
void Canvas::DrawPointEllipseFilled(int x1,
|
||||||
int y1,
|
int y1,
|
||||||
int r1,
|
int r1,
|
||||||
@ -410,11 +410,11 @@ void Canvas::DrawPointEllipseFilled(int x1,
|
|||||||
e2 = 2 * err;
|
e2 = 2 * err;
|
||||||
if (e2 >= dx) {
|
if (e2 >= dx) {
|
||||||
x++;
|
x++;
|
||||||
err += dx += 2 * (long)r2 * r2; // NOLINT
|
err += dx += 2 * r2 * r2;
|
||||||
}
|
}
|
||||||
if (e2 <= dy) {
|
if (e2 <= dy) {
|
||||||
y++;
|
y++;
|
||||||
err += dy += 2 * (long)r1 * r1; // NOLINT
|
err += dy += 2 * r1 * r1;
|
||||||
}
|
}
|
||||||
} while (x <= 0);
|
} while (x <= 0);
|
||||||
|
|
||||||
@ -631,7 +631,7 @@ void Canvas::DrawBlockCircleFilled(int x,
|
|||||||
/// @param x the x coordinate of the center of the circle.
|
/// @param x the x coordinate of the center of the circle.
|
||||||
/// @param y the y coordinate of the center of the circle.
|
/// @param y the y coordinate of the center of the circle.
|
||||||
/// @param radius the radius of the circle.
|
/// @param radius the radius of the circle.
|
||||||
/// @param style the style of the circle.
|
/// @param s the style of the circle.
|
||||||
void Canvas::DrawBlockCircleFilled(int x,
|
void Canvas::DrawBlockCircleFilled(int x,
|
||||||
int y,
|
int y,
|
||||||
int radius,
|
int radius,
|
||||||
@ -664,11 +664,11 @@ void Canvas::DrawBlockEllipse(int x,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Draw an ellipse made of block characters.
|
/// @brief Draw an ellipse made of block characters.
|
||||||
/// @param x the x coordinate of the center of the ellipse.
|
/// @param x1 the x coordinate of the center of the ellipse.
|
||||||
/// @param y the y coordinate of the center of the ellipse.
|
/// @param y1 the y coordinate of the center of the ellipse.
|
||||||
/// @param r1 the radius of the ellipse along the x axis.
|
/// @param r1 the radius of the ellipse along the x axis.
|
||||||
/// @param r2 the radius of the ellipse along the y axis.
|
/// @param r2 the radius of the ellipse along the y axis.
|
||||||
/// @param style the style of the ellipse.
|
/// @param s the style of the ellipse.
|
||||||
void Canvas::DrawBlockEllipse(int x1,
|
void Canvas::DrawBlockEllipse(int x1,
|
||||||
int y1,
|
int y1,
|
||||||
int r1,
|
int r1,
|
||||||
@ -730,11 +730,11 @@ void Canvas::DrawBlockEllipseFilled(int x,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Draw a filled ellipse made of block characters.
|
/// @brief Draw a filled ellipse made of block characters.
|
||||||
/// @param x the x coordinate of the center of the ellipse.
|
/// @param x1 the x coordinate of the center of the ellipse.
|
||||||
/// @param y the y coordinate of the center of the ellipse.
|
/// @param y1 the y coordinate of the center of the ellipse.
|
||||||
/// @param r1 the radius of the ellipse along the x axis.
|
/// @param r1 the radius of the ellipse along the x axis.
|
||||||
/// @param r2 the radius of the ellipse along the y axis.
|
/// @param r2 the radius of the ellipse along the y axis.
|
||||||
/// @param style the style of the ellipse.
|
/// @param s the style of the ellipse.
|
||||||
void Canvas::DrawBlockEllipseFilled(int x1,
|
void Canvas::DrawBlockEllipseFilled(int x1,
|
||||||
int y1,
|
int y1,
|
||||||
int r1,
|
int r1,
|
||||||
|
@ -328,8 +328,8 @@ void Compute3(Global& global) {
|
|||||||
line = Line();
|
line = Line();
|
||||||
}
|
}
|
||||||
|
|
||||||
block.line = (int)lines.size();
|
block.line = lines.size();
|
||||||
block.line_position = (int)line.blocks.size();
|
block.line_position = line.blocks.size();
|
||||||
line.blocks.push_back(&block);
|
line.blocks.push_back(&block);
|
||||||
x += block.min_size_x + global.config.gap_x;
|
x += block.min_size_x + global.config.gap_x;
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,10 @@ Decorator focusPositionRelative(float x, float y) {
|
|||||||
requirement_.selection = Requirement::Selection::NORMAL;
|
requirement_.selection = Requirement::Selection::NORMAL;
|
||||||
|
|
||||||
Box& box = requirement_.selected_box;
|
Box& box = requirement_.selected_box;
|
||||||
box.x_min = (int)((float)requirement_.min_x * x_);
|
box.x_min = int(float(requirement_.min_x) * x_);
|
||||||
box.y_min = (int)((float)requirement_.min_y * y_);
|
box.y_min = int(float(requirement_.min_y) * y_);
|
||||||
box.x_max = (int)((float)requirement_.min_x * x_);
|
box.x_max = int(float(requirement_.min_x) * x_);
|
||||||
box.y_max = (int)((float)requirement_.min_y * y_);
|
box.y_max = int(float(requirement_.min_y) * y_);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -99,9 +99,9 @@ class Gauge : public Node {
|
|||||||
// Draw the progress bar horizontally.
|
// Draw the progress bar horizontally.
|
||||||
{
|
{
|
||||||
const float progress = invert ? 1.F - progress_ : progress_;
|
const float progress = invert ? 1.F - progress_ : progress_;
|
||||||
const float limit =
|
const auto limit =
|
||||||
(float)box_.x_min + progress * (float)(box_.x_max - box_.x_min + 1);
|
float(box_.x_min) + progress * float(box_.x_max - box_.x_min + 1);
|
||||||
const int limit_int = (int)limit;
|
const int limit_int = static_cast<int>(limit);
|
||||||
int x = box_.x_min;
|
int x = box_.x_min;
|
||||||
while (x < limit_int) {
|
while (x < limit_int) {
|
||||||
screen.at(x++, y) = charset_horizontal[9]; // NOLINT
|
screen.at(x++, y) = charset_horizontal[9]; // NOLINT
|
||||||
@ -130,8 +130,8 @@ class Gauge : public Node {
|
|||||||
{
|
{
|
||||||
const float progress = invert ? progress_ : 1.F - progress_;
|
const float progress = invert ? progress_ : 1.F - progress_;
|
||||||
const float limit =
|
const float limit =
|
||||||
(float)box_.y_min + progress * (float)(box_.y_max - box_.y_min + 1);
|
float(box_.y_min) + progress * float(box_.y_max - box_.y_min + 1);
|
||||||
const int limit_int = (int)limit;
|
const int limit_int = static_cast<int>(limit);
|
||||||
int y = box_.y_min;
|
int y = box_.y_min;
|
||||||
while (y < limit_int) {
|
while (y < limit_int) {
|
||||||
screen.at(x, y++) = charset_vertical[8]; // NOLINT
|
screen.at(x, y++) = charset_vertical[8]; // NOLINT
|
||||||
|
@ -33,12 +33,12 @@ int Integrate(std::vector<int>& elements) {
|
|||||||
class GridBox : public Node {
|
class GridBox : public Node {
|
||||||
public:
|
public:
|
||||||
explicit GridBox(std::vector<Elements> lines) : lines_(std::move(lines)) {
|
explicit GridBox(std::vector<Elements> lines) : lines_(std::move(lines)) {
|
||||||
y_size = (int)lines_.size();
|
y_size = lines_.size();
|
||||||
for (const auto& line : lines_) {
|
for (const auto& line : lines_) {
|
||||||
x_size = std::max(x_size, (int)line.size());
|
x_size = std::max(x_size, int(line.size()));
|
||||||
}
|
}
|
||||||
for (auto& line : lines_) {
|
for (auto& line : lines_) {
|
||||||
while (line.size() < (size_t)x_size) {
|
while (line.size() < size_t(x_size)) {
|
||||||
line.push_back(filler());
|
line.push_back(filler());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,8 +286,8 @@ Element spinner(int charset_index, size_t image_index) {
|
|||||||
}
|
}
|
||||||
return gauge(float(image_index) * 0.05F); // NOLINT
|
return gauge(float(image_index) * 0.05F); // NOLINT
|
||||||
}
|
}
|
||||||
charset_index %= (int)elements.size();
|
charset_index %= int(elements.size());
|
||||||
image_index %= (int)elements[charset_index].size();
|
image_index %= int(elements[charset_index].size());
|
||||||
std::vector<Element> lines;
|
std::vector<Element> lines;
|
||||||
for (const auto& it : elements[charset_index][image_index]) {
|
for (const auto& it : elements[charset_index][image_index]) {
|
||||||
lines.push_back(text(it));
|
lines.push_back(text(it));
|
||||||
|
@ -59,10 +59,10 @@ Table::Table(std::vector<std::vector<Element>> input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Table::Initialize(std::vector<std::vector<Element>> input) {
|
void Table::Initialize(std::vector<std::vector<Element>> input) {
|
||||||
input_dim_y_ = (int)input.size();
|
input_dim_y_ = input.size();
|
||||||
input_dim_x_ = 0;
|
input_dim_x_ = 0;
|
||||||
for (auto& row : input) {
|
for (auto& row : input) {
|
||||||
input_dim_x_ = std::max(input_dim_x_, (int)row.size());
|
input_dim_x_ = std::max(input_dim_x_, int(row.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
dim_y_ = 2 * input_dim_y_ + 1;
|
dim_y_ = 2 * input_dim_y_ + 1;
|
||||||
|
@ -73,7 +73,7 @@ Terminal::Color ComputeColorSupport() {
|
|||||||
// colors: https://github.com/microsoft/terminal/issues/1040
|
// colors: https://github.com/microsoft/terminal/issues/1040
|
||||||
// As a fallback, assume microsoft terminal are the ones not setting those
|
// As a fallback, assume microsoft terminal are the ones not setting those
|
||||||
// variables, and enable true colors.
|
// variables, and enable true colors.
|
||||||
if (TERM == "" && COLORTERM == "") {
|
if (TERM.empty() && COLORTERM.empty()) {
|
||||||
return Terminal::Color::TrueColor;
|
return Terminal::Color::TrueColor;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user