FTXUI  0.10.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
screen_interactive.hpp
Go to the documentation of this file.
1#ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
2#define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
3
4#include <atomic> // for atomic
5#include <ftxui/component/receiver.hpp> // for Receiver, Sender
6#include <functional> // for function
7#include <memory> // for shared_ptr
8#include <string> // for string
9#include <thread> // for thread
10
11#include "ftxui/component/captured_mouse.hpp" // for CapturedMouse
12#include "ftxui/component/event.hpp" // for Event
13#include "ftxui/screen/screen.hpp" // for Screen
14
15namespace ftxui {
16class ComponentBase;
17struct Event;
18
19using Component = std::shared_ptr<ComponentBase>;
20
21class ScreenInteractive : public Screen {
22 public:
23 static ScreenInteractive FixedSize(int dimx, int dimy);
27
28 void Loop(Component);
29 std::function<void()> ExitLoopClosure();
30
31 void PostEvent(Event event);
33
34 private:
35 void Install();
36 void Uninstall();
37 void Main(Component component);
38 ScreenInteractive* suspended_screen_ = nullptr;
39
40 void Draw(Component component);
41 void EventLoop(Component component);
42
43 enum class Dimension {
45 Fixed,
48 };
49 Dimension dimension_ = Dimension::Fixed;
50 bool use_alternative_screen_ = false;
52 int dimy,
53 Dimension dimension,
54 bool use_alternative_screen);
55
56 Sender<Event> event_sender_;
57 Receiver<Event> event_receiver_;
58
59 std::string set_cursor_position;
60 std::string reset_cursor_position;
61
62 std::atomic<bool> quit_ = false;
63 std::thread event_listener_;
64
65 int cursor_x_ = 1;
66 int cursor_y_ = 1;
67
68 bool mouse_captured = false;
69};
70
71} // namespace ftxui
72
73#endif /* end of include guard: FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP */
74
75// Copyright 2020 Arthur Sonzogni. All rights reserved.
76// Use of this source code is governed by the MIT license that can be found in
77// the LICENSE file.
static ScreenInteractive TerminalOutput()
static ScreenInteractive FixedSize(int dimx, int dimy)
static ScreenInteractive FitComponent()
static ScreenInteractive Fullscreen()
std::function< void()> ExitLoopClosure()
A rectangular grid of Pixel.
Definition screen.hpp:49
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::unique_ptr< ReceiverImpl< T > > Receiver
Definition receiver.hpp:45
std::unique_ptr< SenderImpl< T > > Sender
Definition receiver.hpp:44
std::shared_ptr< ComponentBase > Component
Represent an event. It can be key press event, a terminal resize, or more ...
Definition event.hpp:25