diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core-commands.c | 10 | ||||
| -rw-r--r-- | src/core-commands.h | 9 | ||||
| -rw-r--r-- | src/search.c | 19 |
3 files changed, 18 insertions, 20 deletions
diff --git a/src/core-commands.c b/src/core-commands.c index e756eab..faf1c48 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -643,7 +643,7 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) ['"'] = {&teco_state_condcommand}, ['E'] = {&teco_state_ecommand, .modifier_at = TRUE, .modifier_colon = 2}, - ['I'] = {&teco_state_insert_plain, + ['I'] = {&teco_state_insert, .modifier_at = TRUE}, ['?'] = {&teco_state_help, .modifier_at = TRUE}, @@ -2962,7 +2962,7 @@ teco_state_insert_done(teco_machine_main_t *ctx, const teco_string_t *str, GErro * may be better, since it has string building characters * disabled. */ -TECO_DEFINE_STATE_INSERT(teco_state_insert_plain); +TECO_DEFINE_STATE_INSERT(teco_state_insert); static gboolean teco_state_insert_indent_initial(teco_machine_main_t *ctx, GError **error) @@ -2995,6 +2995,12 @@ teco_state_insert_indent_initial(teco_machine_main_t *ctx, GError **error) return TRUE; } +static teco_state_t * +teco_state_insert_indent_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) +{ + return teco_state_insert_done(ctx, str, error); +} + /* * Alternatives: ^i, ^I, <CTRL/I>, <TAB> */ diff --git a/src/core-commands.h b/src/core-commands.h index 4cc8747..8f8966f 100644 --- a/src/core-commands.h +++ b/src/core-commands.h @@ -88,14 +88,9 @@ gboolean teco_state_insert_process_edit_cmd(teco_machine_main_t *ctx, teco_machi * @ingroup states * * @note Also serves as a base class of the replace-insertion commands. - * @fixme Generating the done_cb could be avoided if there simply were a default. + * @note You must always define a done_cb(). */ #define TECO_DEFINE_STATE_INSERT(NAME, ...) \ - static teco_state_t * \ - NAME##_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) \ - { \ - return teco_state_insert_done(ctx, str, error); \ - } \ TECO_DEFINE_STATE_EXPECTSTRING(NAME, \ .initial_cb = (teco_state_initial_cb_t)teco_state_insert_initial, \ .process_edit_cmd_cb = (teco_state_process_edit_cmd_cb_t)teco_state_insert_process_edit_cmd, \ @@ -103,7 +98,7 @@ gboolean teco_state_insert_process_edit_cmd(teco_machine_main_t *ctx, teco_machi ##__VA_ARGS__ \ ) -TECO_DECLARE_STATE(teco_state_insert_plain); +TECO_DECLARE_STATE(teco_state_insert); TECO_DECLARE_STATE(teco_state_insert_indent); /** diff --git a/src/search.c b/src/search.c index 0875a9a..83e22ef 100644 --- a/src/search.c +++ b/src/search.c @@ -1226,6 +1226,12 @@ teco_state_replace_insert_initial(teco_machine_main_t *ctx, GError **error) return TRUE; } +static teco_state_t * +teco_state_replace_insert_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) +{ + return teco_state_insert_done(ctx, str, error); +} + /* * FIXME: Could be static */ @@ -1288,16 +1294,8 @@ TECO_DEFINE_STATE_SEARCH(teco_state_replace, .expectstring.last = FALSE ); -/* - * FIXME: TECO_DEFINE_STATE_INSERT() already defines a done_cb(), - * so we had to name this differently. - * Perhaps it simply shouldn't define it. - * Even better, we should perhaps avoid generating "required" callback - * names (e.g. in TECO_DEFINE_STATE_EXPECTSTRING()) as it does more harm - * than it helps and only spreads confusion. - */ static teco_state_t * -teco_state_replace_default_insert_done_overwrite(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) +teco_state_replace_default_insert_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; @@ -1327,8 +1325,7 @@ teco_state_replace_default_insert_done_overwrite(teco_machine_main_t *ctx, const * FIXME: Could be static */ TECO_DEFINE_STATE_INSERT(teco_state_replace_default_insert, - .initial_cb = (teco_state_initial_cb_t)teco_state_replace_insert_initial, - .expectstring.done_cb = teco_state_replace_default_insert_done_overwrite + .initial_cb = (teco_state_initial_cb_t)teco_state_replace_insert_initial ); static teco_state_t * |
