Make component more functionnal

This commit is contained in:
ArthurSonzogni
2021-05-09 20:32:27 +02:00
parent 9d15d1c275
commit 6d75cb2748
70 changed files with 2182 additions and 1769 deletions

View File

@@ -1,27 +1,29 @@
#ifndef FTXUI_COMPONENT_INPUT_H_
#define FTXUI_COMPONENT_INPUT_H_
#include <functional>
#include <string>
#include <functional> // for function
#include <string> // for wstring
#include "ftxui/component/component.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/box.hpp"
#include "ftxui/component/component.hpp" // for Component
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/dom/elements.hpp" // for Element
#include "ftxui/screen/box.hpp" // for Box
namespace ftxui {
struct Event;
/// @brief An input box. The user can type text into it.
/// @ingroup component.
class Input : public Component {
class InputBase : public ComponentBase {
public:
// Access this interface from a Component
static InputBase* From(Component component);
// Constructor.
Input() = default;
~Input() override = default;
InputBase(std::wstring* content, const std::wstring* placeholder);
~InputBase() override = default;
// State.
std::wstring content;
std::wstring placeholder;
int cursor_position = 0;
// State update callback.
@@ -33,6 +35,9 @@ class Input : public Component {
bool OnEvent(Event) override;
private:
std::wstring* const content_;
const std::wstring* const placeholder_;
bool OnMouseEvent(Event);
Box input_box_;
Box cursor_box_;