Support the -pedantic flag.

This commit is contained in:
ArthurSonzogni 2020-02-11 21:44:55 +01:00
parent 5637fa3a93
commit a8fdfafe6a
33 changed files with 81 additions and 85 deletions

View File

@ -76,7 +76,7 @@ foreach(lib screen dom component)
PRIVATE src
)
target_compile_features(${lib} PUBLIC cxx_std_17)
target_compile_options(${lib} PRIVATE -Wall -Werror -Wextra)
target_compile_options(${lib} PRIVATE -Wall -Werror -pedantic -Wextra)
endforeach()
if(FTXUI_ENABLE_INSTALL)

View File

@ -65,14 +65,10 @@ class MyComponent : public Component {
Element Render() override {
return
vbox(
Render(L"menu", menu),
separator(),
Render(L"toggle", toggle),
separator(),
Render(L"checkbox", checkbox_container),
separator(),
Render(L"radiobox", radiobox),
separator(),
Render(L"menu", menu), separator(),
Render(L"toggle", toggle), separator(),
Render(L"checkbox", checkbox_container), separator(),
Render(L"radiobox", radiobox), separator(),
Render(L"input", input) | size(WIDTH, LESS_THAN, 30)
) | border;
}

View File

@ -11,7 +11,7 @@ namespace ftxui {
using Element = std::unique_ptr<Node>;
using Elements = std::vector<Element>;
using Decorator = std::function<Element(Element)>;
using GraphFunction = std::function<std::vector<int>(int,int)>;
using GraphFunction = std::function<std::vector<int>(int, int)>;
// --- Widget ---
Element text(std::wstring text);
@ -83,6 +83,6 @@ TAKE_ANY_ARGS(hbox)
TAKE_ANY_ARGS(dbox)
TAKE_ANY_ARGS(hflow)
}; // namespace ftxui
} // namespace ftxui
#endif /* end of include guard: FTXUI_DOM_ELEMENTS_HPP */

View File

@ -37,6 +37,6 @@ class Node {
void Render(Screen& screen, Node* node);
}; // namespace ftxui
} // namespace ftxui
#endif /* end of include guard: FTXUI_DOM_NODE_HPP */

View File

@ -21,6 +21,6 @@ struct Requirement {
Box selected_box;
};
}; // namespace ftxui
} // namespace ftxui
#endif /* end of include guard: FTXUI_REQUIREMENT_HPP */

View File

@ -12,6 +12,6 @@ struct Box {
static Box Intersection(Box a, Box b);
};
}; // namespace ftxui
} // namespace ftxui
#endif /* end of include guard: FTXUI_SCREEN_BOX_HPP */

View File

@ -35,6 +35,6 @@ enum class Color : uint8_t {
YellowLight = 93,
};
}; // namespace ftxui
} // namespace ftxui
#endif /* end of include guard: FTXUI_COLOR_H_ */

View File

@ -75,6 +75,6 @@ class Screen {
Cursor cursor_;
};
}; // namespace ftxui
} // namespace ftxui
#endif /* end of include guard: FTXUI_SCREEN_SCREEN */

View File

@ -59,7 +59,7 @@ Event ParseCSI(std::function<char()> getchar, std::string& input) {
return Event::Special(input);
// Invalid ESC in CSI.
if (c == '\e')
if (c == '\x1B')
return Event::Special(input);
}
}
@ -68,7 +68,7 @@ Event ParseDCS(std::function<char()> getchar, std::string& input) {
// Parse until the string terminator ST.
while (1) {
input += getchar();
if (input.back() != '\e')
if (input.back() != '\x1B')
continue;
input += getchar();
if (input.back() != '\\')
@ -81,7 +81,7 @@ Event ParseOSC(std::function<char()> getchar, std::string& input) {
// Parse until the string terminator ST.
while (1) {
input += getchar();
if (input.back() != '\e')
if (input.back() != '\x1B')
continue;
input += getchar();
if (input.back() != '\\')
@ -115,7 +115,7 @@ Event Event::GetEvent(std::function<char()> getchar) {
case 'P':
return ParseDCS(getchar, input);
case '\e':
case '\x1B':
return ParseESC(getchar, input);
}
@ -129,28 +129,28 @@ Event Event::GetEvent(std::function<char()> getchar) {
}
// --- Arrow ---
Event Event::ArrowLeft = Event::Special("\e[D");
Event Event::ArrowRight = Event::Special("\e[C");
Event Event::ArrowUp = Event::Special("\e[A");
Event Event::ArrowDown = Event::Special("\e[B");
Event Event::ArrowLeft = Event::Special("\x1B[D");
Event Event::ArrowRight = Event::Special("\x1B[C");
Event Event::ArrowUp = Event::Special("\x1B[A");
Event Event::ArrowDown = Event::Special("\x1B[B");
Event Event::Backspace = Event::Special({127});
Event Event::Delete = Event::Special("\e[3~");
Event Event::Escape = Event::Special("\e");
Event Event::Delete = Event::Special("\x1B[3~");
Event Event::Escape = Event::Special("\x1B");
Event Event::Return = Event::Special({10});
Event Event::Tab = Event::Special({9});
Event Event::TabReverse = Event::Special({27, 91, 90});
Event Event::F1 = Event::Special("\e[OP");
Event Event::F2 = Event::Special("\e[OQ");
Event Event::F3 = Event::Special("\e[OR");
Event Event::F4 = Event::Special("\e[OS");
Event Event::F5 = Event::Special("\e[15~");
Event Event::F6 = Event::Special("\e[17~");
Event Event::F7 = Event::Special("\e[18~");
Event Event::F8 = Event::Special("\e[19~");
Event Event::F9 = Event::Special("\e[20~");
Event Event::F10 = Event::Special("\e[21~");
Event Event::F11 = Event::Special("\e[21~"); // Doesn't exist
Event Event::F12 = Event::Special("\e[24~");
Event Event::F1 = Event::Special("\x1B[OP");
Event Event::F2 = Event::Special("\x1B[OQ");
Event Event::F3 = Event::Special("\x1B[OR");
Event Event::F4 = Event::Special("\x1B[OS");
Event Event::F5 = Event::Special("\x1B[15~");
Event Event::F6 = Event::Special("\x1B[17~");
Event Event::F7 = Event::Special("\x1B[18~");
Event Event::F8 = Event::Special("\x1B[19~");
Event Event::F9 = Event::Special("\x1B[20~");
Event Event::F10 = Event::Special("\x1B[21~");
Event Event::F11 = Event::Special("\x1B[21~"); // Doesn't exist
Event Event::F12 = Event::Special("\x1B[24~");
Event Event::Custom = Event::Special({0});
} // namespace ftxui

View File

@ -18,11 +18,11 @@
namespace ftxui {
static const char* HIDE_CURSOR = "\e[?25l";
static const char* SHOW_CURSOR = "\e[?25h";
static const char* HIDE_CURSOR = "\x1B[?25l";
static const char* SHOW_CURSOR = "\x1B[?25h";
static const char* DISABLE_LINE_WRAP = "\e[7l";
static const char* ENABLE_LINE_WRAP = "\e[7h";
static const char* DISABLE_LINE_WRAP = "\x1B[7l";
static const char* ENABLE_LINE_WRAP = "\x1B[7h";
std::stack<std::function<void()>> on_exit_functions;
void OnExit(int signal) {
@ -188,12 +188,12 @@ void ScreenInteractive::Draw(Component* component) {
int dy = dimy_ - 1 - cursor_.y;
if (dx != 0) {
set_cursor_position += "\e[" + std::to_string(dx) + "D";
reset_cursor_position += "\e[" + std::to_string(dx) + "C";
set_cursor_position += "\x1B[" + std::to_string(dx) + "D";
reset_cursor_position += "\x1B[" + std::to_string(dx) + "C";
}
if (dy != 0) {
set_cursor_position += "\e[" + std::to_string(dy) + "A";
reset_cursor_position += "\e[" + std::to_string(dy) + "B";
set_cursor_position += "\x1B[" + std::to_string(dy) + "A";
reset_cursor_position += "\x1B[" + std::to_string(dy) + "B";
}
}

View File

@ -22,4 +22,4 @@ std::unique_ptr<Node> blink(Element child) {
return std::make_unique<Blink>(unpack(std::move(child)));
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -22,4 +22,4 @@ std::unique_ptr<Node> bold(Element child) {
return std::make_unique<Bold>(unpack(std::move(child)));
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -115,4 +115,4 @@ Decorator borderWith(Pixel pixel) {
};
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -58,4 +58,4 @@ Decorator bgcolor(Color c) {
};
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -37,4 +37,4 @@ std::unique_ptr<Node> dbox(Elements children) {
return std::make_unique<DBox>(std::move(children));
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -24,4 +24,4 @@ std::unique_ptr<Node> dim(Element child) {
return std::make_unique<Dim>(unpack(std::move(child)));
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -55,4 +55,4 @@ std::unique_ptr<Node> notflex(Element child) {
return std::make_unique<NotFlex>(std::move(child));
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -123,4 +123,4 @@ std::unique_ptr<Node> frame(Element child) {
return std::make_unique<Frame>(unpack(std::move(child)));
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -36,4 +36,4 @@ std::unique_ptr<Node> gauge(float progress) {
return std::make_unique<Gauge>(progress);
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -42,4 +42,4 @@ std::unique_ptr<Node> graph(GraphFunction graph_function) {
return std::make_unique<Graph>(graph_function);
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -69,4 +69,4 @@ std::unique_ptr<Node> hbox(Elements children) {
return std::make_unique<HBox>(std::move(children));
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -56,4 +56,4 @@ std::unique_ptr<Node> hflow(Elements children) {
return std::make_unique<HFlow>(std::move(children));
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -24,4 +24,4 @@ std::unique_ptr<Node> inverted(Element child) {
return std::make_unique<Inverted>(unpack(std::move(child)));
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -44,4 +44,4 @@ void Render(Screen& screen, Node* node) {
screen.ApplyShader();
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -12,4 +12,4 @@ void NodeDecorator::SetBox(Box box) {
children[0]->SetBox(box);
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -15,6 +15,6 @@ class NodeDecorator : public Node {
void SetBox(Box box) override;
};
}; // namespace ftxui
} // namespace ftxui
#endif /* end of include guard: FTXUI_DOM_NODE_DECORATOR_H_ */

View File

@ -53,4 +53,4 @@ std::unique_ptr<Node> separator(Pixel pixel) {
return std::make_unique<SeparatorWithPixel>(pixel);
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -74,4 +74,4 @@ Decorator size(Direction direction, Constraint constraint, int value) {
};
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -276,4 +276,4 @@ std::unique_ptr<Node> spinner(int c, size_t index) {
return vbox(std::move(lines));
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -36,4 +36,4 @@ std::unique_ptr<Node> text(std::wstring text) {
return std::make_unique<Text>(text);
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -24,4 +24,4 @@ std::unique_ptr<Node> underlined(Element child) {
return std::make_unique<Underlined>(unpack(std::move(child)));
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -69,4 +69,4 @@ std::unique_ptr<Node> vbox(Elements children) {
return std::make_unique<VBox>(std::move(children));
}
}; // namespace ftxui
} // namespace ftxui

View File

@ -8,24 +8,24 @@
namespace ftxui {
namespace {
static const wchar_t* BOLD_SET = L"\e[1m";
static const wchar_t* BOLD_RESET = L"\e[22m"; // Can't use 21 here.
static const wchar_t* BOLD_SET = L"\x1B[1m";
static const wchar_t* BOLD_RESET = L"\x1B[22m"; // Can't use 21 here.
static const wchar_t* DIM_SET = L"\e[2m";
static const wchar_t* DIM_RESET = L"\e[22m";
static const wchar_t* DIM_SET = L"\x1B[2m";
static const wchar_t* DIM_RESET = L"\x1B[22m";
static const wchar_t* UNDERLINED_SET = L"\e[4m";
static const wchar_t* UNDERLINED_RESET = L"\e[24m";
static const wchar_t* UNDERLINED_SET = L"\x1B[4m";
static const wchar_t* UNDERLINED_RESET = L"\x1B[24m";
static const wchar_t* BLINK_SET = L"\e[5m";
static const wchar_t* BLINK_RESET = L"\e[25m";
static const wchar_t* BLINK_SET = L"\x1B[5m";
static const wchar_t* BLINK_RESET = L"\x1B[25m";
static const wchar_t* INVERTED_SET = L"\e[7m";
static const wchar_t* INVERTED_RESET = L"\e[27m";
static const wchar_t* INVERTED_SET = L"\x1B[7m";
static const wchar_t* INVERTED_RESET = L"\x1B[27m";
static const char* MOVE_LEFT = "\r";
static const char* MOVE_UP = "\e[1A";
static const char* CLEAR_LINE = "\e[2K";
static const char* MOVE_UP = "\x1B[1A";
static const char* CLEAR_LINE = "\x1B[2K";
bool In(const Box& stencil, int x, int y) {
return stencil.x_min <= x && x <= stencil.x_max && //
@ -86,9 +86,9 @@ void UpdatePixelStyle(std::wstringstream& ss, Pixel& previous, Pixel& next) {
if (next.foreground_color != previous.foreground_color ||
next.background_color != previous.background_color) {
ss << L"\e[" + to_wstring(std::to_string((uint8_t)next.foreground_color)) +
L"m";
ss << L"\e[" +
ss << L"\x1B[" +
to_wstring(std::to_string((uint8_t)next.foreground_color)) + L"m";
ss << L"\x1B[" +
to_wstring(std::to_string(10 + (uint8_t)next.background_color)) +
L"m";
}
@ -168,4 +168,4 @@ void Screen::ApplyShader() {
}
// clang-format on
}; // namespace ftxui
} // namespace ftxui