diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cmdline.c | 4 | ||||
-rw-r--r-- | src/core-commands.c | 128 | ||||
-rw-r--r-- | src/glob.c | 4 | ||||
-rw-r--r-- | src/goto-commands.c | 10 | ||||
-rw-r--r-- | src/help.c | 4 | ||||
-rw-r--r-- | src/lexer.c | 8 | ||||
-rw-r--r-- | src/move-commands.c | 4 | ||||
-rw-r--r-- | src/parser.c | 34 | ||||
-rw-r--r-- | src/parser.h | 48 | ||||
-rw-r--r-- | src/qreg-commands.c | 30 | ||||
-rw-r--r-- | src/qreg.c | 46 | ||||
-rw-r--r-- | src/ring.c | 6 | ||||
-rw-r--r-- | src/search.c | 24 | ||||
-rw-r--r-- | src/spawn.c | 6 | ||||
-rw-r--r-- | src/symbols.c | 4 |
15 files changed, 178 insertions, 182 deletions
diff --git a/src/cmdline.c b/src/cmdline.c index e367e9a..b03f72a 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -552,7 +552,7 @@ teco_state_command_process_edit_cmd(teco_machine_main_t *ctx, teco_machine_t *pa * be part of another command. */ while (ctx->parent.current->is_start && - (ctx->modifier_at || ctx->modifier_colon) && + (ctx->flags.modifier_at || ctx->flags.modifier_colon) && teco_cmdline.effective_len > 0) teco_cmdline_rubout(); @@ -1375,7 +1375,7 @@ teco_state_save_cmdline_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg { teco_state_expectqreg_reset(ctx); - if (ctx->mode != TECO_MODE_NORMAL) + if (ctx->flags.mode != TECO_MODE_NORMAL) return &teco_state_start; if (!qreg->vtable->undo_set_string(qreg, error) || diff --git a/src/core-commands.c b/src/core-commands.c index 7506e2e..dbf86bd 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -299,8 +299,8 @@ teco_state_start_loop_open(teco_machine_main_t *ctx, GError **error) } else { /* skip to end of loop */ if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->mode = TECO_MODE_PARSE_ONLY_LOOP; + teco_undo_flags(ctx->flags); + ctx->flags.mode = TECO_MODE_PARSE_ONLY_LOOP; } } @@ -427,8 +427,8 @@ teco_state_start_break(teco_machine_main_t *ctx, GError **error) /* skip to end of loop */ if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->mode = TECO_MODE_PARSE_ONLY_LOOP; + teco_undo_flags(ctx->flags); + ctx->flags.mode = TECO_MODE_PARSE_ONLY_LOOP; } /*$ "{" "}" @@ -717,8 +717,8 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) case '\r': case '\n': case '\v': - if (ctx->modifier_at || - (ctx->mode == TECO_MODE_NORMAL && ctx->modifier_colon)) { + if (ctx->flags.modifier_at || + (ctx->flags.mode == TECO_MODE_NORMAL && ctx->flags.modifier_colon)) { teco_error_modifier_set(error, chr); return NULL; } @@ -741,12 +741,12 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) * current radix - this may be changed in the future. */ case '0' ... '9': - if (ctx->modifier_at || - (ctx->mode == TECO_MODE_NORMAL && ctx->modifier_colon)) { + if (ctx->flags.modifier_at || + (ctx->flags.mode == TECO_MODE_NORMAL && ctx->flags.modifier_colon)) { teco_error_modifier_set(error, chr); return NULL; } - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) teco_expressions_add_digit(chr, ctx->qreg_table_locals->radix); return &teco_state_start; @@ -763,12 +763,12 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) break; case '<': - if (ctx->modifier_at) { + if (ctx->flags.modifier_at) { g_set_error_literal(error, TECO_ERROR, TECO_ERROR_MODIFIER, "Unexpected modifier on loop start"); return NULL; } - if (ctx->mode != TECO_MODE_PARSE_ONLY_LOOP) + if (ctx->flags.mode != TECO_MODE_PARSE_ONLY_LOOP) break; if (ctx->parent.must_undo) teco_undo_gint(ctx->nest_level); @@ -776,17 +776,17 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) return &teco_state_start; case '>': - if (ctx->modifier_at) { + if (ctx->flags.modifier_at) { g_set_error_literal(error, TECO_ERROR, TECO_ERROR_MODIFIER, "Unexpected modifier on loop end"); return NULL; } - if (ctx->mode != TECO_MODE_PARSE_ONLY_LOOP) + if (ctx->flags.mode != TECO_MODE_PARSE_ONLY_LOOP) break; if (!ctx->nest_level) { if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->mode = TECO_MODE_NORMAL; + teco_undo_flags(ctx->flags); + ctx->flags.mode = TECO_MODE_NORMAL; } else { if (ctx->parent.must_undo) teco_undo_gint(ctx->nest_level); @@ -798,33 +798,33 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) * Control Structures (conditionals) */ case '|': - if (ctx->modifier_at || - (ctx->mode == TECO_MODE_NORMAL && ctx->modifier_colon)) { + if (ctx->flags.modifier_at || + (ctx->flags.mode == TECO_MODE_NORMAL && ctx->flags.modifier_colon)) { teco_error_modifier_set(error, '|'); return NULL; } if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - if (ctx->mode == TECO_MODE_PARSE_ONLY_COND && !ctx->nest_level) - ctx->mode = TECO_MODE_NORMAL; - else if (ctx->mode == TECO_MODE_NORMAL) + teco_undo_flags(ctx->flags); + if (ctx->flags.mode == TECO_MODE_PARSE_ONLY_COND && !ctx->nest_level) + ctx->flags.mode = TECO_MODE_NORMAL; + else if (ctx->flags.mode == TECO_MODE_NORMAL) /* skip to end of conditional; skip ELSE-part */ - ctx->mode = TECO_MODE_PARSE_ONLY_COND; + ctx->flags.mode = TECO_MODE_PARSE_ONLY_COND; return &teco_state_start; case '\'': - if (ctx->modifier_at || - (ctx->mode == TECO_MODE_NORMAL && ctx->modifier_colon)) { + if (ctx->flags.modifier_at || + (ctx->flags.mode == TECO_MODE_NORMAL && ctx->flags.modifier_colon)) { teco_error_modifier_set(error, '\''); return NULL; } - switch (ctx->mode) { + 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_guint(ctx->__flags); - ctx->mode = TECO_MODE_NORMAL; + teco_undo_flags(ctx->flags); + ctx->flags.mode = TECO_MODE_NORMAL; } else { if (ctx->parent.must_undo) teco_undo_gint(ctx->nest_level); @@ -859,7 +859,7 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) * Modifiers */ case '@': - if (ctx->modifier_at) { + if (ctx->flags.modifier_at) { teco_error_modifier_set(error, '@'); return NULL; } @@ -870,20 +870,20 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) * everywhere, even where it has no syntactic significance. */ if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->modifier_at = TRUE; + teco_undo_flags(ctx->flags); + ctx->flags.modifier_at = TRUE; return &teco_state_start; case ':': - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; - if (ctx->modifier_colon >= 2) { + if (ctx->flags.modifier_colon >= 2) { teco_error_modifier_set(error, ':'); return NULL; } if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->modifier_colon++; + teco_undo_flags(ctx->flags); + ctx->flags.modifier_colon++; return &teco_state_start; default: @@ -995,8 +995,8 @@ teco_state_fcommand_loop_end(teco_machine_main_t *ctx, GError **error) if (teco_loop_stack->len < old_len) { /* skip to end of loop */ if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->mode = TECO_MODE_PARSE_ONLY_LOOP; + teco_undo_flags(ctx->flags); + ctx->flags.mode = TECO_MODE_PARSE_ONLY_LOOP; } } @@ -1008,8 +1008,8 @@ teco_state_fcommand_cond_end(teco_machine_main_t *ctx, GError **error) { /* skip to end of conditional, also including any else-clause */ if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->mode = TECO_MODE_PARSE_ONLY_COND_FORCE; + teco_undo_flags(ctx->flags); + ctx->flags.mode = TECO_MODE_PARSE_ONLY_COND_FORCE; } /*$ F| @@ -1024,8 +1024,8 @@ teco_state_fcommand_cond_else(teco_machine_main_t *ctx, GError **error) { /* skip to ELSE-part or end of conditional */ if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->mode = TECO_MODE_PARSE_ONLY_COND; + teco_undo_flags(ctx->flags); + ctx->flags.mode = TECO_MODE_PARSE_ONLY_COND; } static teco_state_t * @@ -1091,7 +1091,7 @@ teco_undo_change_dir_to_current(void) static teco_state_t * teco_state_changedir_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; g_autofree gchar *dir = teco_file_expand_path(str->data); @@ -1165,7 +1165,7 @@ teco_state_condcommand_input(teco_machine_main_t *ctx, gunichar chr, GError **er teco_int_t value = 0; gboolean result = TRUE; - switch (ctx->mode) { + switch (ctx->flags.mode) { case TECO_MODE_PARSE_ONLY_COND: case TECO_MODE_PARSE_ONLY_COND_FORCE: if (ctx->parent.must_undo) @@ -1195,65 +1195,65 @@ teco_state_condcommand_input(teco_machine_main_t *ctx, gunichar chr, GError **er switch (teco_ascii_toupper(chr)) { case '~': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = !teco_expressions_args(); break; case 'A': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = g_unichar_isalpha(value); break; case 'C': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = g_unichar_isalnum(value) || value == '.' || value == '$' || value == '_'; break; case 'D': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = g_unichar_isdigit(value); break; case 'I': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = G_IS_DIR_SEPARATOR(value); break; case 'S': case 'T': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = teco_is_success(value); break; case 'F': case 'U': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = teco_is_failure(value); break; case 'E': case '=': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = value == 0; break; case 'G': case '>': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = value > 0; break; case 'L': case '<': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = value < 0; break; case 'N': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = value != 0; break; case 'R': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = g_unichar_isalnum(value); break; case 'V': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = g_unichar_islower(value); break; case 'W': - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) result = g_unichar_isupper(value); break; default: @@ -1265,8 +1265,8 @@ teco_state_condcommand_input(teco_machine_main_t *ctx, gunichar chr, GError **er if (!result) { /* skip to ELSE-part or end of conditional */ if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->mode = TECO_MODE_PARSE_ONLY_COND; + teco_undo_flags(ctx->flags); + ctx->flags.mode = TECO_MODE_PARSE_ONLY_COND; } return &teco_state_start; @@ -1622,7 +1622,7 @@ TECO_DEFINE_STATE_COMMAND(teco_state_control); static teco_state_t * teco_state_ascii_input(teco_machine_main_t *ctx, gunichar chr, GError **error) { - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) teco_expressions_push(chr); return &teco_state_start; @@ -1695,7 +1695,7 @@ teco_state_escape_input(teco_machine_main_t *ctx, gunichar chr, GError **error) * or a dollar character. */ if (chr == '\e' || chr == '$') { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; ctx->parent.current = &teco_state_start; @@ -1727,7 +1727,7 @@ teco_state_escape_input(teco_machine_main_t *ctx, gunichar chr, GError **error) * Additionally, this command may be written as a single * dollar character. */ - if (ctx->mode == TECO_MODE_NORMAL && + if (ctx->flags.mode == TECO_MODE_NORMAL && !teco_expressions_discard_args(error)) return NULL; return teco_state_start_input(ctx, chr, error); @@ -2565,7 +2565,7 @@ TECO_DEFINE_STATE_COMMAND(teco_state_ecommand); gboolean teco_state_insert_initial(teco_machine_main_t *ctx, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return TRUE; teco_undo_gsize(teco_ranges[0].from) = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0); @@ -2650,7 +2650,7 @@ teco_state_insert_process(teco_machine_main_t *ctx, const teco_string_t *str, teco_state_t * teco_state_insert_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) teco_undo_gsize(teco_ranges[0].to) = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0); return &teco_state_start; @@ -2696,7 +2696,7 @@ TECO_DEFINE_STATE_INSERT(teco_state_insert_nobuilding, static gboolean teco_state_insert_indent_initial(teco_machine_main_t *ctx, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return TRUE; if (!teco_state_insert_initial(ctx, error)) @@ -310,7 +310,7 @@ teco_globber_compile_pattern(const gchar *pattern) static teco_state_t * teco_state_glob_pattern_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_glob_filename; if (str->len > 0) { @@ -460,7 +460,7 @@ TECO_DEFINE_STATE_EXPECTGLOB(teco_state_glob_pattern, static teco_state_t * teco_state_glob_filename_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; GFileTest file_flags = G_FILE_TEST_EXISTS; diff --git a/src/goto-commands.c b/src/goto-commands.c index e335c70..a0e6634 100644 --- a/src/goto-commands.c +++ b/src/goto-commands.c @@ -76,8 +76,8 @@ teco_state_label_input(teco_machine_main_t *ctx, gunichar chr, GError **error) memset(&teco_goto_skip_label, 0, sizeof(teco_goto_skip_label)); if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->mode = TECO_MODE_NORMAL; + teco_undo_flags(ctx->flags); + ctx->flags.mode = TECO_MODE_NORMAL; } } else if (existing_pc != ctx->macro_pc) { g_autofree gchar *label_printable = teco_string_echo(ctx->goto_label.data, @@ -115,7 +115,7 @@ TECO_DEFINE_STATE(teco_state_label, static teco_state_t * teco_state_goto_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; teco_int_t value; @@ -148,8 +148,8 @@ teco_state_goto_done(teco_machine_main_t *ctx, const teco_string_t *str, GError undo__teco_string_truncate(&teco_goto_skip_label, 0); teco_string_init(&teco_goto_skip_label, label.data, label.len); if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->mode = TECO_MODE_PARSE_ONLY_GOTO; + teco_undo_flags(ctx->flags); + ctx->flags.mode = TECO_MODE_PARSE_ONLY_GOTO; } } @@ -258,7 +258,7 @@ teco_help_cleanup(void) static gboolean teco_state_help_initial(teco_machine_main_t *ctx, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return TRUE; /* @@ -273,7 +273,7 @@ teco_state_help_initial(teco_machine_main_t *ctx, GError **error) static teco_state_t * teco_state_help_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; if (teco_string_contains(str, '\0')) { diff --git a/src/lexer.c b/src/lexer.c index 84ddcc3..5e6202d 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -64,7 +64,7 @@ teco_lexer_getstyle(teco_view_t *view, teco_machine_main_t *machine, gsize macro_pc = machine->macro_pc; teco_machine_main_clear(machine); teco_machine_main_init(machine, NULL, FALSE); - machine->mode = TECO_MODE_LEXING; + machine->flags.mode = TECO_MODE_LEXING; machine->macro_pc = macro_pc; return SCE_SCITECO_INVALID; @@ -164,7 +164,7 @@ teco_lexer_step(teco_view_t *view, teco_machine_main_t *machine, if (style != SCE_SCITECO_INVALID && machine->parent.current->keymacro_mask & TECO_KEYMACRO_MASK_START && - !machine->modifier_at) + !machine->flags.modifier_at) /* clean parser state */ *safe_col = *cur_col; } @@ -206,12 +206,12 @@ teco_lexer_style(teco_view_t *view, gsize end) g_auto(teco_machine_main_t) machine; teco_machine_main_init(&machine, NULL, FALSE); - machine.mode = TECO_MODE_LEXING; + machine.flags.mode = TECO_MODE_LEXING; /* for lexing the contents of @^Uq{...} */ g_auto(teco_machine_main_t) macrodef_machine; teco_machine_main_init(¯odef_machine, NULL, FALSE); - macrodef_machine.mode = TECO_MODE_LEXING; + macrodef_machine.flags.mode = TECO_MODE_LEXING; g_assert(start_col >= 0); guint col = start_col; diff --git a/src/move-commands.c b/src/move-commands.c index cfa36ad..6324131 100644 --- a/src/move-commands.c +++ b/src/move-commands.c @@ -374,7 +374,7 @@ teco_state_start_words(teco_machine_main_t *ctx, const gchar *cmd, gint factor, */ gboolean modifier_at = teco_machine_main_eval_at(ctx); - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; teco_int_t v; @@ -442,7 +442,7 @@ teco_state_start_delete_words(teco_machine_main_t *ctx, const gchar *cmd, gint f */ gboolean modifier_at = teco_machine_main_eval_at(ctx); - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; teco_int_t v; diff --git a/src/parser.c b/src/parser.c index 044a741..c1d22b2 100644 --- a/src/parser.c +++ b/src/parser.c @@ -123,7 +123,7 @@ teco_machine_main_step(teco_machine_main_t *ctx, const gchar *macro, gsize stop_ #ifdef DEBUG g_printf("EXEC(%d): input='%C' (U+%04" G_GINT32_MODIFIER "X), state=%p, mode=%d\n", - ctx->macro_pc, chr, chr, ctx->parent.current, ctx->mode); + ctx->macro_pc, chr, chr, ctx->parent.current, ctx->flags.mode); #endif ctx->macro_pc = g_utf8_next_char(macro+ctx->macro_pc) - macro; @@ -306,6 +306,8 @@ teco_execute_file(const gchar *filename, teco_qreg_table_t *qreg_table_locals, G return TRUE; } +TECO_DEFINE_UNDO_SCALAR(teco_machine_main_flags_t); + void teco_machine_main_init(teco_machine_main_t *ctx, teco_qreg_table_t *qreg_table_locals, gboolean must_undo) @@ -323,25 +325,25 @@ teco_machine_main_init(teco_machine_main_t *ctx, teco_qreg_table_t *qreg_table_l guint teco_machine_main_eval_colon(teco_machine_main_t *ctx) { - guint c = ctx->modifier_colon; + guint c = ctx->flags.modifier_colon; if (c == 0) return 0; if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->modifier_colon = 0; + teco_undo_flags(ctx->flags); + ctx->flags.modifier_colon = 0; return c; } gboolean teco_machine_main_eval_at(teco_machine_main_t *ctx) { - if (!ctx->modifier_at) + if (!ctx->flags.modifier_at) return FALSE; if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->modifier_at = FALSE; + teco_undo_flags(ctx->flags); + ctx->flags.modifier_at = FALSE; return TRUE; } @@ -355,14 +357,14 @@ teco_machine_main_transition_input(teco_machine_main_t *ctx, return NULL; } - if ((ctx->modifier_at && !transitions[chr].modifier_at) || - (ctx->mode == TECO_MODE_NORMAL && - ctx->modifier_colon > transitions[chr].modifier_colon)) { + if ((ctx->flags.modifier_at && !transitions[chr].modifier_at) || + (ctx->flags.mode == TECO_MODE_NORMAL && + ctx->flags.modifier_colon > transitions[chr].modifier_colon)) { teco_error_modifier_set(error, chr); return NULL; } - if (ctx->mode == TECO_MODE_NORMAL && transitions[chr].transition_cb) { + if (ctx->flags.mode == TECO_MODE_NORMAL && transitions[chr].transition_cb) { /* * NOTE: We could also just let transition_cb return a boolean... */ @@ -944,7 +946,7 @@ teco_machine_stringbuilding_clear(teco_machine_stringbuilding_t *ctx) gboolean teco_state_expectstring_initial(teco_machine_main_t *ctx, GError **error) { - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) teco_machine_stringbuilding_set_codepage(&ctx->expectstring.machine, teco_default_codepage()); return TRUE; @@ -958,7 +960,7 @@ teco_state_expectstring_input(teco_machine_main_t *ctx, gunichar chr, GError **e /* * String termination handling */ - if (ctx->modifier_at) { + if (ctx->flags.modifier_at) { if (current->expectstring.last) /* also clears the "@" modifier flag */ teco_machine_main_eval_at(ctx); @@ -1049,7 +1051,7 @@ teco_state_expectstring_input(teco_machine_main_t *ctx, gunichar chr, GError **e * NOTE: Since we only ever append to `string`, this is more efficient * than teco_undo_string(ctx->expectstring.string). */ - if (ctx->mode == TECO_MODE_NORMAL && ctx->parent.must_undo) + if (ctx->flags.mode == TECO_MODE_NORMAL && ctx->parent.must_undo) undo__teco_string_truncate(&ctx->expectstring.string, ctx->expectstring.string.len); /* @@ -1057,11 +1059,11 @@ teco_state_expectstring_input(teco_machine_main_t *ctx, gunichar chr, GError **e */ gsize old_len = ctx->expectstring.string.len; if (current->expectstring.string_building) { - teco_string_t *str = ctx->mode == TECO_MODE_NORMAL + teco_string_t *str = ctx->flags.mode == TECO_MODE_NORMAL ? &ctx->expectstring.string : NULL; if (!teco_machine_stringbuilding_input(&ctx->expectstring.machine, chr, str, error)) return NULL; - } else if (ctx->mode == TECO_MODE_NORMAL) { + } else if (ctx->flags.mode == TECO_MODE_NORMAL) { teco_string_append_wc(&ctx->expectstring.string, chr); } diff --git a/src/parser.h b/src/parser.h index 050467c..5477150 100644 --- a/src/parser.h +++ b/src/parser.h @@ -16,8 +16,6 @@ */ #pragma once -#include <stdbool.h> - #include <glib.h> #include <Scintilla.h> @@ -52,7 +50,7 @@ typedef struct { * a signed integer, it's ok steal one * bit for the pass_through flag. */ - bool pass_through : 1; + guint pass_through : 1; } teco_loop_context_t; extern GArray *teco_loop_stack; @@ -77,8 +75,8 @@ void undo__remove_index__teco_loop_stack(guint); * FIXME: Maybe use TECO_DECLARE_VTABLE_METHOD()? */ typedef const struct { - bool string_building : 1; - bool last : 1; + guint string_building : 1; + guint last : 1; /** * Called repeatedly to process chunks of input and give interactive feedback. @@ -206,7 +204,7 @@ struct teco_state_t { * This is separate of TECO_KEYMACRO_MASK_START which is set * only in the main machine's start states. */ - bool is_start : 1; + guint is_start : 1; /** * Key macro mask. * This is not a bitmask since it is compared with values set @@ -476,25 +474,17 @@ struct teco_machine_main_t { /** Program counter, i.e. pointer to the next character in the current macro frame */ gsize macro_pc; - /** - * Aliases bitfield with an integer. - * This allows teco_undo_guint(__flags), - * while still supporting easy-to-access flags. - */ - union { - struct { - teco_mode_t mode : 8; - - /** number of `:`-modifiers detected */ - guint modifier_colon : 2; - /** - * Whether the `@`-modifier has been detected. - * This is tracked even in parse-only mode. - */ - bool modifier_at : 1; - }; - guint __flags; - }; + struct teco_machine_main_flags_t { + teco_mode_t mode : 8; + + /** number of `:`-modifiers detected */ + guint modifier_colon : 2; + /** + * Whether the `@`-modifier has been detected. + * This is tracked even in parse-only mode. + */ + guint modifier_at : 1; + } flags; /** The nesting level of braces */ guint brace_level; @@ -529,6 +519,12 @@ struct teco_machine_main_t { }; }; +typedef struct teco_machine_main_flags_t teco_machine_main_flags_t; +TECO_DECLARE_UNDO_SCALAR(teco_machine_main_flags_t); + +#define teco_undo_flags(VAR) \ + (*teco_undo_object_teco_machine_main_flags_t_push(&(VAR))) + void teco_machine_main_init(teco_machine_main_t *ctx, teco_qreg_table_t *qreg_table_locals, gboolean must_undo); @@ -564,7 +560,7 @@ typedef const struct { * Since `@` has syntactic significance, * it is checked even in parse-only mode. */ - bool modifier_at : 1; + guint modifier_at : 1; } teco_machine_main_transition_t; /* diff --git a/src/qreg-commands.c b/src/qreg-commands.c index 3da9c46..a4019a0 100644 --- a/src/qreg-commands.c +++ b/src/qreg-commands.c @@ -58,7 +58,7 @@ teco_state_expectqreg_input(teco_machine_main_t *ctx, gunichar chr, GError **err teco_qreg_table_t *table; switch (teco_machine_qregspec_input(ctx->expectqreg, chr, - ctx->mode == TECO_MODE_NORMAL ? &qreg : NULL, &table, error)) { + ctx->flags.mode == TECO_MODE_NORMAL ? &qreg : NULL, &table, error)) { case TECO_MACHINE_QREGSPEC_ERROR: return NULL; case TECO_MACHINE_QREGSPEC_MORE: @@ -81,7 +81,7 @@ teco_state_pushqreg_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg, { teco_state_expectqreg_reset(ctx); - return ctx->mode == TECO_MODE_NORMAL && + return ctx->flags.mode == TECO_MODE_NORMAL && !teco_qreg_stack_push(qreg, error) ? NULL : &teco_state_start; } @@ -99,7 +99,7 @@ teco_state_popqreg_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg, { teco_state_expectqreg_reset(ctx); - return ctx->mode == TECO_MODE_NORMAL && + return ctx->flags.mode == TECO_MODE_NORMAL && !teco_qreg_stack_pop(qreg, error) ? NULL : &teco_state_start; } @@ -143,7 +143,7 @@ teco_state_loadqreg_done(teco_machine_main_t *ctx, const teco_string_t *str, GEr teco_machine_qregspec_get_results(ctx->expectqreg, &qreg, &table); teco_state_expectqreg_reset(ctx); - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; if (str->len > 0) { @@ -198,7 +198,7 @@ teco_state_saveqreg_done(teco_machine_main_t *ctx, const teco_string_t *str, GEr teco_machine_qregspec_get_results(ctx->expectqreg, &qreg, NULL); teco_state_expectqreg_reset(ctx); - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; g_autofree gchar *filename = teco_file_expand_path(str->data); @@ -231,7 +231,7 @@ teco_state_queryqreg_initial(teco_machine_main_t *ctx, GError **error) * required Q-Registers. * In parse-only mode, the type does not matter. */ - teco_qreg_type_t type = ctx->modifier_colon ? TECO_QREG_OPTIONAL : TECO_QREG_REQUIRED; + teco_qreg_type_t type = ctx->flags.modifier_colon ? TECO_QREG_OPTIONAL : TECO_QREG_REQUIRED; /* * NOTE: We have to allocate a new instance always since `expectqreg` @@ -250,7 +250,7 @@ teco_state_queryqreg_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg, { teco_state_expectqreg_reset(ctx); - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; if (!teco_expressions_eval(FALSE, error)) @@ -363,7 +363,7 @@ teco_state_setqregstring_nobuilding_done(teco_machine_main_t *ctx, teco_machine_qregspec_get_results(ctx->expectqreg, &qreg, NULL); teco_state_expectqreg_reset(ctx); - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; gboolean colon_modified = teco_machine_main_eval_colon(ctx) > 0; @@ -482,7 +482,7 @@ TECO_DEFINE_STATE_EXPECTQREG(teco_state_eucommand, static gboolean teco_state_setqregstring_building_initial(teco_machine_main_t *ctx, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return TRUE; teco_qreg_t *qreg; @@ -526,7 +526,7 @@ teco_state_getqregstring_got_register(teco_machine_main_t *ctx, teco_qreg_t *qre { teco_state_expectqreg_reset(ctx); - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; g_auto(teco_string_t) str = {NULL, 0}; @@ -566,7 +566,7 @@ teco_state_setqreginteger_got_register(teco_machine_main_t *ctx, teco_qreg_t *qr { teco_state_expectqreg_reset(ctx); - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; if (!teco_expressions_eval(FALSE, error)) @@ -616,7 +616,7 @@ teco_state_increaseqreg_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg { teco_state_expectqreg_reset(ctx); - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; teco_int_t value, add; @@ -650,7 +650,7 @@ teco_state_macro_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg, { teco_state_expectqreg_reset(ctx); - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; if (teco_machine_main_eval_colon(ctx) > 0) { @@ -705,7 +705,7 @@ TECO_DEFINE_STATE_EXPECTQREG(teco_state_macro); static teco_state_t * teco_state_macrofile_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; g_autofree gchar *filename = teco_file_expand_path(str->data); @@ -754,7 +754,7 @@ teco_state_copytoqreg_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg, */ gboolean modifier_at = teco_machine_main_eval_at(ctx); - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; gssize from, len; /* in bytes */ @@ -18,7 +18,6 @@ #include "config.h" #endif -#include <stdbool.h> #include <string.h> #include <glib.h> @@ -1354,18 +1353,10 @@ error_add_frame: struct teco_machine_qregspec_t { teco_machine_t parent; - /** - * Aliases bitfield with an integer. - * This allows teco_undo_guint(__flags), - * while still supporting easy-to-access flags. - */ - union { - struct { - teco_qreg_type_t type : 8; - bool parse_only : 1; - }; - guint __flags; - }; + struct teco_machine_qregspec_flags_t { + teco_qreg_type_t type : 8; + guint parse_only : 1; + } flags; /** Local Q-Register table of the macro invocation frame. */ teco_qreg_table_t *qreg_table_locals; @@ -1374,6 +1365,7 @@ struct teco_machine_qregspec_t { /* * FIXME: Does it make sense to allow nested braces? * Perhaps it's sufficient to support ^Q]. + * We might also want to include it in the bitfield above. */ gint nesting; teco_string_t name; @@ -1382,6 +1374,12 @@ struct teco_machine_qregspec_t { teco_qreg_table_t *result_table; }; +typedef struct teco_machine_qregspec_flags_t teco_machine_qregspec_flags_t; +TECO_DEFINE_UNDO_SCALAR(teco_machine_qregspec_flags_t); + +#define teco_undo_qregspec_flags(VAR) \ + (*teco_undo_object_teco_machine_qregspec_flags_t_push(&(VAR))) + /* * FIXME: All teco_state_qregspec_* states could be static? */ @@ -1398,12 +1396,12 @@ static teco_state_t *teco_state_qregspec_start_global_input(teco_machine_qregspe static teco_state_t * teco_state_qregspec_done(teco_machine_qregspec_t *ctx, GError **error) { - if (ctx->parse_only) + if (ctx->flags.parse_only) return &teco_state_qregspec_start; ctx->result = teco_qreg_table_find(ctx->result_table, ctx->name.data, ctx->name.len); - switch (ctx->type) { + switch (ctx->flags.type) { case TECO_QREG_REQUIRED: if (!ctx->result) { teco_error_invalidqreg_set(error, ctx->name.data, ctx->name.len, @@ -1473,7 +1471,7 @@ teco_state_qregspec_start_global_input(teco_machine_qregspec_t *ctx, gunichar ch return &teco_state_qregspec_string; } - if (!ctx->parse_only) { + if (!ctx->flags.parse_only) { if (ctx->parent.must_undo) undo__teco_string_truncate(&ctx->name, ctx->name.len); teco_string_append_wc(&ctx->name, g_unichar_toupper(chr)); @@ -1500,7 +1498,7 @@ teco_state_qregspec_caret_input(teco_machine_qregspec_t *ctx, gunichar chr, GErr return NULL; } - if (!ctx->parse_only) { + if (!ctx->flags.parse_only) { if (ctx->parent.must_undo) undo__teco_string_truncate(&ctx->name, ctx->name.len); teco_string_append_wc(&ctx->name, TECO_CTL_KEY(chr)); @@ -1516,7 +1514,7 @@ teco_state_qregspec_firstchar_input(teco_machine_qregspec_t *ctx, gunichar chr, /* * FIXME: Disallow space characters? */ - if (!ctx->parse_only) { + if (!ctx->flags.parse_only) { if (ctx->parent.must_undo) undo__teco_string_truncate(&ctx->name, ctx->name.len); teco_string_append_wc(&ctx->name, g_unichar_toupper(chr)); @@ -1534,7 +1532,7 @@ teco_state_qregspec_secondchar_input(teco_machine_qregspec_t *ctx, gunichar chr, /* * FIXME: Disallow space characters? */ - if (!ctx->parse_only) { + if (!ctx->flags.parse_only) { if (ctx->parent.must_undo) undo__teco_string_truncate(&ctx->name, ctx->name.len); teco_string_append_wc(&ctx->name, g_unichar_toupper(chr)); @@ -1572,7 +1570,7 @@ teco_state_qregspec_string_input(teco_machine_qregspec_t *ctx, gunichar chr, GEr } } - if (!ctx->parse_only && ctx->parent.must_undo) + if (!ctx->flags.parse_only && ctx->parent.must_undo) undo__teco_string_truncate(&ctx->name, ctx->name.len); /* @@ -1580,7 +1578,7 @@ teco_state_qregspec_string_input(teco_machine_qregspec_t *ctx, gunichar chr, GEr * as the target string. */ if (!teco_machine_stringbuilding_input(&ctx->machine_stringbuilding, chr, - ctx->parse_only ? NULL : &ctx->name, error)) + ctx->flags.parse_only ? NULL : &ctx->name, error)) return NULL; return &teco_state_qregspec_string; @@ -1606,7 +1604,7 @@ teco_machine_qregspec_new(teco_qreg_type_t type, teco_qreg_table_t *locals, gboo */ teco_machine_qregspec_t *ctx = g_new0(teco_machine_qregspec_t, 1); teco_machine_init(&ctx->parent, &teco_state_qregspec_start, must_undo); - ctx->type = type; + ctx->flags.type = type; ctx->qreg_table_locals = locals; teco_machine_stringbuilding_init(&ctx->machine_stringbuilding, '[', locals, must_undo); ctx->result_table = &teco_qreg_table_globals; @@ -1622,7 +1620,7 @@ teco_machine_qregspec_reset(teco_machine_qregspec_t *ctx) if (ctx->parent.must_undo) { teco_undo_string_own(ctx->name); teco_undo_gint(ctx->nesting); - teco_undo_guint(ctx->__flags); + teco_undo_qregspec_flags(ctx->flags); } else { teco_string_clear(&ctx->name); } @@ -1655,7 +1653,7 @@ teco_machine_qregspec_status_t teco_machine_qregspec_input(teco_machine_qregspec_t *ctx, gunichar chr, teco_qreg_t **result, teco_qreg_table_t **result_table, GError **error) { - ctx->parse_only = result == NULL; + ctx->flags.parse_only = result == NULL; if (!teco_machine_input(&ctx->parent, chr, error)) return TECO_MACHINE_QREGSPEC_ERROR; @@ -397,7 +397,7 @@ static gboolean allow_filename = FALSE; static gboolean teco_state_edit_file_initial(teco_machine_main_t *ctx, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return TRUE; teco_int_t id; @@ -427,7 +427,7 @@ teco_state_edit_file_initial(teco_machine_main_t *ctx, GError **error) static teco_state_t * teco_state_edit_file_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; if (!allow_filename) { @@ -524,7 +524,7 @@ TECO_DEFINE_STATE_EXPECTGLOB(teco_state_edit_file, static teco_state_t * teco_state_save_file_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; g_autofree gchar *filename = teco_file_expand_path(str->data); diff --git a/src/search.c b/src/search.c index 13fb135..7fcf10e 100644 --- a/src/search.c +++ b/src/search.c @@ -97,7 +97,7 @@ teco_state_control_search_mode(teco_machine_main_t *ctx, GError **error) static gboolean teco_state_search_initial(teco_machine_main_t *ctx, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return TRUE; teco_machine_stringbuilding_set_codepage(&ctx->expectstring.machine, @@ -691,7 +691,7 @@ teco_state_search_process(teco_machine_main_t *ctx, const teco_string_t *str, gs if (teco_is_failure(search_mode)) flags |= G_REGEX_CASELESS; - if (ctx->modifier_colon == 2) + if (ctx->flags.modifier_colon == 2) flags |= G_REGEX_ANCHORED; /* this is set in teco_state_search_initial() */ @@ -813,7 +813,7 @@ failure: static teco_state_t * teco_state_search_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; teco_qreg_t *search_reg = teco_qreg_table_find(&teco_qreg_table_globals, "_", 1); @@ -943,7 +943,7 @@ TECO_DEFINE_STATE_SEARCH(teco_state_search); static gboolean teco_state_search_all_initial(teco_machine_main_t *ctx, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return TRUE; teco_machine_stringbuilding_set_codepage(&ctx->expectstring.machine, @@ -1000,7 +1000,7 @@ teco_state_search_all_initial(teco_machine_main_t *ctx, GError **error) static teco_state_t * teco_state_search_all_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode <= TECO_MODE_NORMAL && + if (ctx->flags.mode <= TECO_MODE_NORMAL && (!teco_state_search_done(ctx, str, error) || !teco_ed_hook(TECO_ED_HOOK_EDIT, error))) return NULL; @@ -1060,7 +1060,7 @@ TECO_DEFINE_STATE_SEARCH(teco_state_search_all, static teco_state_t * teco_state_search_kill_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; teco_qreg_t *search_reg = teco_qreg_table_find(&teco_qreg_table_globals, "_", 1); @@ -1140,7 +1140,7 @@ TECO_DEFINE_STATE_SEARCH(teco_state_search_kill); static teco_state_t * teco_state_search_delete_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; teco_qreg_t *search_reg = teco_qreg_table_find(&teco_qreg_table_globals, "_", 1); @@ -1183,7 +1183,7 @@ TECO_DEFINE_STATE_SEARCH(teco_state_search_delete); static gboolean teco_state_replace_insert_initial(teco_machine_main_t *ctx, GError **error) { - if (ctx->mode == TECO_MODE_NORMAL) + if (ctx->flags.mode == TECO_MODE_NORMAL) teco_machine_stringbuilding_set_codepage(&ctx->expectstring.machine, teco_interface_get_codepage()); return TRUE; @@ -1210,7 +1210,7 @@ TECO_DEFINE_STATE_EXPECTSTRING(teco_state_replace_ignore); static teco_state_t * teco_state_replace_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_replace_ignore; teco_qreg_t *search_reg = teco_qreg_table_find(&teco_qreg_table_globals, "_", 1); @@ -1259,7 +1259,7 @@ TECO_DEFINE_STATE_SEARCH(teco_state_replace, static teco_state_t * teco_state_replace_default_insert_done_overwrite(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; teco_qreg_t *replace_reg = teco_qreg_table_find(&teco_qreg_table_globals, "-", 1); @@ -1292,7 +1292,7 @@ TECO_DEFINE_STATE_INSERT(teco_state_replace_default_insert, static teco_state_t * teco_state_replace_default_ignore_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL || + if (ctx->flags.mode > TECO_MODE_NORMAL || !str->len) return &teco_state_start; @@ -1315,7 +1315,7 @@ TECO_DEFINE_STATE_EXPECTSTRING(teco_state_replace_default_ignore); static teco_state_t * teco_state_replace_default_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_replace_default_ignore; teco_qreg_t *search_reg = teco_qreg_table_find(&teco_qreg_table_globals, "_", 1); diff --git a/src/spawn.c b/src/spawn.c index e44ecc4..d51dbb1 100644 --- a/src/spawn.c +++ b/src/spawn.c @@ -171,7 +171,7 @@ teco_parse_shell_command_line(const gchar *cmdline, GError **error) static gboolean teco_state_execute_initial(teco_machine_main_t *ctx, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return TRUE; /* @@ -260,7 +260,7 @@ teco_state_execute_done(teco_machine_main_t *ctx, const teco_string_t *str, GErr #endif G_SPAWN_STDERR_TO_DEV_NULL; - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; if (teco_spawn_ctx.from < 0) @@ -618,7 +618,7 @@ teco_state_egcommand_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg, { teco_state_expectqreg_reset(ctx); - if (ctx->mode <= TECO_MODE_NORMAL) + if (ctx->flags.mode <= TECO_MODE_NORMAL) teco_undo_ptr(teco_spawn_ctx.register_argument) = qreg; return &teco_state_execute; } diff --git a/src/symbols.c b/src/symbols.c index 66edd90..4028b7e 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -214,7 +214,7 @@ teco_scintilla_parse_symbols(teco_machine_scintilla_t *scintilla, const teco_str static teco_state_t * teco_state_scintilla_symbols_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_scintilla_lparam; /* @@ -426,7 +426,7 @@ teco_create_lexer(const teco_string_t *str, GError **error) static teco_state_t * teco_state_scintilla_lparam_done(teco_machine_main_t *ctx, const teco_string_t *str, GError **error) { - if (ctx->mode > TECO_MODE_NORMAL) + if (ctx->flags.mode > TECO_MODE_NORMAL) return &teco_state_start; sptr_t lParam = 0; |