From 9bcc65dfe45a0854a18a75d415e90ef47de4ff6a Mon Sep 17 00:00:00 2001 From: xiota Date: Wed, 24 Nov 2021 03:30:44 -0800 Subject: [PATCH 1/4] Add semantic labels to MsgColors enum in msgwindow.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit COLOR_RED → COLOR_ERROR (geany-compiler-error) COLOR_DARK_RED → COLOR_CONTEXT (geany-compiler-context) COLOR_BLACK → COLOR_TEXT COLOR_BLUE → COLOR_MESSAGE (geany-compiler-message) --- src/build.c | 10 +++++----- src/msgwindow.c | 12 ++++++++---- src/msgwindow.h | 20 ++++++++++++++------ src/plugindata.h | 2 +- src/search.c | 16 ++++++++-------- 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/build.c b/src/build.c index 4085fd7bb0..d727736088 100644 --- a/src/build.c +++ b/src/build.c @@ -793,7 +793,7 @@ static void build_spawn_cmd(GeanyDocument *doc, const gchar *cmd, const gchar *d gtk_list_store_clear(msgwindow.store_compiler); gtk_notebook_set_current_page(GTK_NOTEBOOK(msgwindow.notebook), MSG_COMPILER); - msgwin_compiler_add(COLOR_BLUE, _("%s (in directory: %s)"), cmd, utf8_working_dir); + msgwin_compiler_add(COLOR_MESSAGE, _("%s (in directory: %s)"), cmd, utf8_working_dir); g_free(utf8_working_dir); #ifdef G_OS_UNIX @@ -1024,7 +1024,7 @@ static void process_build_output_line(gchar *msg, gint color) editor_indicator_set_on_line(doc->editor, GEANY_INDICATOR_ERROR, line); } build_info.message_count++; - color = COLOR_RED; /* error message parsed on the line */ + color = COLOR_ERROR; /* error message parsed on the line */ if (build_info.message_count == 1) { @@ -1043,7 +1043,7 @@ static void build_iofunc(GString *string, GIOCondition condition, gpointer data) if (condition & (G_IO_IN | G_IO_PRI)) { process_build_output_line(string->str, - (GPOINTER_TO_INT(data)) ? COLOR_DARK_RED : COLOR_BLACK); + (GPOINTER_TO_INT(data)) ? COLOR_CONTEXT : COLOR_TEXT); } } @@ -1096,7 +1096,7 @@ static void show_build_result_message(gboolean failure) if (failure) { msg = _("Compilation failed."); - msgwin_compiler_add_string(COLOR_BLUE, msg); + msgwin_compiler_add_string(COLOR_MESSAGE, msg); /* If msgwindow is hidden, user will want to display it to see the error */ if (! ui_prefs.msgwindow_visible) { @@ -1110,7 +1110,7 @@ static void show_build_result_message(gboolean failure) else { msg = _("Compilation finished successfully."); - msgwin_compiler_add_string(COLOR_BLUE, msg); + msgwin_compiler_add_string(COLOR_MESSAGE, msg); if (! ui_prefs.msgwindow_visible || gtk_notebook_get_current_page(GTK_NOTEBOOK(msgwindow.notebook)) != MSG_COMPILER) ui_set_statusbar(FALSE, "%s", msg); diff --git a/src/msgwindow.c b/src/msgwindow.c index 52bb031835..dc38356d99 100644 --- a/src/msgwindow.c +++ b/src/msgwindow.c @@ -297,10 +297,14 @@ static const GdkColor *get_color(gint msg_color) { switch (msg_color) { - case COLOR_RED: return &color_error; - case COLOR_DARK_RED: return &color_context; - case COLOR_BLUE: return &color_message; - default: return NULL; + case COLOR_ERROR: /* red */ + return &color_error; + case COLOR_CONTEXT: /* orange */ + return &color_context; + case COLOR_MESSAGE: /* blue */ + return &color_message; + default: /* black */ + return NULL; } } diff --git a/src/msgwindow.h b/src/msgwindow.h index 07b06dbc7d..0e494e2c04 100644 --- a/src/msgwindow.h +++ b/src/msgwindow.h @@ -25,20 +25,28 @@ #include "gtkcompat.h" - G_BEGIN_DECLS /** - * Various colors for use in the compiler and messages treeviews when adding messages. + * Colors for use when adding messages to the compiler and messages treeviews. + * Defined in ``geany.css`` **/ enum MsgColors { - COLOR_RED, /**< Color red */ - COLOR_DARK_RED, /**< Color dark red */ - COLOR_BLACK, /**< Color black */ - COLOR_BLUE /**< Color blue */ + COLOR_ERROR, /**< Color for ``geany-compiler-error``. Default is red. */ + COLOR_CONTEXT, /**< Color for ``geany-compiler-context``. Default is orange. */ + COLOR_TEXT, /**< Color for normal text. Default is black. */ + COLOR_MESSAGE, /**< Color for ``geany-compiler-message``. Default is blue. */ + +#ifndef GEANY_DISABLE_DEPRECATED + COLOR_RED GEANY_DEPRECATED = COLOR_ERROR, /**< @deprecated Use COLOR_ERROR instead. */ + COLOR_DARK_RED GEANY_DEPRECATED = COLOR_CONTEXT, /**< @deprecated Use COLOR_CONTEXT instead. */ + COLOR_BLACK GEANY_DEPRECATED = COLOR_TEXT, /**< @deprecated Use COLOR_TEXT instead. */ + COLOR_BLUE GEANY_DEPRECATED = COLOR_MESSAGE, /**< @deprecated Use COLOR_MESSAGE instead. */ +#endif /* GEANY_DISABLE_DEPRECATED */ }; + /** Indices of the notebooks in the messages window. */ typedef enum { diff --git a/src/plugindata.h b/src/plugindata.h index 02fa05c7eb..366985f6de 100644 --- a/src/plugindata.h +++ b/src/plugindata.h @@ -58,7 +58,7 @@ G_BEGIN_DECLS * @warning You should not test for values below 200 as previously * @c GEANY_API_VERSION was defined as an enum value, not a macro. */ -#define GEANY_API_VERSION 242 +#define GEANY_API_VERSION 243 /* hack to have a different ABI when built with different GTK major versions * because loading plugins linked to a different one leads to crashes. diff --git a/src/search.c b/src/search.c index 4b4b4b664c..cbe12523be 100644 --- a/src/search.c +++ b/src/search.c @@ -1712,7 +1712,7 @@ search_find_in_files(const gchar *utf8_search_text, const gchar *utf8_dir, const msgwin_set_messages_dir(dir); utf8_str = g_strdup_printf(_("%s %s -- %s (in directory: %s)"), tool_prefs.grep_cmd, opts, utf8_search_text, utf8_dir); - msgwin_msg_add_string(COLOR_BLUE, -1, NULL, utf8_str); + msgwin_msg_add_string(COLOR_MESSAGE, -1, NULL, utf8_str); g_free(utf8_str); ret = TRUE; } @@ -1836,13 +1836,13 @@ static void read_fif_io(gchar *msg, GIOCondition condition, gchar *enc, gint msg static void search_read_io(GString *string, GIOCondition condition, gpointer data) { - read_fif_io(string->str, condition, data, COLOR_BLACK); + read_fif_io(string->str, condition, data, COLOR_TEXT); } static void search_read_io_stderr(GString *string, GIOCondition condition, gpointer data) { - read_fif_io(string->str, condition, data, COLOR_DARK_RED); + read_fif_io(string->str, condition, data, COLOR_CONTEXT); } @@ -1875,7 +1875,7 @@ static void search_finished(GPid child_pid, gint status, gpointer user_data) "Search completed with %d match.", "Search completed with %d matches.", count); - msgwin_msg_add(COLOR_BLUE, -1, NULL, text, count); + msgwin_msg_add(COLOR_MESSAGE, -1, NULL, text, count); ui_set_statusbar(FALSE, text, count); break; } @@ -1883,7 +1883,7 @@ static void search_finished(GPid child_pid, gint status, gpointer user_data) msg = _("No matches found."); /* fall through */ default: - msgwin_msg_add_string(COLOR_BLUE, -1, NULL, msg); + msgwin_msg_add_string(COLOR_MESSAGE, -1, NULL, msg); ui_set_statusbar(FALSE, "%s", msg); break; } @@ -2171,7 +2171,7 @@ static gint find_document_usage(GeanyDocument *doc, const gchar *search_text, Ge if (line != prev_line) { buffer = sci_get_line(doc->editor->sci, line); - msgwin_msg_add(COLOR_BLACK, line + 1, doc, + msgwin_msg_add(COLOR_TEXT, line + 1, doc, "%s:%d: %s", short_file_name, line + 1, g_strstrip(buffer)); g_free(buffer); prev_line = line; @@ -2223,14 +2223,14 @@ void search_find_usage(const gchar *search_text, const gchar *original_search_te if (count == 0) /* no matches were found */ { ui_set_statusbar(FALSE, _("No matches found for \"%s\"."), original_search_text); - msgwin_msg_add(COLOR_BLUE, -1, NULL, _("No matches found for \"%s\"."), original_search_text); + msgwin_msg_add(COLOR_MESSAGE, -1, NULL, _("No matches found for \"%s\"."), original_search_text); } else { ui_set_statusbar(FALSE, ngettext( "Found %d match for \"%s\".", "Found %d matches for \"%s\".", count), count, original_search_text); - msgwin_msg_add(COLOR_BLUE, -1, NULL, ngettext( + msgwin_msg_add(COLOR_MESSAGE, -1, NULL, ngettext( "Found %d match for \"%s\".", "Found %d matches for \"%s\".", count), count, original_search_text); } From 82e390f2e8be3ce7aeb575a7fbe6901f087f2a5c Mon Sep 17 00:00:00 2001 From: xiota Date: Wed, 24 Nov 2021 23:19:27 -0800 Subject: [PATCH 2/4] Add comment to note deprecation date --- src/msgwindow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msgwindow.h b/src/msgwindow.h index 0e494e2c04..370905993d 100644 --- a/src/msgwindow.h +++ b/src/msgwindow.h @@ -38,7 +38,7 @@ enum MsgColors COLOR_TEXT, /**< Color for normal text. Default is black. */ COLOR_MESSAGE, /**< Color for ``geany-compiler-message``. Default is blue. */ -#ifndef GEANY_DISABLE_DEPRECATED +#ifndef GEANY_DISABLE_DEPRECATED /* 2021/11/24 */ COLOR_RED GEANY_DEPRECATED = COLOR_ERROR, /**< @deprecated Use COLOR_ERROR instead. */ COLOR_DARK_RED GEANY_DEPRECATED = COLOR_CONTEXT, /**< @deprecated Use COLOR_CONTEXT instead. */ COLOR_BLACK GEANY_DEPRECATED = COLOR_TEXT, /**< @deprecated Use COLOR_TEXT instead. */ From b326e8763dce0652b34da105595802b9f02c3411 Mon Sep 17 00:00:00 2001 From: xiota Date: Thu, 25 Nov 2021 00:18:41 -0800 Subject: [PATCH 3/4] Add deprecation version and API --- src/msgwindow.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/msgwindow.h b/src/msgwindow.h index 370905993d..506862c755 100644 --- a/src/msgwindow.h +++ b/src/msgwindow.h @@ -38,11 +38,16 @@ enum MsgColors COLOR_TEXT, /**< Color for normal text. Default is black. */ COLOR_MESSAGE, /**< Color for ``geany-compiler-message``. Default is blue. */ -#ifndef GEANY_DISABLE_DEPRECATED /* 2021/11/24 */ - COLOR_RED GEANY_DEPRECATED = COLOR_ERROR, /**< @deprecated Use COLOR_ERROR instead. */ - COLOR_DARK_RED GEANY_DEPRECATED = COLOR_CONTEXT, /**< @deprecated Use COLOR_CONTEXT instead. */ - COLOR_BLACK GEANY_DEPRECATED = COLOR_TEXT, /**< @deprecated Use COLOR_TEXT instead. */ - COLOR_BLUE GEANY_DEPRECATED = COLOR_MESSAGE, /**< @deprecated Use COLOR_MESSAGE instead. */ +#ifndef GEANY_DISABLE_DEPRECATED + /* 2021/12 */ + /** @deprecated Use COLOR_ERROR instead. @since 1.39 (API 243) */ + COLOR_RED GEANY_DEPRECATED = COLOR_ERROR, + /** @deprecated Use COLOR_CONTEXT instead. @since 1.39 (API 243) */ + COLOR_DARK_RED GEANY_DEPRECATED = COLOR_CONTEXT, + /** @deprecated Use COLOR_TEXT instead. @since 1.39 (API 243) */ + COLOR_BLACK GEANY_DEPRECATED = COLOR_TEXT, + /** @deprecated Use COLOR_MESSAGE instead. @since 1.39 (API 243) */ + COLOR_BLUE GEANY_DEPRECATED = COLOR_MESSAGE, #endif /* GEANY_DISABLE_DEPRECATED */ }; From 4cb29c2c9d1c7f96f556604ca873973708b62ae1 Mon Sep 17 00:00:00 2001 From: xiota Date: Thu, 25 Nov 2021 00:57:33 -0800 Subject: [PATCH 4/4] fix incorrect use of doxygen tag --- src/msgwindow.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/msgwindow.h b/src/msgwindow.h index 506862c755..353632fd84 100644 --- a/src/msgwindow.h +++ b/src/msgwindow.h @@ -40,13 +40,13 @@ enum MsgColors #ifndef GEANY_DISABLE_DEPRECATED /* 2021/12 */ - /** @deprecated Use COLOR_ERROR instead. @since 1.39 (API 243) */ + /** @deprecated since 1.39 (API 243) Use COLOR_ERROR instead. */ COLOR_RED GEANY_DEPRECATED = COLOR_ERROR, - /** @deprecated Use COLOR_CONTEXT instead. @since 1.39 (API 243) */ + /** @deprecated since 1.39 (API 243) Use COLOR_CONTEXT instead. */ COLOR_DARK_RED GEANY_DEPRECATED = COLOR_CONTEXT, - /** @deprecated Use COLOR_TEXT instead. @since 1.39 (API 243) */ + /** @deprecated since 1.39 (API 243) Use COLOR_TEXT instead. */ COLOR_BLACK GEANY_DEPRECATED = COLOR_TEXT, - /** @deprecated Use COLOR_MESSAGE instead. @since 1.39 (API 243) */ + /** @deprecated since 1.39 (API 243) Use COLOR_MESSAGE instead. */ COLOR_BLUE GEANY_DEPRECATED = COLOR_MESSAGE, #endif /* GEANY_DISABLE_DEPRECATED */ };