mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-28 16:29:34 +08:00
Make component more functionnal
This commit is contained in:
@@ -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_;
|
||||
|
Reference in New Issue
Block a user