2018-10-19 04:58:38 +08:00
|
|
|
#ifndef FTXUI_COMPONENT_INPUT_H_
|
|
|
|
#define FTXUI_COMPONENT_INPUT_H_
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
2020-03-24 04:26:00 +08:00
|
|
|
#include "ftxui/component/component.hpp"
|
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
namespace ftxui {
|
2018-10-19 04:58:38 +08:00
|
|
|
|
|
|
|
class Input : public Component {
|
|
|
|
public:
|
|
|
|
// Constructor.
|
2019-01-13 01:24:46 +08:00
|
|
|
Input() = default;
|
|
|
|
~Input() override = default;
|
2018-10-19 04:58:38 +08:00
|
|
|
|
|
|
|
// State.
|
2018-10-21 20:18:11 +08:00
|
|
|
std::wstring content;
|
|
|
|
std::wstring placeholder;
|
2018-10-19 04:58:38 +08:00
|
|
|
|
|
|
|
// State update callback.
|
2020-03-24 04:26:00 +08:00
|
|
|
std::function<void()> on_change = []() {};
|
|
|
|
std::function<void()> on_enter = []() {};
|
2018-10-19 04:58:38 +08:00
|
|
|
|
|
|
|
// Component implementation.
|
2019-01-12 22:00:08 +08:00
|
|
|
Element Render() override;
|
2019-01-06 23:10:57 +08:00
|
|
|
bool OnEvent(Event) override;
|
2018-10-19 04:58:38 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
int cursor_position = 0;
|
|
|
|
};
|
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
} // namespace ftxui
|
2018-10-19 04:58:38 +08:00
|
|
|
|
|
|
|
#endif /* end of include guard: FTXUI_COMPONENT_INPUT_H_ */
|