mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-23 11:17:06 +08:00
86c3b60a6f
Most CJK users use IME (input method) to type CJK characters. They need the cursor to be at the correct location, not in the bottom right corner. This CL does: * Move the cursor the focus() element. * Hide the cursor (and show it at exit) * Intercept SIGINT to guarantee proper cleanup all the time. This should fix the second issue mentionned on: https://github.com/ArthurSonzogni/FTXUI/issues/2
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
#ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
|
|
#define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
|
|
|
|
#include <condition_variable>
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <queue>
|
|
#include <atomic>
|
|
|
|
#include "ftxui/component/event.hpp"
|
|
#include "ftxui/screen/screen.hpp"
|
|
|
|
namespace ftxui {
|
|
class Component;
|
|
|
|
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);
|
|
|
|
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;
|
|
};
|
|
|
|
} // namespace ftxui
|
|
|
|
#endif /* end of include guard: FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP */
|