From f0500a5a0eeee9aad6ead78714ccfa4121578853 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 12 Dec 2021 20:56:32 +0100 Subject: [PATCH] [Help] Print out the parsed config/theme files. --- include/theme.h | 13 +++++++++++++ source/rofi.c | 20 +++++++++++--------- source/theme.c | 21 ++++++++++++++++++++- 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/include/theme.h b/include/theme.h index 30b501f2..db41e16a 100644 --- a/include/theme.h +++ b/include/theme.h @@ -454,4 +454,17 @@ RofiDistance rofi_theme_property_copy_distance(RofiDistance const distance); */ int rofi_theme_rasi_validate(const char *filename); +/** + * + * Free memory. + */ +void rofi_theme_free_parsed_files(void); + +/** + * @param is_term Indicate if printed to terminal. + * + * Print the list of parsed config files. + */ +void rofi_theme_print_parsed_files(int is_term); + #endif diff --git a/source/rofi.c b/source/rofi.c index bf320057..b640e5d5 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -269,7 +269,7 @@ static void print_list_of_modi(int is_term) { break; } } - printf(" * %s%s%s%s\n", active ? "+" : "", + printf(" • %s%s%s%s\n", active ? "+" : "", is_term ? (active ? color_green : color_red) : "", available_modi[i]->name, is_term ? color_reset : ""); } @@ -328,31 +328,31 @@ static void help(G_GNUC_UNUSED int argc, char **argv) { printf("\n"); printf("Compile time options:\n"); #ifdef WINDOW_MODE - printf("\t* window %senabled%s\n", is_term ? color_green : "", + printf("\t• window %senabled%s\n", is_term ? color_green : "", is_term ? color_reset : ""); #else - printf("\t* window %sdisabled%s\n", is_term ? color_red : "", + printf("\t• window %sdisabled%s\n", is_term ? color_red : "", is_term ? color_reset : ""); #endif #ifdef ENABLE_DRUN - printf("\t* drun %senabled%s\n", is_term ? color_green : "", + printf("\t• drun %senabled%s\n", is_term ? color_green : "", is_term ? color_reset : ""); #else - printf("\t* drun %sdisabled%s\n", is_term ? color_red : "", + printf("\t• drun %sdisabled%s\n", is_term ? color_red : "", is_term ? color_reset : ""); #endif #ifdef ENABLE_GCOV - printf("\t* gcov %senabled%s\n", is_term ? color_green : "", + printf("\t• gcov %senabled%s\n", is_term ? color_green : "", is_term ? color_reset : ""); #else - printf("\t* gcov %sdisabled%s\n", is_term ? color_red : "", + printf("\t• gcov %sdisabled%s\n", is_term ? color_red : "", is_term ? color_reset : ""); #endif #ifdef ENABLE_ASAN - printf("\t* asan %senabled%s\n", is_term ? color_green : "", + printf("\t• asan %senabled%s\n", is_term ? color_green : "", is_term ? color_reset : ""); #else - printf("\t* asan %sdisabled%s\n", is_term ? color_red : "", + printf("\t• asan %sdisabled%s\n", is_term ? color_red : "", is_term ? color_reset : ""); #endif printf("\n"); @@ -380,6 +380,7 @@ static void help(G_GNUC_UNUSED int argc, char **argv) { printf(" Configuration file: %sDisabled%s\n", is_term ? color_bold : "", is_term ? color_reset : ""); } + rofi_theme_print_parsed_files(is_term); } static void help_print_disabled_mode(const char *mode) { @@ -478,6 +479,7 @@ static void cleanup(void) { rofi_collect_modi_destroy(); rofi_icon_fetcher_destroy(); + rofi_theme_free_parsed_files(); if (rofi_configuration) { rofi_theme_free(rofi_configuration); rofi_configuration = NULL; diff --git a/source/theme.c b/source/theme.c index 8d10fbff..ab367aab 100644 --- a/source/theme.c +++ b/source/theme.c @@ -46,6 +46,25 @@ #include "widgets/textbox.h" #include +GList *parsed_config_files = NULL; + +void rofi_theme_free_parsed_files(void) { + g_list_free_full(parsed_config_files, g_free); + parsed_config_files = NULL; +} + +void rofi_theme_print_parsed_files(gboolean is_term) { + printf("\nParsed files:\n"); + for (GList *iter = g_list_first(parsed_config_files); iter != NULL; + iter = g_list_next(iter)) { + printf("\t\u2022 %s%s%s\n", + is_term ? color_bold : "", (const char *)(iter->data), + is_term ? color_reset : ""); + + } + printf("\n"); +} + void yyerror(YYLTYPE *yylloc, const char *, const char *); static gboolean distance_compare(RofiDistance d, RofiDistance e) { // TODO UPDATE @@ -1361,7 +1380,7 @@ char *rofi_theme_parse_prepare_file(const char *file, const char *parent_file) { g_free(basedir); } GFile *gf = g_file_new_for_path(filename); - g_free(filename); + parsed_config_files = g_list_append(parsed_config_files, filename); filename = g_file_get_path(gf); g_object_unref(gf);