diff options
Diffstat (limited to 'src/core-commands.c')
| -rw-r--r-- | src/core-commands.c | 70 |
1 files changed, 42 insertions, 28 deletions
diff --git a/src/core-commands.c b/src/core-commands.c index 58a1ea2..32381f7 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -52,6 +52,7 @@ static teco_state_t *teco_state_control_input(teco_machine_main_t *ctx, gunichar chr, GError **error); static teco_state_t *teco_state_ctlc_control_input(teco_machine_main_t *ctx, gunichar chr, GError **error); +static teco_state_t *teco_state_endcond(teco_machine_main_t *ctx, const gchar *cmd, GError **error); /** * Translate buffer range arguments from the expression stack to @@ -750,7 +751,8 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) if (teco_is_noop(chr)) { if (ctx->flags.modifier_at || (ctx->flags.mode == TECO_MODE_NORMAL && ctx->flags.modifier_colon)) { - teco_error_modifier_set(error, chr); + gchar cmd[] = {chr, '\0'}; + teco_error_modifier_set(error, cmd); return NULL; } return &teco_state_start; @@ -776,7 +778,8 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) case '0' ... '9': if (ctx->flags.modifier_at || (ctx->flags.mode == TECO_MODE_NORMAL && ctx->flags.modifier_colon)) { - teco_error_modifier_set(error, chr); + gchar cmd[] = {chr, '\0'}; + teco_error_modifier_set(error, cmd); return NULL; } if (ctx->flags.mode == TECO_MODE_NORMAL) @@ -835,7 +838,7 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) case '|': if (ctx->flags.modifier_at || (ctx->flags.mode == TECO_MODE_NORMAL && ctx->flags.modifier_colon)) { - teco_error_modifier_set(error, '|'); + teco_error_modifier_set(error, "|"); return NULL; } if (ctx->parent.must_undo) @@ -847,29 +850,7 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) ctx->flags.mode = TECO_MODE_PARSE_ONLY_COND; return &teco_state_start; - case '\'': - if (ctx->flags.modifier_at || - (ctx->flags.mode == TECO_MODE_NORMAL && ctx->flags.modifier_colon)) { - teco_error_modifier_set(error, '\''); - return NULL; - } - switch (ctx->flags.mode) { - case TECO_MODE_PARSE_ONLY_COND: - case TECO_MODE_PARSE_ONLY_COND_FORCE: - if (!ctx->nest_level) { - if (ctx->parent.must_undo) - teco_undo_flags(ctx->flags); - ctx->flags.mode = TECO_MODE_NORMAL; - } else { - if (ctx->parent.must_undo) - teco_undo_gint(ctx->nest_level); - ctx->nest_level--; - } - break; - default: - break; - } - return &teco_state_start; + case '\'': return teco_state_endcond(ctx, "'", error); /* * Word movement and deletion commands. @@ -895,7 +876,7 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) */ case '@': if (ctx->flags.modifier_at) { - teco_error_modifier_set(error, '@'); + teco_error_modifier_set(error, "@"); return NULL; } /* @@ -913,7 +894,7 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; if (ctx->flags.modifier_colon >= 2) { - teco_error_modifier_set(error, ':'); + teco_error_modifier_set(error, ":"); return NULL; } if (ctx->parent.must_undo) @@ -1096,6 +1077,10 @@ teco_state_fcommand_input(teco_machine_main_t *ctx, gunichar chr, GError **error ['|'] = {&teco_state_start, teco_state_fcommand_cond_else} }; + switch (chr) { + case '"': return teco_state_endcond(ctx, "F\"", error); + } + return teco_machine_main_transition_input(ctx, transitions, G_N_ELEMENTS(transitions), teco_ascii_toupper(chr), error); } @@ -1315,6 +1300,35 @@ TECO_DEFINE_STATE_COMMAND(teco_state_condcommand, .input_cb = (teco_state_input_cb_t)teco_state_condcommand_input ); +static teco_state_t * +teco_state_endcond(teco_machine_main_t *ctx, const gchar *cmd, GError **error) +{ + if (ctx->flags.modifier_at || + (ctx->flags.mode == TECO_MODE_NORMAL && ctx->flags.modifier_colon)) { + teco_error_modifier_set(error, cmd); + return NULL; + } + + switch (ctx->flags.mode) { + case TECO_MODE_PARSE_ONLY_COND: + case TECO_MODE_PARSE_ONLY_COND_FORCE: + if (!ctx->nest_level) { + if (ctx->parent.must_undo) + teco_undo_flags(ctx->flags); + ctx->flags.mode = TECO_MODE_NORMAL; + } else { + if (ctx->parent.must_undo) + teco_undo_gint(ctx->nest_level); + ctx->nest_level--; + } + break; + default: + break; + } + + return &teco_state_start; +} + /*$ ^_ negate * n^_ -> ~n -- Binary negation * |
