diff --git a/COPYING b/COPYING index 06ef234..6972c16 100644 --- a/COPYING +++ b/COPYING @@ -123,3 +123,25 @@ UCS-4 to UTF-8 encoding is copied from "terminology": ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The "solarized" color palettes in vte.c are from: + + Copyright (c) 2011 Ethan Schoonover + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. diff --git a/src/main.c b/src/main.c index ad1e04e..a0ef538 100644 --- a/src/main.c +++ b/src/main.c @@ -419,6 +419,8 @@ static void print_help() "\t-t, --term [vt220]\n" "\t Value of the TERM environment variable\n" "\t for the child process\n" + "\t --palette [default]\n" + "\t Select the used color palette\n" "\n" "Video Options:\n" "\t --fbdev [off] Use fbdev instead of DRM\n" @@ -510,6 +512,7 @@ struct conf_option options[] = { CONF_OPTION_BOOL('s', "switchvt", NULL, &kmscon_conf.switchvt, false), CONF_OPTION_BOOL('l', "login", aftercheck_login, &kmscon_conf.login, false), CONF_OPTION_STRING('t', "term", NULL, &kmscon_conf.term, "vt220"), + CONF_OPTION_STRING(0, "palette", NULL, &kmscon_conf.palette, NULL), CONF_OPTION_STRING(0, "xkb-layout", NULL, &kmscon_conf.xkb_layout, "us"), CONF_OPTION_STRING(0, "xkb-variant", NULL, &kmscon_conf.xkb_variant, ""), CONF_OPTION_STRING(0, "xkb-options", NULL, &kmscon_conf.xkb_options, ""), diff --git a/src/main.h b/src/main.h index 4f51647..99de55e 100644 --- a/src/main.h +++ b/src/main.h @@ -68,6 +68,9 @@ struct kmscon_conf_t { /* font engine */ char *font_engine; + + /* color palette */ + char *palette; }; extern struct kmscon_conf_t kmscon_conf; diff --git a/src/vte.c b/src/vte.c index 2c23758..ada0b0c 100644 --- a/src/vte.c +++ b/src/vte.c @@ -53,9 +53,9 @@ #include #include #include - #include "console.h" #include "log.h" +#include "main.h" #include "unicode.h" #include "vte.h" @@ -219,6 +219,87 @@ static uint8_t color_palette[COLOR_NUM][3] = { [COLOR_BACKGROUND] = { 0, 0, 0 }, /* black */ }; +static uint8_t color_palette_solarized[COLOR_NUM][3] = { + [COLOR_BLACK] = { 7, 54, 66 }, /* black */ + [COLOR_RED] = { 220, 50, 47 }, /* red */ + [COLOR_GREEN] = { 133, 153, 0 }, /* green */ + [COLOR_YELLOW] = { 181, 137, 0 }, /* yellow */ + [COLOR_BLUE] = { 38, 139, 210 }, /* blue */ + [COLOR_MAGENTA] = { 211, 54, 130 }, /* magenta */ + [COLOR_CYAN] = { 42, 161, 152 }, /* cyan */ + [COLOR_LIGHT_GREY] = { 238, 232, 213 }, /* light grey */ + [COLOR_DARK_GREY] = { 0, 43, 54 }, /* dark grey */ + [COLOR_LIGHT_RED] = { 203, 75, 22 }, /* light red */ + [COLOR_LIGHT_GREEN] = { 88, 110, 117 }, /* light green */ + [COLOR_LIGHT_YELLOW] = { 101, 123, 131 }, /* light yellow */ + [COLOR_LIGHT_BLUE] = { 131, 148, 150 }, /* light blue */ + [COLOR_LIGHT_MAGENTA] = { 108, 113, 196 }, /* light magenta */ + [COLOR_LIGHT_CYAN] = { 147, 161, 161 }, /* light cyan */ + [COLOR_WHITE] = { 253, 246, 227 }, /* white */ + + [COLOR_FOREGROUND] = { 238, 232, 213 }, /* light grey */ + [COLOR_BACKGROUND] = { 7, 54, 66 }, /* black */ +}; + +static uint8_t color_palette_solarized_black[COLOR_NUM][3] = { + [COLOR_BLACK] = { 0, 0, 0 }, /* black */ + [COLOR_RED] = { 220, 50, 47 }, /* red */ + [COLOR_GREEN] = { 133, 153, 0 }, /* green */ + [COLOR_YELLOW] = { 181, 137, 0 }, /* yellow */ + [COLOR_BLUE] = { 38, 139, 210 }, /* blue */ + [COLOR_MAGENTA] = { 211, 54, 130 }, /* magenta */ + [COLOR_CYAN] = { 42, 161, 152 }, /* cyan */ + [COLOR_LIGHT_GREY] = { 238, 232, 213 }, /* light grey */ + [COLOR_DARK_GREY] = { 0, 43, 54 }, /* dark grey */ + [COLOR_LIGHT_RED] = { 203, 75, 22 }, /* light red */ + [COLOR_LIGHT_GREEN] = { 88, 110, 117 }, /* light green */ + [COLOR_LIGHT_YELLOW] = { 101, 123, 131 }, /* light yellow */ + [COLOR_LIGHT_BLUE] = { 131, 148, 150 }, /* light blue */ + [COLOR_LIGHT_MAGENTA] = { 108, 113, 196 }, /* light magenta */ + [COLOR_LIGHT_CYAN] = { 147, 161, 161 }, /* light cyan */ + [COLOR_WHITE] = { 253, 246, 227 }, /* white */ + + [COLOR_FOREGROUND] = { 238, 232, 213 }, /* light grey */ + [COLOR_BACKGROUND] = { 0, 0, 0 }, /* black */ +}; + +static uint8_t color_palette_solarized_white[COLOR_NUM][3] = { + [COLOR_BLACK] = { 7, 54, 66 }, /* black */ + [COLOR_RED] = { 220, 50, 47 }, /* red */ + [COLOR_GREEN] = { 133, 153, 0 }, /* green */ + [COLOR_YELLOW] = { 181, 137, 0 }, /* yellow */ + [COLOR_BLUE] = { 38, 139, 210 }, /* blue */ + [COLOR_MAGENTA] = { 211, 54, 130 }, /* magenta */ + [COLOR_CYAN] = { 42, 161, 152 }, /* cyan */ + [COLOR_LIGHT_GREY] = { 238, 232, 213 }, /* light grey */ + [COLOR_DARK_GREY] = { 0, 43, 54 }, /* dark grey */ + [COLOR_LIGHT_RED] = { 203, 75, 22 }, /* light red */ + [COLOR_LIGHT_GREEN] = { 88, 110, 117 }, /* light green */ + [COLOR_LIGHT_YELLOW] = { 101, 123, 131 }, /* light yellow */ + [COLOR_LIGHT_BLUE] = { 131, 148, 150 }, /* light blue */ + [COLOR_LIGHT_MAGENTA] = { 108, 113, 196 }, /* light magenta */ + [COLOR_LIGHT_CYAN] = { 147, 161, 161 }, /* light cyan */ + [COLOR_WHITE] = { 253, 246, 227 }, /* white */ + + [COLOR_FOREGROUND] = { 7, 54, 66 }, /* black */ + [COLOR_BACKGROUND] = { 238, 232, 213 }, /* light grey */ +}; + +static uint8_t (*get_palette(void))[3] +{ + if (!kmscon_conf.palette) + return color_palette; + + if (!strcmp(kmscon_conf.palette, "solarized")) + return color_palette_solarized; + if (!strcmp(kmscon_conf.palette, "solarized-black")) + return color_palette_solarized_black; + if (!strcmp(kmscon_conf.palette, "solarized-white")) + return color_palette_solarized_white; + + return color_palette; +} + static void set_fcolor(struct font_char_attr *attr, unsigned int color, struct kmscon_vte *vte) { @@ -275,7 +356,7 @@ int kmscon_vte_new(struct kmscon_vte **out, struct kmscon_console *con, vte->con = con; vte->write_cb = write_cb; vte->data = data; - vte->palette = color_palette; + vte->palette = get_palette(); set_fcolor(&vte->def_attr, COLOR_FOREGROUND, vte); set_bcolor(&vte->def_attr, COLOR_BACKGROUND, vte);