diff --git a/src/dialog.c b/src/dialog.c index 5efb799fa..13b32a44d 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -169,8 +169,10 @@ create_dlg (int y1, int x1, int lines, int cols, const int *color_set, y1 -= 2; new_d = g_new0 (Dlg_head, 1); - if (color_set != NULL) - memmove (new_d->color, color_set, sizeof (new_d->color)); + if (color_set != NULL) { + new_d->color = g_new (int, DLG_COLOR_NUM); + memmove (new_d->color, color_set, sizeof (int) * DLG_COLOR_NUM); + } new_d->help_ctx = help_ctx; new_d->callback = callback ? callback : default_dlg_callback; new_d->x = x1; @@ -802,6 +804,7 @@ destroy_dlg (Dlg_head *h) g_free (h->current); h->current = c; } + g_free (h->color); g_free (h->title); g_free (h); diff --git a/src/dialog.h b/src/dialog.h index c2da7e219..5fa1830da 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -26,12 +26,6 @@ #include "../src/tty/mouse.h" #include "util.h" /* Hook */ -/* Color constants */ -#define DLG_NORMALC(h) ((h)->color[0]) -#define DLG_FOCUSC(h) ((h)->color[1]) -#define DLG_HOT_NORMALC(h) ((h)->color[2]) -#define DLG_HOT_FOCUSC(h) ((h)->color[3]) - /* Common return values */ #define B_EXIT 0 #define B_CANCEL 1 @@ -89,11 +83,18 @@ typedef enum { struct Dlg_head; typedef cb_ret_t (*dlg_cb_fn)(struct Dlg_head *h, dlg_msg_t msg, int parm); +/* Dialog color constants */ +#define DLG_COLOR_NUM 4 +#define DLG_NORMALC(h) ((h)->color[0]) +#define DLG_FOCUSC(h) ((h)->color[1]) +#define DLG_HOT_NORMALC(h) ((h)->color[2]) +#define DLG_HOT_FOCUSC(h) ((h)->color[3]) + typedef struct Dlg_head { /* Set by the user */ int flags; /* User flags */ const char *help_ctx; /* Name of the help entry */ - const int color[4]; /* Color set. Unused in viewer and editor */ + int *color; /* Color set. Unused in viewer and editor */ /*notconst*/ char *title; /* Title of the dialog */ /* Set and received by the user */ diff --git a/src/main.c b/src/main.c index fd34698ad..d692351e5 100644 --- a/src/main.c +++ b/src/main.c @@ -1671,7 +1671,7 @@ mc_maybe_editor_or_viewer (void) static void do_nc (void) { - const int midnight_colors[4] = + const int midnight_colors[DLG_COLOR_NUM] = { NORMAL_COLOR, /* NORMALC */ REVERSE_COLOR, /* FOCUSC */ diff --git a/src/wtools.c b/src/wtools.c index 783010b44..70aa94ae1 100644 --- a/src/wtools.c +++ b/src/wtools.c @@ -50,7 +50,7 @@ Listbox * create_listbox_window_delta (int delta_x, int delta_y, int cols, int lines, const char *title, const char *help) { - const int listbox_colors[4] = + const int listbox_colors[DLG_COLOR_NUM] = { MENU_ENTRY_COLOR, MENU_SELECTED_COLOR,