aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/opener.tes5
-rw-r--r--lib/tank.tes4
-rw-r--r--src/interface.h5
-rw-r--r--src/stdio-commands.c34
-rw-r--r--tests/testsuite.at10
5 files changed, 44 insertions, 14 deletions
diff --git a/lib/opener.tes b/lib/opener.tes
index 59af79a..8bcd896 100644
--- a/lib/opener.tes
+++ b/lib/opener.tes
@@ -48,9 +48,6 @@
EQ.f G* I# R
<-A"I 1; ' :R;>
I#
- 1:EN*Q.f"S
- !* FIXME: log as a true warning once  supports it *!
- Warning: Detected recovery file "Q.f"^J
- '
+ 1:EN*Q.f"S 2Detected recovery file "Q.f" '
]*
}
diff --git a/lib/tank.tes b/lib/tank.tes
index 8573e22..0894009 100644
--- a/lib/tank.tes
+++ b/lib/tank.tes
@@ -125,7 +125,7 @@
>
M[tank.explode]
- %[tank.score] SCORE: \[tank.score]
+ %[tank.score] 1SCORE: \[tank.score]
}
@[tank.selfdestruct]{
@@ -170,7 +170,7 @@ ESGETTABDRAWMODE-2"N
>
'
-CONTROL: W A S D. SHOOT: SPACE. QUIT: ESCAPE. PRESS ANY KEY TO START. 
+1CONTROL: W A S D. SHOOT: SPACE. QUIT: ESCAPE. PRESS ANY KEY TO START. 
ESGETCARETSTYLEU.[caretstyle]
0ESSETCARETSTYLE
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.
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 6bc33e4..a236149 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -221,6 +221,16 @@ AT_DATA([expout], [[TEST
Line 2
]])
TE_CHECK([[@^A/TEST^JLine 2^J/]], 0, expout, ignore)
+# FIXME: "Info" messages are surpressed by --quiet.
+#AT_DATA([expout], [[Info: TEST
+#]])
+#TE_CHECK([[1@^A/TEST/]], 0, expout, ignore)
+AT_DATA([experr], [[Warning: TEST
+]])
+TE_CHECK([[2@^A/TEST/]], 0, ignore, experr)
+AT_DATA([experr], [[Error: TEST
+]])
+TE_CHECK([[3@^A/TEST/]], 0, ignore, experr)
AT_CLEANUP
AT_SETUP([Type out buffer contents])