Use IWYU.

This commit is contained in:
ArthurSonzogni
2021-05-01 20:40:35 +02:00
parent eb399d20c5
commit 155758c073
119 changed files with 770 additions and 342 deletions

View File

@@ -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_;
};

View File

@@ -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.

View 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

View File

@@ -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:

View File

@@ -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 {

View File

@@ -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 */

View File

@@ -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.

View File

@@ -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

View File

@@ -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 */

View File

@@ -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.

View File

@@ -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();

View File

@@ -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:

View File

@@ -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

View File

@@ -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