@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user