aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2026-04-14 01:16:04 +0200
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2026-04-14 23:19:45 +0200
commit34af154e92383161666751ca69a288c98f5cca60 (patch)
tree8bea36b04c21205321724b8690d53b3a23bc12e5 /src
parentcd48ea8f00567f30d9685f96a12b8f123a121f62 (diff)
`^A` now accepts an optional integer to specify the message severityHEADmaster-fmsbw-cimaster
* I.e. you can now log warnings and errors from SciTECO code as well. * We do not need a version of ^A accepting code points, since this is supported by ^T already.
Diffstat (limited to 'src')
-rw-r--r--src/interface.h5
-rw-r--r--src/stdio-commands.c34
2 files changed, 31 insertions, 8 deletions
diff --git a/src/interface.h b/src/interface.h
index 54f807b..3ee8742 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -60,10 +60,11 @@ GOptionGroup *teco_interface_get_options(void);
void teco_interface_init_color(guint color, guint32 rgb);
typedef enum {
- TECO_MSG_USER,
+ TECO_MSG_USER = 0,
TECO_MSG_INFO,
TECO_MSG_WARNING,
- TECO_MSG_ERROR
+ TECO_MSG_ERROR,
+ TECO_MSG_MAX = TECO_MSG_ERROR
} teco_msg_t;
extern teco_msg_t teco_interface_msg_level;
diff --git a/src/stdio-commands.c b/src/stdio-commands.c
index abb6566..123d0ea 100644
--- a/src/stdio-commands.c
+++ b/src/stdio-commands.c
@@ -255,17 +255,39 @@ teco_state_print_string_initial(teco_machine_main_t *ctx, GError **error)
static teco_state_t *
teco_state_print_string_done(teco_machine_main_t *ctx, teco_string_t str, GError **error)
{
- teco_interface_msg_literal(TECO_MSG_USER, str.data, str.len);
+ teco_int_t type;
+
+ if (!teco_expressions_pop_num_calc(&type, TECO_MSG_USER, error))
+ return NULL;
+ if (type < TECO_MSG_USER || type > TECO_MSG_MAX) {
+ g_set_error_literal(error, TECO_ERROR, TECO_ERROR_FAILED,
+ "Invalid message level specified for <^A>");
+ return NULL;
+ }
+
+ teco_interface_msg_literal(type, str.data, str.len);
return &teco_state_start;
}
/*$ "^A" ":^A" print "print string"
- * ^A<string>^A -- Print string as message
- * @^A/string/
- * :^A<string>^A
+ * [type]^A<string>^A -- Print string as message
+ * [type]@^A/string/
+ * [type]:^A<string>^A
*
- * Print <string> as a message, i.e. in the message line
- * in interactive mode and if possible on the terminal (stdout) as well.
+ * Print <string> as a message with severity <type>, i.e. in the
+ * message line in interactive mode and if possible on the terminal
+ * as well.
+ * The following message levels are supported:
+ * .IP 0: 3
+ * User-level message:
+ * They are written without any prefixes directly to stdout.
+ * This is the default if <type> is omitted.
+ * .IP 1:
+ * Info-level message
+ * .IP 2:
+ * Warnings
+ * .IP 3:
+ * Errors
*
* \fB^A\fP differs from all other commands in the way <string>
* is terminated.