FTXUI/include/ftxui/component/screen_interactive.hpp

69 lines
1.7 KiB
C++
Raw Normal View History

#ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
#define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
2021-05-02 02:40:35 +08:00
#include <atomic> // for atomic
#include <ftxui/component/receiver.hpp>
2021-05-02 02:40:35 +08:00
#include <memory> // for unique_ptr
#include <string> // for string
2019-01-27 09:33:06 +08:00
2021-05-02 02:40:35 +08:00
#include "ftxui/component/captured_mouse.hpp" // for CapturedMouse
2019-01-27 09:33:06 +08:00
#include "ftxui/component/event.hpp"
2021-05-02 02:40:35 +08:00
#include "ftxui/screen/screen.hpp" // for Screen
namespace ftxui {
2019-01-13 01:24:46 +08:00
class Component;
2021-05-02 02:40:35 +08:00
struct Event;
2019-01-13 01:24:46 +08:00
class ScreenInteractive : public Screen {
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);
CapturedMouse CaptureMouse();
private:
void Draw(Component* component);
void EventLoop(Component* component);
enum class Dimension {
FitComponent,
Fixed,
Fullscreen,
TerminalOutput,
};
Dimension dimension_ = Dimension::Fixed;
bool use_alternative_screen_ = false;
ScreenInteractive(int dimx,
int dimy,
Dimension dimension,
bool use_alternative_screen);
Sender<Event> event_sender_;
Receiver<Event> event_receiver_;
std::string set_cursor_position;
std::string reset_cursor_position;
std::atomic<bool> quit_ = false;
int cursor_x_ = 0;
int cursor_y_ = 0;
bool mouse_captured = false;
};
} // namespace ftxui
#endif /* end of include guard: FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP */
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.