From bda5a8d1d286a406816af958c43bfef6d19fc4f5 Mon Sep 17 00:00:00 2001 From: Howland Owl Date: Wed, 26 Apr 2017 01:23:20 +0300 Subject: [PATCH 1/3] a bit silly but leave the usealtcolors thing in there to stop compile errors --- st.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/st.c b/st.c index 92c35d4..dd446cd 100644 --- a/st.c +++ b/st.c @@ -4171,10 +4171,8 @@ numlock(const Arg *dummy) void swapcolors(const Arg *dummy) { -// usealtcolors = !usealtcolors; + usealtcolors = !usealtcolors; whichcolortable = whichcolortable +1; - printf("%d, %d\n",whichcolortable, - sizeof(colornames)/sizeof(colornames[0]) ); if ( whichcolortable >= sizeof(colornames)/sizeof(colornames[0]) ) { whichcolortable = 0; } From 447600497e518465ee09e570d2a3ce323678114f Mon Sep 17 00:00:00 2001 From: Howland Owl Date: Wed, 26 Apr 2017 02:13:00 +0300 Subject: [PATCH 2/3] ability to change title (but no string to change yet) --- st.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/st.c b/st.c index dd446cd..ccb9370 100644 --- a/st.c +++ b/st.c @@ -4034,6 +4034,17 @@ xresettitle(void) xsettitle(opt_title ? opt_title : "st"); } +void xcolor2title(void){ + char *cs; + size_t lencs; + + lencs = (size_t)snprintf(NULL,0,"new color %d",whichcolortable); + cs = malloc(lencs); + snprintf(cs,lencs,"new color %d",whichcolortable); + xsettitle(cs); + free(cs); +} + void redraw(void) { @@ -4176,6 +4187,7 @@ swapcolors(const Arg *dummy) if ( whichcolortable >= sizeof(colornames)/sizeof(colornames[0]) ) { whichcolortable = 0; } + xcolor2title(); xloadcols(); redraw(); } From bf70ebefbfff53c85b71cb950d268a29c50cc9b0 Mon Sep 17 00:00:00 2001 From: Howland Owl Date: Wed, 26 Apr 2017 03:15:56 +0300 Subject: [PATCH 3/3] And a method for printing the colorscheme. --- config.h | 8 +++++++- st.c | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/config.h b/config.h index c699cdd..6085580 100644 --- a/config.h +++ b/config.h @@ -88,7 +88,13 @@ static const int alpha = 0xdd; static int whichcolortable = 0; -static char *colornames[3][260] = { +static const char *schemenames[] = { + "Cobalt Neon", + "Highway", + "Grape", +}; + +static char *colorchart[3][260] = { // cobalt neon { "#142631", // 0 diff --git a/st.c b/st.c index ccb9370..a31527b 100644 --- a/st.c +++ b/st.c @@ -3167,7 +3167,7 @@ sixd_to_16bit(int x) const char* getcolorname(int i) { - return colornames[whichcolortable][i]; + return colorchart[whichcolortable][i]; // return (usealtcolors) ? altcolorname[i] : colorname[i]; } @@ -4040,7 +4040,7 @@ void xcolor2title(void){ lencs = (size_t)snprintf(NULL,0,"new color %d",whichcolortable); cs = malloc(lencs); - snprintf(cs,lencs,"new color %d",whichcolortable); + sprintf(cs,"colorscheme %s",schemenames[whichcolortable]); xsettitle(cs); free(cs); } @@ -4184,7 +4184,7 @@ swapcolors(const Arg *dummy) { usealtcolors = !usealtcolors; whichcolortable = whichcolortable +1; - if ( whichcolortable >= sizeof(colornames)/sizeof(colornames[0]) ) { + if ( whichcolortable >= sizeof(colorchart)/sizeof(colorchart[0]) ) { whichcolortable = 0; } xcolor2title();