aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core-commands.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-07-28 02:41:33 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-07-28 02:41:33 +0300
commit86fbf212de71a83e7bb4d83a4b33e54bed52dff9 (patch)
tree1afd4168fa4448ff369181fe1e8b3d69472a1d2a /src/core-commands.c
parentafc50684cdb38815573fdff0f4fff47cc4eb00a8 (diff)
downloadsciteco-86fbf212de71a83e7bb4d83a4b33e54bed52dff9.tar.gz
`ED&2` can be used to access the program termination flag now
* `0,2ED` is roughly equivalent to `-EX` * `ED&2` can be used to query whether EX has been run. This is useful if macros can run EX. * `2,0ED` could be used to cancel the effect of EX. * But the real motivation is for implementing a REPL script.
Diffstat (limited to 'src/core-commands.c')
-rw-r--r--src/core-commands.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/core-commands.c b/src/core-commands.c
index 1a4b22a..015865d 100644
--- a/src/core-commands.c
+++ b/src/core-commands.c
@@ -1873,7 +1873,7 @@ teco_state_ctlc_control_input(teco_machine_main_t *ctx, gunichar chr, GError **e
if (!teco_expressions_eval(FALSE, error))
return NULL;
- teco_quit_requested = TRUE;
+ teco_ed |= TECO_ED_EXIT;
g_set_error_literal(error, TECO_ERROR, TECO_ERROR_QUIT, "");
return NULL;
}
@@ -1907,7 +1907,12 @@ TECO_DEFINE_STATE_COMMAND(teco_state_ctlc_control);
* Without any argument ED returns the current flags.
*
* Currently, the following flags are used by \*(ST:
- * .IP 4: 5
+ * .IP 2: 5
+ * Reflects whether program termination has been requested
+ * by successfully performing the \fBEX\fP command.
+ * This flag can also be used to cancel the effect of any
+ * prior \fBEX\fP.
+ * .IP 4:
* If enabled, prefer raw single-byte ANSI encoding
* for all new buffers and registers.
* This does not change the encoding of any existing
@@ -2577,7 +2582,7 @@ teco_state_ecommand_encoding(teco_machine_main_t *ctx, GError **error)
teco_interface_ssm(SCI_GOTOPOS, teco_interface_glyphs2bytes(dot_glyphs), 0);
}
-/*$ "EX" ":EX" exit
+/*$ "EX" ":EX" exit quit
* [bool]EX -- Exit program
* -EX
* :EX
@@ -2614,6 +2619,10 @@ teco_state_ecommand_encoding(teco_machine_main_t *ctx, GError **error)
* \(lq:EX\fB$$\fP\(rq is nevertheless the usual interactive
* command sequence to exit while saving all modified
* buffers.
+ *
+ * The program termination request is also available in bit 2
+ * of the \fBED\fP flags, so \(lqED&2\(rq can be used to
+ * check whether EX has been successfully called.
*/
/** @fixme what if changing file after EX? will currently still exit */
static void
@@ -2634,7 +2643,7 @@ teco_state_ecommand_exit(teco_machine_main_t *ctx, GError **error)
}
}
- teco_undo_gboolean(teco_quit_requested) = TRUE;
+ teco_undo_int(teco_ed) |= TECO_ED_EXIT;
}
static void