mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-10-23 21:40:54 +08:00
Adds opt-in support for applications that need to read piped data from stdin while still receiving interactive keyboard input (#1094)
Enables applications to read piped data while maintaining interactive keyboard input by redirecting stdin to /dev/tty when explicitly enabled. Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
@@ -43,10 +43,11 @@ class ScreenInteractive : public Screen {
|
||||
static ScreenInteractive TerminalOutput();
|
||||
|
||||
// Destructor.
|
||||
~ScreenInteractive();
|
||||
~ScreenInteractive() override;
|
||||
|
||||
// Options. Must be called before Loop().
|
||||
void TrackMouse(bool enable = true);
|
||||
void HandlePipedInput(bool enable = true);
|
||||
|
||||
// Return the currently active screen, nullptr if none.
|
||||
static ScreenInteractive* Active();
|
||||
@@ -100,6 +101,8 @@ class ScreenInteractive : public Screen {
|
||||
void Draw(Component component);
|
||||
void ResetCursorPosition();
|
||||
|
||||
void InstallPipedInputHandling();
|
||||
|
||||
void Signal(int signal);
|
||||
|
||||
void FetchTerminalEvents();
|
||||
@@ -117,6 +120,7 @@ class ScreenInteractive : public Screen {
|
||||
int dimx,
|
||||
int dimy,
|
||||
bool use_alternative_screen);
|
||||
|
||||
const Dimension dimension_;
|
||||
const bool use_alternative_screen_;
|
||||
|
||||
@@ -141,6 +145,11 @@ class ScreenInteractive : public Screen {
|
||||
bool force_handle_ctrl_c_ = true;
|
||||
bool force_handle_ctrl_z_ = true;
|
||||
|
||||
// Piped input handling state (POSIX only)
|
||||
bool handle_piped_input_ = true;
|
||||
// File descriptor for /dev/tty, used for piped input handling.
|
||||
int tty_fd_ = -1;
|
||||
|
||||
// The style of the cursor to restore on exit.
|
||||
int cursor_reset_shape_ = 1;
|
||||
|
||||
|
Reference in New Issue
Block a user