2019-01-07 00:10:35 +08:00
|
|
|
#ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
|
|
|
|
#define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2020-03-24 04:26:00 +08:00
|
|
|
#include <atomic>
|
2019-01-27 09:33:06 +08:00
|
|
|
#include <condition_variable>
|
2018-10-10 01:06:03 +08:00
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
2019-01-27 09:33:06 +08:00
|
|
|
#include <mutex>
|
|
|
|
#include <queue>
|
|
|
|
|
|
|
|
#include "ftxui/component/event.hpp"
|
|
|
|
#include "ftxui/screen/screen.hpp"
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
namespace ftxui {
|
2019-01-13 01:24:46 +08:00
|
|
|
class Component;
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-13 01:24:46 +08:00
|
|
|
class ScreenInteractive : public Screen {
|
2020-03-24 04:26:00 +08:00
|
|
|
public:
|
|
|
|
static ScreenInteractive FixedSize(int dimx, int dimy);
|
|
|
|
static ScreenInteractive Fullscreen();
|
|
|
|
static ScreenInteractive FitComponent();
|
|
|
|
static ScreenInteractive TerminalOutput();
|
|
|
|
|
|
|
|
~ScreenInteractive();
|
|
|
|
void Loop(Component*);
|
|
|
|
std::function<void()> ExitLoopClosure();
|
|
|
|
|
|
|
|
void PostEvent(Event event);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void Draw(Component* component);
|
|
|
|
void EventLoop(Component* component);
|
|
|
|
|
|
|
|
enum class Dimension {
|
|
|
|
FitComponent,
|
|
|
|
Fixed,
|
|
|
|
Fullscreen,
|
|
|
|
TerminalOutput,
|
|
|
|
};
|
|
|
|
Dimension dimension_ = Dimension::Fixed;
|
|
|
|
ScreenInteractive(int dimx, int dimy, Dimension dimension);
|
|
|
|
|
|
|
|
std::condition_variable events_queue_cv;
|
|
|
|
std::mutex events_queue_mutex;
|
|
|
|
std::queue<Event> events_queue;
|
|
|
|
std::atomic<bool> quit_ = false;
|
|
|
|
|
|
|
|
std::string set_cursor_position;
|
|
|
|
std::string reset_cursor_position;
|
2018-10-10 01:06:03 +08:00
|
|
|
};
|
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
} // namespace ftxui
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-07 00:10:35 +08:00
|
|
|
#endif /* end of include guard: FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP */
|