esc

Externally Scriptable Editor

git clone git://mccd.space/esc

commit 3581dfe2b9200a5004fae2d80e38aff37f88e436
parent d63238060080134de3863ef9090313672c5cf980
Author: Marc Coquand <marc@coquand.email>
Date:   Wed, 25 Feb 2026 15:31:34 +0100

Revert "test out the new clipboard changes"

This reverts commit e51fda723d45058942f28fd5e81edb66e9a2299e.

Diffstat:
Mmain.c | 28+---------------------------
1 file changed, 1 insertion(+), 27 deletions(-)
diff --git a/main.c b/main.c
@@ -22,7 +22,6 @@ void handle_events(Editor *ed, SDL_Renderer *renderer, float *scroll_x,
 		   bool *is_dragging) {
 	SDL_Event event;
 	char *cmd;
-	static char *last_primary_selection = NULL;
 
 	if (SDL_WaitEvent(&event)) {
 		do {
@@ -239,7 +238,6 @@ void handle_events(Editor *ed, SDL_Renderer *renderer, float *scroll_x,
 						if (SDL_HasPrimarySelectionText()) {
 							char *text =
 							    SDL_GetPrimarySelectionText();
-							SDL_Log("Got primary selection: %s", text ? text : "(null)");
 							if (text) {
 								editor_insert_text(
 								    ed, text,
@@ -279,33 +277,9 @@ void handle_events(Editor *ed, SDL_Renderer *renderer, float *scroll_x,
 		if (editor_has_selection(ed)) {
 			char *sel = editor_get_selection(ed);
 			if (sel) {
-				// Only update primary selection if it changed
-				bool selection_changed = (last_primary_selection == NULL || 
-				                        strcmp(last_primary_selection, sel) != 0);
-				
-				if (selection_changed) {
-					SDL_SetPrimarySelectionText(sel);
-					SDL_Log("Set primary selection: %s", sel);
-					
-					// Also try to set it using wl-copy as a fallback for external tools
-					char cmd[1024];
-					snprintf(cmd, sizeof(cmd), "wl-copy --primary '%s'", sel);
-					unix_exec_command(cmd, NULL);
-					
-					// Update the last selection
-					if (last_primary_selection) {
-						free(last_primary_selection);
-					}
-					last_primary_selection = strdup(sel);
-				}
+				SDL_SetPrimarySelectionText(sel);
 				free(sel);
 			}
-		} else {
-			// No selection, clear the last selection
-			if (last_primary_selection) {
-				free(last_primary_selection);
-				last_primary_selection = NULL;
-			}
 		}
 	}
 }