mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-10-31 10:38:09 +08:00 
			
		
		
		
	Add clang-tidy. (#368)
This commit is contained in:
		| @@ -1,7 +1,7 @@ | ||||
| #ifndef FTXUI_DOM_CANVAS_HPP | ||||
| #define FTXUI_DOM_CANVAS_HPP | ||||
|  | ||||
| #include <stddef.h>       // for size_t | ||||
| #include <cstddef>        // for size_t | ||||
| #include <functional>     // for function | ||||
| #include <string>         // for string | ||||
| #include <unordered_map>  // for unordered_map | ||||
| @@ -13,7 +13,7 @@ namespace ftxui { | ||||
|  | ||||
| struct Canvas { | ||||
|  public: | ||||
|   Canvas() {} | ||||
|   Canvas() = default; | ||||
|   Canvas(int width, int height); | ||||
|  | ||||
|   // Getters: | ||||
| @@ -114,7 +114,8 @@ struct Canvas { | ||||
|  | ||||
|   struct XYHash { | ||||
|     size_t operator()(const XY& xy) const { | ||||
|       return static_cast<size_t>(xy.x * 1024 + xy.y); | ||||
|       constexpr size_t shift = 1024; | ||||
|       return size_t(xy.x) * shift + size_t(xy.y); | ||||
|     } | ||||
|   }; | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| #ifndef FTXUI_DOM_DEPRECRATED_HPP | ||||
| #define FTXUI_DOM_DEPRECRATED_HPP | ||||
| #ifndef FTXUI_DOM_DEPRECATED_HPP | ||||
| #define FTXUI_DOM_DEPRECATED_HPP | ||||
|  | ||||
| #include "ftxui/dom/elements.hpp" | ||||
|  | ||||
| @@ -9,7 +9,7 @@ Element vtext(std::wstring text); | ||||
| Elements paragraph(std::wstring text); | ||||
| }  // namespace ftxui | ||||
|  | ||||
| #endif /* end of include guard: FTXUI_DOM_DEPRECRATED_HPP */ | ||||
| #endif  // FTXUI_DOM_DEPRECATED_HPP | ||||
|  | ||||
| // Copyright 2021 Arthur Sonzogni. All rights reserved. | ||||
| // Use of this source code is governed by the MIT license that can be found in | ||||
|   | ||||
| @@ -35,7 +35,7 @@ Decorator operator|(Decorator, Decorator); | ||||
| // --- Widget --- | ||||
| Element text(std::string text); | ||||
| Element vtext(std::string text); | ||||
| Element separator(void); | ||||
| Element separator(); | ||||
| Element separatorLight(); | ||||
| Element separatorHeavy(); | ||||
| Element separatorDouble(); | ||||
| @@ -45,18 +45,18 @@ Element separator(Pixel); | ||||
| Element separatorCharacter(std::string); | ||||
| Element separatorHSelector(float left, | ||||
|                            float right, | ||||
|                            Color background, | ||||
|                            Color foreground); | ||||
|                            Color unselected_color, | ||||
|                            Color selected_color); | ||||
| Element separatorVSelector(float up, | ||||
|                            float down, | ||||
|                            Color background, | ||||
|                            Color foreground); | ||||
| Element gauge(float ratio); | ||||
| Element gaugeLeft(float ratio); | ||||
| Element gaugeRight(float ratio); | ||||
| Element gaugeUp(float ratio); | ||||
| Element gaugeDown(float ratio); | ||||
| Element gaugeDirection(float ratio, GaugeDirection); | ||||
|                            Color unselected_color, | ||||
|                            Color selected_color); | ||||
| Element gauge(float progress); | ||||
| Element gaugeLeft(float progress); | ||||
| Element gaugeRight(float progress); | ||||
| Element gaugeUp(float progress); | ||||
| Element gaugeDown(float progress); | ||||
| Element gaugeDirection(float progress, GaugeDirection); | ||||
| Element border(Element); | ||||
| Element borderLight(Element); | ||||
| Element borderHeavy(Element); | ||||
| @@ -64,14 +64,14 @@ Element borderDouble(Element); | ||||
| Element borderRounded(Element); | ||||
| Element borderEmpty(Element); | ||||
| Decorator borderStyled(BorderStyle); | ||||
| Decorator borderWith(Pixel); | ||||
| Decorator borderWith(const Pixel&); | ||||
| Element window(Element title, Element content); | ||||
| Element spinner(int charset_index, size_t image_index); | ||||
| Element paragraph(std::string text); | ||||
| Element paragraphAlignLeft(std::string text); | ||||
| Element paragraphAlignRight(std::string text); | ||||
| Element paragraphAlignCenter(std::string text); | ||||
| Element paragraphAlignJustify(std::string text); | ||||
| Element paragraph(const std::string& text); | ||||
| Element paragraphAlignLeft(const std::string& text); | ||||
| Element paragraphAlignRight(const std::string& text); | ||||
| Element paragraphAlignCenter(const std::string& text); | ||||
| Element paragraphAlignJustify(const std::string& text); | ||||
| Element graph(GraphFunction); | ||||
| Element emptyElement(); | ||||
| Element canvas(ConstRef<Canvas>); | ||||
| @@ -90,7 +90,7 @@ Element color(Color, Element); | ||||
| Element bgcolor(Color, Element); | ||||
| Decorator focusPosition(int x, int y); | ||||
| Decorator focusPositionRelative(float x, float y); | ||||
| Element automerge(Element); | ||||
| Element automerge(Element child); | ||||
|  | ||||
| // --- Layout is | ||||
| // Horizontal, Vertical or stacked set of elements. | ||||
| @@ -163,7 +163,7 @@ Dimensions Fit(Element&); | ||||
|  | ||||
| // Include old definitions using wstring. | ||||
| #include "ftxui/dom/deprecated.hpp" | ||||
| #endif /* end of include guard: FTXUI_DOM_ELEMENTS_HPP */ | ||||
| #endif  // FTXUI_DOM_ELEMENTS_HPP | ||||
|  | ||||
| // Copyright 2020 Arthur Sonzogni. All rights reserved. | ||||
| // Use of this source code is governed by the MIT license that can be found in | ||||
|   | ||||
| @@ -108,7 +108,7 @@ struct FlexboxConfig { | ||||
|  | ||||
| }  // namespace ftxui | ||||
|  | ||||
| #endif /* end of include guard: FTXUI_DOM_FLEXBOX_CONFIG_HPP */ | ||||
| #endif  // FTXUI_DOM_FLEXBOX_CONFIG_HPP | ||||
|  | ||||
| // Copyright 2021 Arthur Sonzogni. All rights reserved. | ||||
| // Use of this source code is governed by the MIT license that can be found in | ||||
|   | ||||
| @@ -20,6 +20,11 @@ class Node { | ||||
|  public: | ||||
|   Node(); | ||||
|   Node(Elements children); | ||||
|   Node(const Node&) = delete; | ||||
|   Node(const Node&&) = delete; | ||||
|   Node& operator=(const Node&) = delete; | ||||
|   Node& operator=(const Node&&) = delete; | ||||
|  | ||||
|   virtual ~Node(); | ||||
|  | ||||
|   // Step 1: Compute layout requirement. Tell parent what dimensions this | ||||
| @@ -50,12 +55,12 @@ class Node { | ||||
|   Box box_; | ||||
| }; | ||||
|  | ||||
| void Render(Screen& screen, const Element& node); | ||||
| void Render(Screen& screen, const Element& element); | ||||
| void Render(Screen& screen, Node* node); | ||||
|  | ||||
| }  // namespace ftxui | ||||
|  | ||||
| #endif /* end of include guard: FTXUI_DOM_NODE_HPP */ | ||||
| #endif  // FTXUI_DOM_NODE_HPP | ||||
|  | ||||
| // Copyright 2020 Arthur Sonzogni. All rights reserved. | ||||
| // Use of this source code is governed by the MIT license that can be found in | ||||
|   | ||||
| @@ -28,7 +28,7 @@ struct Requirement { | ||||
|  | ||||
| }  // namespace ftxui | ||||
|  | ||||
| #endif /* end of include guard: FTXUI_DOM_REQUIREMENT_HPP */ | ||||
| #endif  // FTXUI_DOM_REQUIREMENT_HPP | ||||
|  | ||||
| // Copyright 2020 Arthur Sonzogni. All rights reserved. | ||||
| // Use of this source code is governed by the MIT license that can be found in | ||||
|   | ||||
| @@ -52,10 +52,10 @@ class Table { | ||||
|   void Initialize(std::vector<std::vector<Element>>); | ||||
|   friend TableSelection; | ||||
|   std::vector<std::vector<Element>> elements_; | ||||
|   int input_dim_x_; | ||||
|   int input_dim_y_; | ||||
|   int dim_x_; | ||||
|   int dim_y_; | ||||
|   int input_dim_x_ = 0; | ||||
|   int input_dim_y_ = 0; | ||||
|   int dim_x_ = 0; | ||||
|   int dim_y_ = 0; | ||||
| }; | ||||
|  | ||||
| class TableSelection { | ||||
|   | ||||
| @@ -1,10 +1,13 @@ | ||||
| #ifndef FTXUI_DOM_TAKE_ANY_ARGS_HPP | ||||
| #define FTXUI_DOM_TAKE_ANY_ARGS_HPP | ||||
|  | ||||
| // IWYU pragma: private, include "ftxui/dom/elements.hpp" | ||||
| #include <type_traits> | ||||
|  | ||||
| namespace ftxui { | ||||
|  | ||||
| template <class T> | ||||
| void Merge(Elements&, T) {} | ||||
| void Merge(Elements& /*container*/, T /*element*/) {} | ||||
|  | ||||
| template <> | ||||
| inline void Merge(Elements& container, Element element) { | ||||
| @@ -38,6 +41,8 @@ TAKE_ANY_ARGS(dbox) | ||||
| TAKE_ANY_ARGS(hflow) | ||||
| }  // namespace ftxui | ||||
|  | ||||
| #endif  // FTXUI_DOM_TAKE_ANY_ARGS_HPP | ||||
|  | ||||
| // 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. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Arthur Sonzogni
					Arthur Sonzogni