aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/sciteco.7.template6
-rw-r--r--src/cmdline.c35
-rw-r--r--tests/testsuite.at7
3 files changed, 27 insertions, 21 deletions
diff --git a/doc/sciteco.7.template b/doc/sciteco.7.template
index 86ca68f..b3b2aaa 100644
--- a/doc/sciteco.7.template
+++ b/doc/sciteco.7.template
@@ -433,7 +433,8 @@ If enabled, the rubout commands will perform analoguous
re-insertions of previously rubbed out characters.
Therefore \fB^G\fP (CTRL+G)
effectively switches between undo and redo modes.
-The modifier also influences the behaviour of the TAB key.
+The modifier may also enable file name and symbol completions
+with the TAB key.
T}
T{
Case insensitive command character
@@ -601,8 +602,9 @@ T};T{
Auto complete filename beginning after the last space (or beginning
of the string argument).
Fully completed filenames are terminated with a space.
-This autocompletion works in every string argument (as long as
+This auto-completion works in every string argument as long as
the \fB^G\fP modifier is enabled.
+The modifier is automatically disabled after a full completion.
T}
\^;\^;\^;T{
Operating system command arguments
diff --git a/src/cmdline.c b/src/cmdline.c
index 99bc802..a4e2189 100644
--- a/src/cmdline.c
+++ b/src/cmdline.c
@@ -113,6 +113,17 @@ teco_cmdline_init(void)
teco_cmdline_ssm(SCI_MARGINSETTEXT, 0, (sptr_t)"*");
}
+static inline void
+teco_cmdline_modifier_set(gboolean modifier)
+{
+ if (teco_cmdline.modifier_enabled == modifier)
+ return;
+ teco_cmdline.modifier_enabled = modifier;
+ teco_interface_msg(TECO_MSG_INFO,
+ "Immediate editing modifier is now %s.",
+ teco_cmdline.modifier_enabled ? "enabled" : "disabled");
+}
+
/**
* Insert string into command line and execute
* it immediately.
@@ -142,13 +153,6 @@ teco_cmdline_insert(const gchar *data, gsize len, GError **error)
teco_cmdline_ssm(SCI_GOTOPOS, effective_len+len, 0);
} else {
/* discard rubbed out part of the command line */
- if (effective_len < macro_len)
- /*
- * Automatically disable immediate editing modifier.
- * FIXME: Should we show a message as when pressing ^G?
- */
- teco_cmdline.modifier_enabled = FALSE;
-
teco_cmdline_ssm(SCI_DELETERANGE, effective_len, macro_len - effective_len);
teco_cmdline_ssm(SCI_ADDTEXT, len, (sptr_t)data);
@@ -545,10 +549,7 @@ teco_state_process_edit_cmd(teco_machine_t *ctx, teco_machine_t *parent_ctx, gun
case TECO_CTL_KEY('G'): /* toggle immediate editing modifier */
teco_interface_popup_clear();
- teco_cmdline.modifier_enabled = !teco_cmdline.modifier_enabled;
- teco_interface_msg(TECO_MSG_INFO,
- "Immediate editing modifier is now %s.",
- teco_cmdline.modifier_enabled ? "enabled" : "disabled");
+ teco_cmdline_modifier_set(!teco_cmdline.modifier_enabled);
return TRUE;
case TECO_CTL_KEY('H'): /* rubout/reinsert character */
@@ -818,16 +819,12 @@ teco_state_stringbuilding_start_process_edit_cmd(teco_machine_stringbuilding_t *
g_auto(teco_string_t) new_chars, new_chars_escaped;
gboolean unambiguous = teco_file_auto_complete(filename, G_FILE_TEST_EXISTS, &new_chars);
teco_machine_stringbuilding_escape(ctx, new_chars.data, new_chars.len, &new_chars_escaped);
- if (unambiguous)
+ if (unambiguous) {
teco_string_append_c(&new_chars_escaped, ' ');
+ teco_cmdline_modifier_set(FALSE);
+ }
- if (!teco_cmdline_insert(new_chars_escaped.data, new_chars_escaped.len, error))
- return FALSE;
-
- /* may be reset if there was a rubbed out command line */
- teco_cmdline.modifier_enabled = TRUE;
-
- return TRUE;
+ return teco_cmdline_insert(new_chars_escaped.data, new_chars_escaped.len, error);
}
}
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 4378ca0..fef01dc 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -40,6 +40,7 @@ m4_define([TE_CHECK_CMDLINE], [
m4_define([TE_ESCAPE], [m4_format([%c], 27)])
m4_define([TE_RUBOUT], [m4_format([%c], 8)])
m4_define([TE_RUBOUT_WORD], [m4_format([%c], 23)])
+m4_define([TE_MODIFIER], [m4_format([%c], 7)])
AT_BANNER([Language features])
@@ -490,6 +491,12 @@ TE_CHECK_CMDLINE([[@I/ @:foo ]]TE_RUBOUT_WORD[[/ Z-3"N(0/0)']], 0, ignore, stde
AT_FAIL_IF([$GREP "^Error:" stderr])
AT_CLEANUP
+AT_SETUP([Rub in with immediate editing commands])
+TE_CHECK_CMDLINE([[@I/foo/ ]]TE_RUBOUT_WORD[]TE_MODIFIER[]TE_RUBOUT_WORD[[{Z-9"N(0/0)'}]], 0, ignore, stderr)
+#AT_FAIL_IF([! $GREP "^Info: Immediate editing modifier" stderr])
+AT_FAIL_IF([$GREP "^Error:" stderr])
+AT_CLEANUP
+
AT_SETUP([Disallowed interactive commands])
# Command-line termination while editing the replacement register would
# be hard to recover from.