From 1b8261071ef3ad3b8d1c2db6e712b0e590c563b3 Mon Sep 17 00:00:00 2001 From: cflip Date: Tue, 31 Jan 2023 13:31:21 -0700 Subject: Reimplement editor_prompt and 'Save as' using the new prompt mode Now there there is a new way to prompt for text, we can reimplement the long abandoned editor_prompt function and use it to allow saving to new files. The new editor_prompt function takes a callback that will be called after the user presses enter on the prompt. --- editor.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'editor.h') diff --git a/editor.h b/editor.h index e530956..2c64013 100644 --- a/editor.h +++ b/editor.h @@ -36,11 +36,14 @@ struct editor_state { struct textbuf cmdline; }; +typedef void (*prompt_callback_t)(struct editor_state*, char*, size_t); + void init_editor(struct editor_state* editor); void editor_set_status_message(struct editor_state* editor, const char* format, ...); -char* editor_prompt(struct editor_state* editor, char* prompt, void (*callback)(struct editor_state*, char*, int)); +void editor_prompt(struct editor_state* editor, char* prompt, prompt_callback_t callback); void editor_run_command(struct editor_state *editor); +void editor_try_save(struct editor_state *editor); void editor_try_quit(struct editor_state *editor); void editor_move_left(struct editor_state *); -- cgit v1.2.3