aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-28 17:38:02 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-28 17:38:02 +0300
commit0ce3b52f696d9fb07dded56400d4d3338074ea6c (patch)
treed264e4352cd572c2a8003c35dd3a8396a9e680ee /src/main.c
parent427092d2c8ee11b4a56eb50dbf68861f10f2a81f (diff)
downloadsciteco-0ce3b52f696d9fb07dded56400d4d3338074ea6c.tar.gz
added hidden --fake-cmdline parameter for testing command-line editing
* Supports all immediate editing commands. Naturally it cannot emulate arbitrary key presses since there is no canonic ASCII-encoding of function keys. Key macros are not consequently also not testable. The --fake-cmdline parameter is instead treated very similar to a key macro expansion. * Most importantly this allows adding test cases for rubout behavior and bugs that are quite common. * Added regression test cases for the last two rubout bugs. * It's not easy to pass control codes in command line arguments in a portable manner, so the test cases will often use { and }. Control codes could be used e.g. by defining variables like RUBOUT=`printf '\b'` and referencing them with ${RUBOUT}.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index eb3c0b4..5b3b8cf 100644
--- a/src/main.c
+++ b/src/main.c
@@ -105,6 +105,7 @@ teco_get_default_config_path(const gchar *program)
static gchar *teco_eval_macro = NULL;
static gboolean teco_mung_file = FALSE;
static gboolean teco_mung_profile = TRUE;
+static gchar *teco_fake_cmdline = NULL;
static gboolean teco_8bit_clean = FALSE;
static gchar *
@@ -121,6 +122,9 @@ teco_process_options(gchar ***argv)
"Do not mung "
"$SCITECOCONFIG" G_DIR_SEPARATOR_S INI_FILE " "
"even if it exists"},
+ {"fake-cmdline", 0, G_OPTION_FLAG_HIDDEN,
+ G_OPTION_ARG_STRING, &teco_fake_cmdline,
+ "Emulate key presses in batch mode (for debugging)", "keys"},
{"8bit", '8', 0, G_OPTION_ARG_NONE, &teco_8bit_clean,
"Use ANSI encoding by default and disable automatic EOL conversion"},
{NULL}
@@ -437,6 +441,15 @@ main(int argc, char **argv)
*/
teco_machine_main_init(&teco_cmdline.machine, &local_qregs, TRUE);
+ if (G_UNLIKELY(teco_fake_cmdline != NULL)) {
+ if (!teco_cmdline_keypress(teco_fake_cmdline, strlen(teco_fake_cmdline), &error) &&
+ !g_error_matches(error, TECO_ERROR, TECO_ERROR_QUIT)) {
+ teco_error_add_frame_toplevel();
+ goto error;
+ }
+ goto cleanup;
+ }
+
if (!teco_interface_event_loop(&error))
goto error;