summaryrefslogtreecommitdiff
path: root/examples/dte/cmdline.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/cmdline.h
parent349991bf6efe473ab9a5cbdae0a8114d72b997e3 (diff)
downloadcrep-1566b6faa8534118c3566188181367cd0868468f.tar.gz
Added partial matching and introduced threads
Diffstat (limited to 'examples/dte/cmdline.h')
-rw-r--r--examples/dte/cmdline.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/dte/cmdline.h b/examples/dte/cmdline.h
new file mode 100644
index 0000000..70cc7a5
--- /dev/null
+++ b/examples/dte/cmdline.h
@@ -0,0 +1,40 @@
+#ifndef CMDLINE_H
+#define CMDLINE_H
+
+#include <stdbool.h>
+#include <sys/types.h>
+#include "command/run.h"
+#include "history.h"
+#include "util/macros.h"
+#include "util/ptr-array.h"
+#include "util/string-view.h"
+#include "util/string.h"
+
+typedef struct {
+ char *orig; // Full cmdline string (backing buffer for `escaped` and `tail`)
+ char *parsed; // Result of passing `escaped` through parse_command_arg()
+ StringView escaped; // Middle part of `orig` (string to be replaced)
+ StringView tail; // Suffix part of `orig` (after `escaped`)
+ size_t head_len; // Length of prefix part of `orig` (before `escaped`)
+ PointerArray completions; // Array of completion candidates
+ size_t idx; // Index of currently selected completion
+ bool add_space_after_single_match;
+ bool tilde_expanded;
+} CompletionState;
+
+typedef struct {
+ String buf;
+ size_t pos;
+ const HistoryEntry *search_pos;
+ char *search_text;
+ CompletionState completion;
+} CommandLine;
+
+extern const CommandSet cmd_mode_commands;
+extern const CommandSet search_mode_commands;
+
+void cmdline_set_text(CommandLine *c, const char *text) NONNULL_ARGS;
+void cmdline_clear(CommandLine *c) NONNULL_ARGS;
+void cmdline_free(CommandLine *c) NONNULL_ARGS;
+
+#endif