FTXUI/include/ftxui/component/input.hpp

35 lines
664 B
C++
Raw Normal View History

2018-10-19 04:58:38 +08:00
#ifndef FTXUI_COMPONENT_INPUT_H_
#define FTXUI_COMPONENT_INPUT_H_
#include <functional>
#include "ftxui/component/component.hpp"
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.
std::function<void()> on_change = []() {};
std::function<void()> on_enter = []() {};
2018-10-19 04:58:38 +08:00
// Component implementation.
Element Render() override;
bool OnEvent(Event) override;
2018-10-19 04:58:38 +08:00
private:
int cursor_position = 0;
};
} // namespace ftxui
2018-10-19 04:58:38 +08:00
#endif /* end of include guard: FTXUI_COMPONENT_INPUT_H_ */