From 49e1f099fd4efe78365f0449522b99bdaa661f8f Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 21 Sep 2024 11:32:22 +0200 Subject: syntax errors are reported with "echoed" characters, ie. as purely printable characters * Some characters like LF wouldn't be displayed in the message line correctly. * In fact the Gtk UI cannot display any of the control characters correctly. * I was considering deferring all echoing/formatting to the UIs, so they can use TecoGtkLabel or teco_curses_format_str(). This is not possible since messages transmitted via GError must not contain null-bytes, so these need to be sorted out earlier anyway. * This should also fix syntax errors in PDCurses for Windows where "%C" apparently doesn't work with non-ANSI codepoints. --- src/error.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/error.h b/src/error.h index 03af66c..0db6caa 100644 --- a/src/error.h +++ b/src/error.h @@ -64,8 +64,10 @@ typedef enum { static inline void teco_error_syntax_set(GError **error, gunichar chr) { + gchar buf[6]; + g_autofree gchar *chr_printable = teco_string_echo(buf, g_unichar_to_utf8(chr, buf)); g_set_error(error, TECO_ERROR, TECO_ERROR_SYNTAX, - "Syntax error \"%C\" (U+%04" G_GINT32_MODIFIER "X)", chr, chr); + "Syntax error \"%s\" (U+%04" G_GINT32_MODIFIER "X)", chr_printable, chr); } static inline void -- cgit v1.2.3