Add search function
Build project / build (push) Has been cancelled

This commit is contained in:
arthur
2025-11-03 16:45:23 +01:00
parent 6a201b3ebc
commit 419e924650
8 changed files with 44 additions and 2 deletions
+18
View File
@@ -110,3 +110,21 @@ void editorSave() {
free(buf);
editorSetStatusMessage("Can't save! I/O error: %s", strerror(errno));
}
void editorFind() {
char *query = editorPrompt("Search: %s (ESC to cancel)");
if (query == NULL) return;
int i;
for (i = 0; i < E.numrows; i++) {
erow *row = &E.row[i];
char *match = strstr(row->render, query);
if (match) {
E.cursor_y = i;
E.cursor_x = editorRowRxToCx(row, match - row->render);
E.row_offset = E.numrows;
break;
}
}
free(query);
}