From d94b5df94b5aaa77c4dfb62033991725ffae4001 Mon Sep 17 00:00:00 2001 From: Josh Dick Date: Thu, 1 Jun 2017 18:34:33 -0400 Subject: [PATCH] Tweak terminal color scheme selection colors to be more sensible. Fixes #104. --- build/build.js | 41 ++++- build/templates/One Dark.itermcolors | 259 +++++++++++++++++++++++++++ build/templates/One Dark.terminal | 94 ++++++++++ term/One Dark.itermcolors | 22 +-- term/One Dark.terminal | 4 +- 5 files changed, 405 insertions(+), 15 deletions(-) create mode 100644 build/templates/One Dark.itermcolors create mode 100644 build/templates/One Dark.terminal diff --git a/build/build.js b/build/build.js index 91a9b50..bc5508d 100755 --- a/build/build.js +++ b/build/build.js @@ -1,5 +1,6 @@ #!/usr/bin/env node +const _ = require('lodash') // ships with termcolors; only used because of termcolors customization const doT = require('doT') const termcolors = require('termcolors') const { readFileSync, writeFileSync } = require('fs') @@ -115,9 +116,45 @@ try { const xresources = readFileSync(resolve(__dirname, '../term/One Dark.Xresources'), 'utf8') const terminalPalette = termcolors.xresources.import(xresources) + let itermTemplate, terminalAppTemplate + + // Compile custom terminal color templates based on ones that ship with termcolors try { - writeFileSync(resolve(__dirname, '../term/One\ Dark.itermcolors'), termcolors.iterm.export(terminalPalette)) - writeFileSync(resolve(__dirname, '../term/One\ Dark.terminal'), termcolors.terminalapp.export(terminalPalette)) + itermTemplate = termcolors.export( + // From termcolors/lib/formats/iterm.js + readFileSync(resolve(__dirname, 'templates/One\ Dark.itermcolors')), + _.partialRight(_.mapValues, function (color) { + return color.toAvgRgbArray() + }) + ) + + // From termcolors/lib/formats/terminal-app.js + const code = [ + new Buffer('62706c6973743030d40102030405061516582476657273696f6e58246f626a65637473592461726368697665725424746f7012000186a0a307080f55246e756c6cd3090a0b0c0d0e554e535247425c4e53436f6c6f7253706163655624636c6173734f1027', 'hex'), + new Buffer('0010018002d2101112135a24636c6173736e616d655824636c6173736573574e53436f6c6f72a21214584e534f626a6563745f100f4e534b657965644172636869766572d1171854726f6f74800108111a232d32373b41484e5b628c8e9095a0a9b1b4bdcfd2d700000000000001010000000000000019000000000000000000000000000000d9', 'hex') + ] + + terminalAppTemplate = termcolors.export( + readFileSync(resolve(__dirname, 'templates/One\ Dark.terminal')), + // From termcolors/lib/formats/terminal-app.js + _.partialRight(_.mapValues, function (color) { + var srgb = color.toAvgRgbArray() + srgb = srgb.map(function (n) { + return n.toFixed(10).toString() + }).join(' ') + var output = code[0].toString('binary') + srgb + code[1].toString('binary') + output = (new Buffer(output, 'binary')).toString('base64') + return output.match(/.{1,68}/g).join('\n\t') + }) + ) + + } catch (e) { + handleError('Error compiling terminal color template', e) + } + + try { + writeFileSync(resolve(__dirname, '../term/One\ Dark.itermcolors'), itermTemplate(terminalPalette)) + writeFileSync(resolve(__dirname, '../term/One\ Dark.terminal'), terminalAppTemplate(terminalPalette)) } catch (e) { handleError('Error writing terminal color file', e) } diff --git a/build/templates/One Dark.itermcolors b/build/templates/One Dark.itermcolors new file mode 100644 index 0000000..faa4104 --- /dev/null +++ b/build/templates/One Dark.itermcolors @@ -0,0 +1,259 @@ + + + + + Ansi 0 Color + + Color Space + sRGB + Blue Component + {{=c[0][2]}} + Green Component + {{=c[0][1]}} + Red Component + {{=c[0][0]}} + + Ansi 1 Color + + Color Space + sRGB + Blue Component + {{=c[1][2]}} + Green Component + {{=c[1][1]}} + Red Component + {{=c[1][0]}} + + Ansi 10 Color + + Color Space + sRGB + Blue Component + {{=c[10][2]}} + Green Component + {{=c[10][1]}} + Red Component + {{=c[10][0]}} + + Ansi 11 Color + + Color Space + sRGB + Blue Component + {{=c[11][2]}} + Green Component + {{=c[11][1]}} + Red Component + {{=c[11][0]}} + + Ansi 12 Color + + Color Space + sRGB + Blue Component + {{=c[12][2]}} + Green Component + {{=c[12][1]}} + Red Component + {{=c[12][0]}} + + Ansi 13 Color + + Color Space + sRGB + Blue Component + {{=c[13][2]}} + Green Component + {{=c[13][1]}} + Red Component + {{=c[13][0]}} + + Ansi 14 Color + + Color Space + sRGB + Blue Component + {{=c[14][2]}} + Green Component + {{=c[14][1]}} + Red Component + {{=c[14][0]}} + + Ansi 15 Color + + Color Space + sRGB + Blue Component + {{=c[15][2]}} + Green Component + {{=c[15][1]}} + Red Component + {{=c[15][0]}} + + Ansi 2 Color + + Color Space + sRGB + Blue Component + {{=c[2][2]}} + Green Component + {{=c[2][1]}} + Red Component + {{=c[2][0]}} + + Ansi 3 Color + + Color Space + sRGB + Blue Component + {{=c[3][2]}} + Green Component + {{=c[3][1]}} + Red Component + {{=c[3][0]}} + + Ansi 4 Color + + Color Space + sRGB + Blue Component + {{=c[4][2]}} + Green Component + {{=c[4][1]}} + Red Component + {{=c[4][0]}} + + Ansi 5 Color + + Color Space + sRGB + Blue Component + {{=c[5][2]}} + Green Component + {{=c[5][1]}} + Red Component + {{=c[5][0]}} + + Ansi 6 Color + + Color Space + sRGB + Blue Component + {{=c[6][2]}} + Green Component + {{=c[6][1]}} + Red Component + {{=c[6][0]}} + + Ansi 7 Color + + Color Space + sRGB + Blue Component + {{=c[7][2]}} + Green Component + {{=c[7][1]}} + Red Component + {{=c[7][0]}} + + Ansi 8 Color + + Color Space + sRGB + Blue Component + {{=c[8][2]}} + Green Component + {{=c[8][1]}} + Red Component + {{=c[8][0]}} + + Ansi 9 Color + + Color Space + sRGB + Blue Component + {{=c[9][2]}} + Green Component + {{=c[9][1]}} + Red Component + {{=c[9][0]}} + + Background Color + + Color Space + sRGB + Blue Component + {{=c.background[2]}} + Green Component + {{=c.background[1]}} + Red Component + {{=c.background[0]}} + + Bold Color + + Color Space + sRGB + Blue Component + {{=c.foreground[2]}} + Green Component + {{=c.foreground[1]}} + Red Component + {{=c.foreground[0]}} + + Cursor Color + + Color Space + sRGB + Blue Component + {{=c.foreground[2]}} + Green Component + {{=c.foreground[1]}} + Red Component + {{=c.foreground[0]}} + + Cursor Text Color + + Color Space + sRGB + Blue Component + {{=c.background[2]}} + Green Component + {{=c.background[1]}} + Red Component + {{=c.background[0]}} + + Foreground Color + + Color Space + sRGB + Blue Component + {{=c.foreground[2]}} + Green Component + {{=c.foreground[1]}} + Red Component + {{=c.foreground[0]}} + + Selected Text Color + + Color Space + sRGB + Blue Component + {{=c.background[2]}} + Green Component + {{=c.background[1]}} + Red Component + {{=c.background[0]}} + + Selection Color + + Color Space + sRGB + Blue Component + {{=c.foreground[2]}} + Green Component + {{=c.foreground[1]}} + Red Component + {{=c.foreground[0]}} + + + diff --git a/build/templates/One Dark.terminal b/build/templates/One Dark.terminal new file mode 100644 index 0000000..984831c --- /dev/null +++ b/build/templates/One Dark.terminal @@ -0,0 +1,94 @@ + + + + + ANSIBlackColor + + {{=c[0]}} + + ANSIBlueColor + + {{=c[4]}} + + ANSIBrightBlackColor + + {{=c[8]}} + + ANSIBrightBlueColor + + {{=c[12]}} + + ANSIBrightCyanColor + + {{=c[14]}} + + ANSIBrightGreenColor + + {{=c[10]}} + + ANSIBrightMagentaColor + + {{=c[13]}} + + ANSIBrightRedColor + + {{=c[9]}} + + ANSIBrightWhiteColor + + {{=c[15]}} + + ANSIBrightYellowColor + + {{=c[11]}} + + ANSICyanColor + + {{=c[6]}} + + ANSIGreenColor + + {{=c[2]}} + + ANSIMagentaColor + + {{=c[5]}} + + ANSIRedColor + + {{=c[1]}} + + ANSIWhiteColor + + {{=c[7]}} + + ANSIYellowColor + + {{=c[3]}} + + BackgroundColor + + {{=c.background}} + + CursorColor + + {{=c.foreground}} + + SelectionColor + + {{=c[15]}} + + TextBoldColor + + {{=c.foreground}} + + TextColor + + {{=c.foreground}} + + name + One Dark + type + Window Settings + + diff --git a/term/One Dark.itermcolors b/term/One Dark.itermcolors index bf68111..471e0c5 100644 --- a/term/One Dark.itermcolors +++ b/term/One Dark.itermcolors @@ -234,17 +234,6 @@ 0.6705882352941176 Selected Text Color - - Color Space - sRGB - Blue Component - 0.7490196078431373 - Green Component - 0.6980392156862745 - Red Component - 0.6705882352941176 - - Selection Color Color Space sRGB @@ -255,5 +244,16 @@ Red Component 0.1568627450980392 + Selection Color + + Color Space + sRGB + Blue Component + 0.7490196078431373 + Green Component + 0.6980392156862745 + Red Component + 0.6705882352941176 + diff --git a/term/One Dark.terminal b/term/One Dark.terminal index 96ad5ae..d10c58b 100644 --- a/term/One Dark.terminal +++ b/term/One Dark.terminal @@ -168,7 +168,7 @@ YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPECcw - LjMzNzI1NDkwMjAgMC43MTM3MjU0OTAyIDAuNzYwNzg0MzEzNwAQAYAC0hAREhNaJGNs + LjM2MDc4NDMxMzcgMC4zODgyMzUyOTQxIDAuNDM5MjE1Njg2MwAQAYAC0hAREhNaJGNs YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp dmVy0RcYVHJvb3SAAQgRGiMtMjc7QUhOW2KMjpCVoKmxtL3P0tcAAAAAAAABAQAAAAAA AAAZAAAAAAAAAAAAAAAAAAAA2Q== @@ -192,7 +192,7 @@ AAAZAAAAAAAAAAAAAAAAAAAA2Q== name - terminal.sexy + One Dark type Window Settings