esc

Externally Scriptable Editor

git clone git://mccd.space/esc

commit f45e6f4c4616d2e8503b7ef2c1cc3ac405d465dc
parent 9fcc86a85fac750156a7d828e8aa2ebb2a7bbbf8
Author: Marc Coquand <marc@coquand.email>
Date:   Wed, 25 Feb 2026 17:14:56 +0100

Add autocomplete handling (?)

Diffstat:
Mmain.c | 25+++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)
diff --git a/main.c b/main.c
@@ -293,7 +293,32 @@ static void sig_quit(int sig) {
 	SDL_PushEvent(&ev);
 }
 
+static void handle_completion(int argc, char *argv[]) {
+	if (argc < 3) {
+		return;
+	}
+	
+	if (strcmp(argv[1], "completion") == 0 && strcmp(argv[2], "bash") == 0) {
+		// Handle bash completion
+		const char *current_word = getenv("COMP_WORDS");
+		const char *cursor_pos = getenv("COMP_POINT");
+		
+		if (!current_word || !cursor_pos) {
+			return;
+		}
+		
+		// Simple file/directory completion
+		printf("_filedir\n");
+		exit(0);
+	}
+}
+
 int main(int argc, char *argv[]) {
+	// Handle completion subcommand before initializing SDL
+	if (argc >= 2) {
+		handle_completion(argc, argv);
+	}
+	
 	// Otherwise wayland just wouldn't load.
 	SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland",
 				SDL_HINT_OVERRIDE);