diff options
Diffstat (limited to 'examples/dte/spawn.h')
| -rw-r--r-- | examples/dte/spawn.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/dte/spawn.h b/examples/dte/spawn.h new file mode 100644 index 0000000..659f2cd --- /dev/null +++ b/examples/dte/spawn.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | #ifndef SPAWN_H | ||
| 2 | #define SPAWN_H | ||
| 3 | |||
| 4 | #include <stdbool.h> | ||
| 5 | #include "compiler.h" | ||
| 6 | #include "editor.h" | ||
| 7 | #include "msg.h" | ||
| 8 | #include "util/macros.h" | ||
| 9 | #include "util/string.h" | ||
| 10 | #include "util/string-view.h" | ||
| 11 | |||
| 12 | typedef enum { | ||
| 13 | SPAWN_QUIET = 1 << 0, // Interpret SPAWN_TTY as SPAWN_NULL and don't yield terminal to child | ||
| 14 | SPAWN_PROMPT = 1 << 1, // Show "press any key to continue" prompt | ||
| 15 | SPAWN_READ_STDOUT = 1 << 2, // Read errors from stdout instead of stderr | ||
| 16 | } SpawnFlags; | ||
| 17 | |||
| 18 | typedef enum { | ||
| 19 | SPAWN_NULL, | ||
| 20 | SPAWN_TTY, | ||
| 21 | SPAWN_PIPE, | ||
| 22 | } SpawnAction; | ||
| 23 | |||
| 24 | typedef struct { | ||
| 25 | EditorState *editor; | ||
| 26 | const char **argv; | ||
| 27 | const char **env; | ||
| 28 | StringView input; | ||
| 29 | String outputs[2]; // For stdout/stderr | ||
| 30 | SpawnFlags flags; | ||
| 31 | SpawnAction actions[3]; | ||
| 32 | } SpawnContext; | ||
| 33 | |||
| 34 | int spawn(SpawnContext *ctx) NONNULL_ARGS WARN_UNUSED_RESULT; | ||
| 35 | bool spawn_compiler(SpawnContext *ctx, const Compiler *c, MessageArray *msgs) NONNULL_ARGS WARN_UNUSED_RESULT; | ||
| 36 | |||
| 37 | #endif | ||
