summaryrefslogtreecommitdiff
path: root/examples/dte/spawn.h
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2023-11-09 23:19:53 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2023-11-09 23:19:53 +0100
commit1566b6faa8534118c3566188181367cd0868468f (patch)
tree1de8d4b369efb5e592685a31088f798a6b63ffa1 /examples/dte/spawn.h
parent349991bf6efe473ab9a5cbdae0a8114d72b997e3 (diff)
downloadcrep-1566b6faa8534118c3566188181367cd0868468f.tar.gz
Added partial matching and introduced threads
Diffstat (limited to 'examples/dte/spawn.h')
-rw-r--r--examples/dte/spawn.h37
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 @@
+#ifndef SPAWN_H
+#define SPAWN_H
+
+#include <stdbool.h>
+#include "compiler.h"
+#include "editor.h"
+#include "msg.h"
+#include "util/macros.h"
+#include "util/string.h"
+#include "util/string-view.h"
+
+typedef enum {
+ SPAWN_QUIET = 1 << 0, // Interpret SPAWN_TTY as SPAWN_NULL and don't yield terminal to child
+ SPAWN_PROMPT = 1 << 1, // Show "press any key to continue" prompt
+ SPAWN_READ_STDOUT = 1 << 2, // Read errors from stdout instead of stderr
+} SpawnFlags;
+
+typedef enum {
+ SPAWN_NULL,
+ SPAWN_TTY,
+ SPAWN_PIPE,
+} SpawnAction;
+
+typedef struct {
+ EditorState *editor;
+ const char **argv;
+ const char **env;
+ StringView input;
+ String outputs[2]; // For stdout/stderr
+ SpawnFlags flags;
+ SpawnAction actions[3];
+} SpawnContext;
+
+int spawn(SpawnContext *ctx) NONNULL_ARGS WARN_UNUSED_RESULT;
+bool spawn_compiler(SpawnContext *ctx, const Compiler *c, MessageArray *msgs) NONNULL_ARGS WARN_UNUSED_RESULT;
+
+#endif