mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-10-31 18:48:11 +08:00 
			
		
		
		
	Use IWYU.
This commit is contained in:
		| @@ -2,10 +2,14 @@ | ||||
| #define FTXUI_COMPONENT_BUTTON_HPP | ||||
|  | ||||
| #include <functional> | ||||
| #include <string> | ||||
|  | ||||
| #include "ftxui/component/component.hpp" | ||||
| #include "ftxui/dom/elements.hpp" | ||||
| #include "ftxui/screen/box.hpp" | ||||
|  | ||||
| namespace ftxui { | ||||
| struct Event; | ||||
|  | ||||
| /// @brief A button. An action is associated to the click event. | ||||
| /// @ingroup dom | ||||
| @@ -25,6 +29,7 @@ class Button : public Component { | ||||
|   // Component implementation. | ||||
|   Element Render() override; | ||||
|   bool OnEvent(Event) override; | ||||
|  | ||||
|  private: | ||||
|   Box box_; | ||||
| }; | ||||
|   | ||||
| @@ -12,3 +12,7 @@ using CapturedMouse = std::unique_ptr<CapturedMouseInterface>; | ||||
| }  // namespace ftxui | ||||
|  | ||||
| #endif /* end of include guard: FTXUI_CAPTURED_MOUSE_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. | ||||
|   | ||||
| @@ -1,11 +1,13 @@ | ||||
| #ifndef FTXUI_COMPONENT_CHECKBOX_HPP | ||||
| #define FTXUI_COMPONENT_CHECKBOX_HPP | ||||
|  | ||||
| #include <functional> | ||||
| #include <string> | ||||
|  | ||||
| #include "ftxui/component/component.hpp" | ||||
| #include "ftxui/screen/box.hpp" | ||||
|  | ||||
| namespace ftxui { | ||||
| struct Event; | ||||
|  | ||||
| /// @brief A Checkbox. It can be checked or unchecked.Display an element on a | ||||
| /// ftxui::Screen. | ||||
| @@ -42,7 +44,6 @@ class CheckBox : public Component { | ||||
|  | ||||
|   int cursor_position = 0; | ||||
|   Box box_; | ||||
|  | ||||
| }; | ||||
|  | ||||
| }  // namespace ftxui | ||||
|   | ||||
| @@ -1,14 +1,17 @@ | ||||
| #ifndef FTXUI_COMPONENT_COMPONENT_HPP | ||||
| #define FTXUI_COMPONENT_COMPONENT_HPP | ||||
|  | ||||
| #include <memory> | ||||
| #include "ftxui/component/event.hpp" | ||||
| #include "ftxui/dom/elements.hpp" | ||||
| #include <memory>  // for unique_ptr | ||||
| #include <vector>  // for vector | ||||
|  | ||||
| #include "ftxui/component/captured_mouse.hpp"  // for CaptureMouse | ||||
| #include "ftxui/dom/elements.hpp"             // for Element | ||||
|  | ||||
| namespace ftxui { | ||||
|  | ||||
| class Delegate; | ||||
| class Focus; | ||||
| struct Event; | ||||
|  | ||||
| /// @brief It implement rendering itself as ftxui::Element. It implement | ||||
| /// keyboard navigation by responding to ftxui::Event. | ||||
| @@ -53,6 +56,8 @@ class Component { | ||||
|   void TakeFocus(); | ||||
|  | ||||
|  protected: | ||||
|   CapturedMouse CaptureMouse(const Event& event); | ||||
|  | ||||
|   std::vector<Component*> children_; | ||||
|  | ||||
|  private: | ||||
|   | ||||
| @@ -2,6 +2,8 @@ | ||||
| #define FTXUI_COMPONENT_CONTAINER_HPP | ||||
|  | ||||
| #include "ftxui/component/component.hpp" | ||||
| #include "ftxui/component/event.hpp" | ||||
| #include "ftxui/dom/elements.hpp" | ||||
|  | ||||
| namespace ftxui { | ||||
|  | ||||
|   | ||||
| @@ -1,16 +1,14 @@ | ||||
| #ifndef FTXUI_COMPONENT_EVENT_HPP | ||||
| #define FTXUI_COMPONENT_EVENT_HPP | ||||
|  | ||||
| #include <array> | ||||
| #include <ftxui/component/mouse.hpp> | ||||
| #include <ftxui/component/receiver.hpp> | ||||
| #include <functional> | ||||
| #include <string> | ||||
| #include <ftxui/component/mouse.hpp>  // for Mouse | ||||
| #include <string>                     // for string, operator== | ||||
| #include <vector> | ||||
|  | ||||
| namespace ftxui { | ||||
|  | ||||
| class ScreenInteractive; | ||||
| class Component; | ||||
|  | ||||
| /// @brief Represent an event. It can be key press event, a terminal resize, or | ||||
| /// more ... | ||||
| @@ -53,7 +51,7 @@ struct Event { | ||||
|   static Event Custom; | ||||
|  | ||||
|   //--- Method section --------------------------------------------------------- | ||||
|   bool is_character() const { return type_ == Type::Character;} | ||||
|   bool is_character() const { return type_ == Type::Character; } | ||||
|   wchar_t character() const { return character_; } | ||||
|  | ||||
|   bool is_mouse() const { return type_ == Type::Mouse; } | ||||
| @@ -67,13 +65,12 @@ struct Event { | ||||
|  | ||||
|   const std::string& input() const { return input_; } | ||||
|  | ||||
|   ScreenInteractive* screen() { return screen_; } | ||||
|   void SetScreen(ScreenInteractive* screen) { screen_ = screen; } | ||||
|  | ||||
|   bool operator==(const Event& other) const { return input_ == other.input_; } | ||||
|  | ||||
|   //--- State section ---------------------------------------------------------- | ||||
|  private: | ||||
|   friend Component; | ||||
|   friend ScreenInteractive; | ||||
|   enum class Type { | ||||
|     Unknown, | ||||
|     Character, | ||||
| @@ -94,10 +91,9 @@ struct Event { | ||||
|   }; | ||||
|   std::string input_; | ||||
|  | ||||
|   ScreenInteractive* screen_; | ||||
|   ScreenInteractive* screen_ = nullptr; | ||||
| }; | ||||
|  | ||||
|  | ||||
| }  // namespace ftxui | ||||
|  | ||||
| #endif /* end of include guard: FTXUI_COMPONENT_EVENT_HPP */ | ||||
|   | ||||
| @@ -2,10 +2,14 @@ | ||||
| #define FTXUI_COMPONENT_INPUT_H_ | ||||
|  | ||||
| #include <functional> | ||||
| #include <string> | ||||
|  | ||||
| #include "ftxui/component/component.hpp" | ||||
| #include "ftxui/dom/elements.hpp" | ||||
| #include "ftxui/screen/box.hpp" | ||||
|  | ||||
| namespace ftxui { | ||||
| struct Event; | ||||
|  | ||||
| /// @brief An input box. The user can type text into it. | ||||
| /// @ingroup component. | ||||
|   | ||||
| @@ -2,11 +2,15 @@ | ||||
| #define FTXUI_COMPONENT_MENU | ||||
|  | ||||
| #include <functional> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| #include "ftxui/component/component.hpp" | ||||
| #include "ftxui/dom/elements.hpp" | ||||
| #include "ftxui/screen/box.hpp" | ||||
|  | ||||
| namespace ftxui { | ||||
| struct Event; | ||||
|  | ||||
| /// @brief A list of items. The user can navigate through them. | ||||
| /// @ingroup component | ||||
|   | ||||
| @@ -1,3 +1,5 @@ | ||||
| #ifndef FTXUI_COMPONENT_MOUSE_HPP | ||||
| #define FTXUI_COMPONENT_MOUSE_HPP | ||||
| namespace ftxui { | ||||
|  | ||||
| /// @brief A mouse event. It contains the coordinate of the mouse, the button | ||||
| @@ -39,3 +41,4 @@ struct Mouse { | ||||
| // 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. | ||||
| #endif /* end of include guard: FTXUI_COMPONENT_MOUSE_HPP */ | ||||
|   | ||||
| @@ -1,11 +1,15 @@ | ||||
| #ifndef FTXUI_COMPONENT_RADIOBOX_HPP | ||||
| #define FTXUI_COMPONENT_RADIOBOX_HPP | ||||
|  | ||||
| #include <functional> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| #include "ftxui/component/component.hpp" | ||||
| #include "ftxui/dom/elements.hpp" | ||||
| #include "ftxui/screen/box.hpp" | ||||
|  | ||||
| namespace ftxui { | ||||
| struct Event; | ||||
|  | ||||
| /// @brief A list of selectable element. One and only one can be selected at | ||||
| /// the same time. | ||||
|   | ||||
| @@ -1,13 +1,13 @@ | ||||
| #ifndef FTXUI_COMPONENT_RECEIVER_HPP_ | ||||
| #define FTXUI_COMPONENT_RECEIVER_HPP_ | ||||
|  | ||||
| #include <atomic> | ||||
| #include <condition_variable> | ||||
| #include <atomic>              // for atomic | ||||
| #include <condition_variable>  // for condition_variable | ||||
| #include <functional> | ||||
| #include <iostream> | ||||
| #include <memory> | ||||
| #include <mutex> | ||||
| #include <queue> | ||||
| #include <memory>  // for unique_ptr, make_unique | ||||
| #include <mutex>   // for mutex, unique_lock | ||||
| #include <queue>   // for queue | ||||
|  | ||||
| namespace ftxui { | ||||
|  | ||||
| @@ -38,6 +38,7 @@ namespace ftxui { | ||||
| // clang-format off | ||||
| template<class T> class SenderImpl; | ||||
| template<class T> class ReceiverImpl; | ||||
|  | ||||
| template<class T> using Sender = std::unique_ptr<SenderImpl<T>>; | ||||
| template<class T> using Receiver = std::unique_ptr<ReceiverImpl<T>>; | ||||
| template<class T> Receiver<T> MakeReceiver(); | ||||
|   | ||||
| @@ -1,20 +1,18 @@ | ||||
| #ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP | ||||
| #define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP | ||||
|  | ||||
| #include <atomic> | ||||
| #include <condition_variable> | ||||
| #include <atomic>  // for atomic | ||||
| #include <ftxui/component/receiver.hpp> | ||||
| #include <functional> | ||||
| #include <memory> | ||||
| #include <mutex> | ||||
| #include <queue> | ||||
| #include <memory>  // for unique_ptr | ||||
| #include <string>  // for string | ||||
|  | ||||
| #include "ftxui/component/captured_mouse.hpp" | ||||
| #include "ftxui/component/captured_mouse.hpp"  // for CapturedMouse | ||||
| #include "ftxui/component/event.hpp" | ||||
| #include "ftxui/screen/screen.hpp" | ||||
| #include "ftxui/screen/screen.hpp"  // for Screen | ||||
|  | ||||
| namespace ftxui { | ||||
| class Component; | ||||
| struct Event; | ||||
|  | ||||
| class ScreenInteractive : public Screen { | ||||
|  public: | ||||
|   | ||||
| @@ -11,13 +11,8 @@ namespace ftxui { | ||||
| // float max = 100.f, | ||||
| // float increment = (max - min) * 0.05f); | ||||
|  | ||||
| template<class T> // T = {int, float} | ||||
| ComponentPtr Slider(std::wstring label, | ||||
|                     T* value, | ||||
|                     T min, | ||||
|                     T max, | ||||
|                     T increment); | ||||
|  | ||||
| template <class T>  // T = {int, float} | ||||
| ComponentPtr Slider(std::wstring label, T* value, T min, T max, T increment); | ||||
|  | ||||
| }  // namespace ftxui | ||||
|  | ||||
|   | ||||
| @@ -1,12 +1,15 @@ | ||||
| #ifndef FTXUI_COMPONENT_TOGGLE_H_ | ||||
| #define FTXUI_COMPONENT_TOGGLE_H_ | ||||
|  | ||||
| #include <functional> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| #include "ftxui/component/component.hpp" | ||||
| #include "ftxui/dom/elements.hpp" | ||||
| #include "ftxui/screen/box.hpp" | ||||
|  | ||||
| namespace ftxui { | ||||
| struct Event; | ||||
|  | ||||
| /// @brief An horizontal list of elements. The user can navigate through them. | ||||
| /// @ingroup component | ||||
|   | ||||
| @@ -78,7 +78,7 @@ enum Direction { WIDTH, HEIGHT }; | ||||
| enum Constraint { LESS_THAN, EQUAL, GREATER_THAN }; | ||||
| Decorator size(Direction, Constraint, int value); | ||||
|  | ||||
| // --  | ||||
| // -- | ||||
| Decorator reflect(Box& box); | ||||
|  | ||||
| // --- Frame --- | ||||
|   | ||||
| @@ -1,16 +1,18 @@ | ||||
| #ifndef FTXUI_DOM_NODE_HPP | ||||
| #define FTXUI_DOM_NODE_HPP | ||||
|  | ||||
| #include <memory> | ||||
| #include <vector> | ||||
| #include <memory>  // for shared_ptr | ||||
| #include <vector>  // for vector | ||||
|  | ||||
| #include "ftxui/dom/requirement.hpp" | ||||
| #include "ftxui/screen/box.hpp" | ||||
| #include "ftxui/dom/requirement.hpp"  // for Requirement | ||||
| #include "ftxui/screen/box.hpp"       // for Box | ||||
| #include "ftxui/screen/screen.hpp" | ||||
|  | ||||
| namespace ftxui { | ||||
|  | ||||
| class Node; | ||||
| class Screen; | ||||
|  | ||||
| using Element = std::shared_ptr<Node>; | ||||
| using Elements = std::vector<std::shared_ptr<Node>>; | ||||
|  | ||||
|   | ||||
| @@ -1,3 +1,4 @@ | ||||
| // IWYU pragma: private, include "ftxui/dom/elements.hpp" | ||||
| #include <type_traits> | ||||
|  | ||||
| template <class T> | ||||
|   | ||||
| @@ -1,8 +1,8 @@ | ||||
| #ifndef FTXUI_SCREEN_COLOR | ||||
| #define FTXUI_SCREEN_COLOR | ||||
|  | ||||
| #include <cstdint> | ||||
| #include <string> | ||||
| #include <stdint.h>  // for uint8_t | ||||
| #include <string>    // for wstring | ||||
|  | ||||
| #ifdef RGB | ||||
| // Workaround for wingdi.h (via Windows.h) defining macros that break things. | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| #ifndef FTXUI_SCREEN_COLOR_INFO_HPP | ||||
| #define FTXUI_SCREEN_COLOR_INFO_HPP | ||||
|  | ||||
| #include <stdint.h> | ||||
| #include <ftxui/screen/color.hpp> | ||||
|  | ||||
| namespace ftxui { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ArthurSonzogni
					ArthurSonzogni