Support piped input.

This commit is contained in:
2026-09-03 09:52:13 +01:00
parent f8975a60d8
commit abbfcc352a
7 changed files with 88 additions and 4 deletions
+11
View File
@@ -69,6 +69,17 @@ CommandIO::CommandIO(BEd &bed) : bed(bed) {
}
std::pair<std::string, bool> CommandIO::run() {
if (!bed.io.interactive())
return run_pipe();
return run_terminal();
}
std::pair<std::string, bool> CommandIO::run_pipe() {
bed.io.write(prompt);
return bed.io.read_pipe();
}
std::pair<std::string, bool> CommandIO::run_terminal() {
auto [row, col] = bed.io.cursor_position();
auto [rows, cols] = bed.io.terminal_size();
if (row > rows)