Support piped input.
This commit is contained in:
@@ -58,12 +58,23 @@ struct IO {
|
||||
static volatile std::atomic_bool resized;
|
||||
static void handle_sigwinch(int);
|
||||
|
||||
static enum struct Mode {
|
||||
PIPE,
|
||||
TERMINAL
|
||||
} mode;
|
||||
|
||||
std::string pipe_input;
|
||||
std::deque<char> input_queue;
|
||||
|
||||
IO();
|
||||
~IO();
|
||||
|
||||
IO(const IO &) = delete;
|
||||
IO &operator=(const IO &) = delete;
|
||||
|
||||
bool interactive() const {
|
||||
return mode == Mode::TERMINAL;
|
||||
}
|
||||
void enable_mouse();
|
||||
void disable_mouse();
|
||||
|
||||
@@ -71,14 +82,14 @@ struct IO {
|
||||
std::pair<uint16_t, uint16_t> cursor_position();
|
||||
void move_cursor(uint16_t row, uint16_t col);
|
||||
|
||||
std::pair<std::string, bool> read_pipe();
|
||||
|
||||
KeyEvent read_key();
|
||||
void write(const char *, uint64_t);
|
||||
void write(std::string_view);
|
||||
void write_line(std::string_view);
|
||||
void run_pty(const std::string &);
|
||||
|
||||
std::deque<char> input_queue;
|
||||
|
||||
KeyEvent::ReadResult get_next_byte(char &out);
|
||||
void enqueue_bytes(const std::string &bytes);
|
||||
static int utf8_seq_len(uint8_t byte);
|
||||
|
||||
@@ -41,6 +41,8 @@ struct CommandIO {
|
||||
|
||||
CommandIO(BEd &);
|
||||
std::pair<std::string, bool> run();
|
||||
std::pair<std::string, bool> run_pipe();
|
||||
std::pair<std::string, bool> run_terminal();
|
||||
void redraw();
|
||||
};
|
||||
} // namespace bed::internal::ui
|
||||
|
||||
@@ -15,6 +15,8 @@ struct TextMode {
|
||||
|
||||
TextMode(BEd &);
|
||||
std::pair<vase::Shard *, bool> run();
|
||||
std::pair<vase::Shard *, bool> run_pipe();
|
||||
std::pair<vase::Shard *, bool> run_terminal();
|
||||
void grow();
|
||||
void redraw();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user