From 881f82bab21c10745efebd2df3d3569d4d26ea84 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Aug 13 2026 09:51:27 +0000 Subject: Add active compact button color set --- diff --git a/CHANGES b/CHANGES index 4308b91..4541b5b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +0.52.26 +- add actcompactbutton color set for focused compact buttons + 0.52.25 - improve Makefile (Ryan Carsten Schmidt) - fix "yes" in Spanish translation diff --git a/button.c b/button.c index 8eb5e5a..c5bb649 100644 --- a/button.c +++ b/button.c @@ -107,10 +107,8 @@ static void buttonDrawIt(newtComponent co, int active, int pushed) { if (bu->compact) { if (!active) SLsmg_set_color(NEWT_COLORSET_COMPACTBUTTON); - else if (SLtt_Use_Ansi_Colors) - SLsmg_set_color(NEWT_COLORSET_BUTTON); else - SLsmg_set_color(NEWT_COLORSET_ACTBUTTON); + SLsmg_set_color(NEWT_COLORSET_ACTCOMPACTBUTTON); newtGotorc(co->top+ pushed, co->left + 1 + pushed); SLsmg_write_char('<'); SLsmg_write_string(bu->text); diff --git a/newt.c b/newt.c index 7b58f17..3703f00 100644 --- a/newt.c +++ b/newt.c @@ -231,7 +231,8 @@ static void updateColorset(char *fg, char *bg, char **fg_p, char **bg_p) /* parse color specifications (e.g. root=,black:border=red,blue) * and update the palette */ -static void parseColors(char *s, struct newtColors *palette) +static void parseColors(char *s, struct newtColors *palette, + char **actCompactButtonFg, char **actCompactButtonBg) { char *name, *str, *fg, *bg; @@ -288,6 +289,8 @@ static void parseColors(char *s, struct newtColors *palette) updateColorset(fg, bg, &palette->disabledEntryFg, &palette->disabledEntryBg); else if (!strcmp(name, "compactbutton")) updateColorset(fg, bg, &palette->compactButtonFg, &palette->compactButtonBg); + else if (!strcmp(name, "actcompactbutton")) + updateColorset(fg, bg, actCompactButtonFg, actCompactButtonBg); else if (!strcmp(name, "actsellistbox")) updateColorset(fg, bg, &palette->actSelListboxFg, &palette->actSelListboxBg); else if (!strcmp(name, "sellistbox")) @@ -300,6 +303,7 @@ static void initColors(void) char *colors, *colors_file, buf[16384]; FILE *f; struct newtColors palette; + char *actCompactButtonFg = NULL, *actCompactButtonBg = NULL; palette = newtDefaultColorPalette; @@ -312,17 +316,21 @@ static void initColors(void) if ((colors = getenv("NEWT_COLORS"))) { strncpy(buf, colors, sizeof (buf)); buf[sizeof (buf) - 1] = '\0'; - parseColors(buf, &palette); + parseColors(buf, &palette, &actCompactButtonFg, &actCompactButtonBg); } else if (colors_file && *colors_file && (f = fopen(colors_file, "r"))) { size_t r; if ((r = fread(buf, 1, sizeof (buf) - 1, f)) > 0) { buf[r] = '\0'; - parseColors(buf, &palette); + parseColors(buf, &palette, &actCompactButtonFg, &actCompactButtonBg); } fclose(f); } newtSetColors(palette); + if (actCompactButtonFg || actCompactButtonBg) + newtSetColor(NEWT_COLORSET_ACTCOMPACTBUTTON, + actCompactButtonFg ? actCompactButtonFg : palette.buttonFg, + actCompactButtonBg ? actCompactButtonBg : palette.buttonBg); } void newtFlushInput(void) { @@ -466,7 +474,8 @@ void newtSetColors(struct newtColors colors) { SLtt_set_mono(NEWT_COLORSET_SELLISTBOX, NULL, SLTT_BOLD_MASK); - SLtt_set_mono(NEWT_COLORSET_ACTBUTTON, NULL, SLTT_REV_MASK); + SLtt_set_mono(NEWT_COLORSET_ACTBUTTON, NULL, SLTT_REV_MASK); + SLtt_set_mono(NEWT_COLORSET_ACTCOMPACTBUTTON, NULL, SLTT_REV_MASK); SLtt_set_mono(NEWT_COLORSET_ACTCHECKBOX, NULL, SLTT_REV_MASK); SLtt_set_mono(NEWT_COLORSET_ACTLISTBOX, NULL, SLTT_REV_MASK); SLtt_set_mono(NEWT_COLORSET_ACTTEXTBOX, NULL, SLTT_REV_MASK); @@ -484,6 +493,8 @@ void newtSetColors(struct newtColors colors) { SLtt_set_color(NEWT_COLORSET_SHADOW, "", colors.shadowFg, colors.shadowBg); SLtt_set_color(NEWT_COLORSET_TITLE, "", colors.titleFg, colors.titleBg); SLtt_set_color(NEWT_COLORSET_BUTTON, "", colors.buttonFg, colors.buttonBg); + SLtt_set_color(NEWT_COLORSET_ACTCOMPACTBUTTON, "", colors.buttonFg, + colors.buttonBg); SLtt_set_color(NEWT_COLORSET_ACTBUTTON, "", colors.actButtonFg, colors.actButtonBg); SLtt_set_color(NEWT_COLORSET_CHECKBOX, "", colors.checkboxFg, @@ -523,7 +534,7 @@ void newtSetColors(struct newtColors colors) { void newtSetColor(int colorset, char *fg, char *bg) { if (colorset < NEWT_COLORSET_ROOT || - (colorset > NEWT_COLORSET_SELLISTBOX && colorset < NEWT_COLORSET_CUSTOM(0)) || + (colorset > NEWT_COLORSET_ACTCOMPACTBUTTON && colorset < NEWT_COLORSET_CUSTOM(0)) || !SLtt_Use_Ansi_Colors) return; diff --git a/newt.h b/newt.h index 07becc7..f2c974a 100644 --- a/newt.h +++ b/newt.h @@ -30,6 +30,7 @@ extern "C" { #define NEWT_COLORSET_COMPACTBUTTON 22 #define NEWT_COLORSET_ACTSELLISTBOX 23 #define NEWT_COLORSET_SELLISTBOX 24 +#define NEWT_COLORSET_ACTCOMPACTBUTTON 25 #define NEWT_COLORSET_CUSTOM(x) (30 + (x))