diff options
Diffstat (limited to 'src/error.h')
-rw-r--r-- | src/error.h | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/error.h b/src/error.h index 91d2b60..469d957 100644 --- a/src/error.h +++ b/src/error.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2023 Robin Haberkorn + * Copyright (C) 2012-2024 Robin Haberkorn * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,13 +40,16 @@ typedef enum { */ TECO_ERROR_SYNTAX, TECO_ERROR_ARGEXPECTED, + TECO_ERROR_CODEPOINT, TECO_ERROR_MOVE, TECO_ERROR_WORDS, TECO_ERROR_RANGE, TECO_ERROR_INVALIDQREG, TECO_ERROR_QREGOPUNSUPPORTED, TECO_ERROR_QREGCONTAINSNULL, + TECO_ERROR_EDITINGLOCALQREG, TECO_ERROR_MEMLIMIT, + TECO_ERROR_CLIPBOARD, /** Interrupt current operation */ TECO_ERROR_INTERRUPTED, @@ -60,10 +63,12 @@ typedef enum { } teco_error_t; static inline void -teco_error_syntax_set(GError **error, gchar chr) +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\" (%d)", chr, chr); + "Syntax error \"%s\" (U+%04" G_GINT32_MODIFIER "X)", chr_printable, chr); } static inline void @@ -74,6 +79,13 @@ teco_error_argexpected_set(GError **error, const gchar *cmd) } static inline void +teco_error_codepoint_set(GError **error, const gchar *cmd) +{ + g_set_error(error, TECO_ERROR, TECO_ERROR_CODEPOINT, + "Invalid Unicode codepoint for <%s>", cmd); +} + +static inline void teco_error_move_set(GError **error, const gchar *cmd) { g_set_error(error, TECO_ERROR, TECO_ERROR_MOVE, @@ -119,6 +131,14 @@ teco_error_qregcontainsnull_set(GError **error, const gchar *name, gsize len, gb } static inline void +teco_error_editinglocalqreg_set(GError **error, const gchar *name, gsize len) +{ + g_autofree gchar *name_printable = teco_string_echo(name, len); + g_set_error(error, TECO_ERROR, TECO_ERROR_EDITINGLOCALQREG, + "Editing local Q-Register \"%s\" at end of macro call", name_printable); +} + +static inline void teco_error_interrupted_set(GError **error) { g_set_error_literal(error, TECO_ERROR, TECO_ERROR_INTERRUPTED, "Interrupted"); @@ -135,7 +155,11 @@ teco_error_return_set(GError **error, guint args) extern guint teco_error_pos, teco_error_line, teco_error_column; -void teco_error_set_coord(const gchar *str, guint pos); +static inline void +teco_error_set_coord(const gchar *str, gsize pos) +{ + teco_string_get_coord(str, pos, &teco_error_pos, &teco_error_line, &teco_error_column); +} void teco_error_display_short(const GError *error); void teco_error_display_full(const GError *error); |