diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-07-31 17:19:07 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-07-31 17:19:07 +0300 |
commit | ca70c9061146386ce0986631cd7fc9209a935a34 (patch) | |
tree | 31bdd0ab4f5bec8eb5aadcc75332960b0e8d5a22 /src/core-commands.c | |
parent | 630a6f3cc2438cbc966e883a2106fcfadb59cad3 (diff) | |
download | sciteco-ca70c9061146386ce0986631cd7fc9209a935a34.tar.gz |
added -v/--version and <EO> command
* DEC TECO had an <EO> command.
In contrast to DEC TECO's implementation, the value reported by
<EO> encodes a major.minor.micro semantic version.
Diffstat (limited to 'src/core-commands.c')
-rw-r--r-- | src/core-commands.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core-commands.c b/src/core-commands.c index 67eb51a..a2d3c92 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -20,6 +20,7 @@ #include <time.h> #include <string.h> +#include <stdio.h> #include <glib.h> #include <glib/gstdio.h> @@ -2600,6 +2601,25 @@ teco_state_ecommand_encoding(teco_machine_main_t *ctx, GError **error) teco_interface_ssm(SCI_GOTOPOS, teco_interface_glyphs2bytes(dot_glyphs), 0); } +/*$ EO version + * EO -> major*10000 + minor*100 + micro + * + * Return the version of \*(ST encoded into an integer. + */ +static void +teco_state_ecommand_version(teco_machine_main_t *ctx, GError **error) +{ + /* + * FIXME: This is inefficient and could be done at build-time. + * Or we could have PACKAGE_MAJOR_VERSION, PACKAGE_MINOR_VERSION etc. macros. + * But then, who cares? + */ + guint major, minor, micro; + G_GNUC_UNUSED gint rc = sscanf(PACKAGE_VERSION, "%u.%u.%u", &major, &minor, µ); + g_assert(rc == 3); + teco_expressions_push(major*10000 + minor*100 + micro); +} + /*$ "EX" ":EX" exit quit * [bool]EX -- Exit program * -EX @@ -2715,6 +2735,7 @@ teco_state_ecommand_input(teco_machine_main_t *ctx, gunichar chr, GError **error .modifier_colon = 1}, ['E'] = {&teco_state_start, teco_state_ecommand_encoding, .modifier_colon = 1}, + ['O'] = {&teco_state_start, teco_state_ecommand_version}, ['X'] = {&teco_state_start, teco_state_ecommand_exit, .modifier_colon = 1}, }; |