├── .babelrc ├── .gitignore ├── entry.js ├── package.json ├── LICENSE ├── README.md ├── src └── HyperSixteen.js └── lib ├── HyperSixteen.js └── HyperSixteen.js.map /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | presets: [ "es2015" ] 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | 3 | .DS_Store 4 | ._* 5 | *.log -------------------------------------------------------------------------------- /entry.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | // ES6 Setup 4 | // import SourceMap from 'source-map-install' 5 | // import HyperSixteen from './src/HyperSixteen' 6 | // SourceMap.install() 7 | 8 | // ES5 Setup 9 | const SourceMap = require('source-map-support') 10 | const HyperSixteen = require('./lib/HyperSixteen').default 11 | SourceMap.install() 12 | 13 | // Entry Point 14 | let hyper = new HyperSixteen() 15 | exports.decorateConfig = (config) => hyper.decorateConfig(config) 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hypersixteen", 3 | "version": "1.0.4", 4 | "description": "A base16 loader for Hyper.", 5 | "license": "MIT", 6 | "main": "entry.js", 7 | "author": "Jesse Bryan (https://winneon.moe/)", 8 | "repository": "https://github.com/winneon/hypersixteen", 9 | "keywords": [ 10 | "hyper", 11 | "hyper-theme", 12 | "hyperterm", 13 | "hyperterm-theme", 14 | "colors", 15 | "base16" 16 | ], 17 | "dependencies": { 18 | "base16": "^1.0.0", 19 | "source-map-support": "^0.4.3" 20 | }, 21 | "devDependencies": { 22 | "babel-cli": "^6.16.0", 23 | "babel-preset-es2015": "^6.16.0", 24 | "standard": "^8.3.0" 25 | }, 26 | "scripts": { 27 | "build": "standard src/**/*.js && babel src -q -s -d lib" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Jesse Bryan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hypersixteen 2 | 3 | A [base16](https://github.com/chriskempson/base16) loader for [Hyper](https://github.com/zeit/hyper). 4 | 5 | ![](https://i.imgur.com/OkeSb5G.gif) 6 | 7 | ## Installation 8 | 9 | If you have [hpm](https://github.com/zeit/hpm) installed, then installing is very simple: 10 | 11 | ```shell 12 | $ hpm install hypersixteen 13 | ``` 14 | 15 | If you do not, edit your `.hyper.js` configuration and add `hypersixteen` to the `plugins` array. 16 | 17 | ## Configuration 18 | 19 | hypersixteen defaults to base16's default scheme. To change the scheme, add a `base16.scheme` value into your `.hyper.js` configuration. You can also change individual base16 values (00, 01, 02, etc.) in the same fashion. 20 | 21 | ```javascript 22 | module.exports = { 23 | config: { 24 | ... 25 | base16: { 26 | scheme: 'default' // scheme name 27 | base00: '#000000' // manually setting the base00 value to black 28 | } 29 | ... 30 | } 31 | } 32 | ``` 33 | 34 | The available schemes are shown at the [base16-builder](https://github.com/chriskempson/base16-builder/tree/master/schemes) repository. -------------------------------------------------------------------------------- /src/HyperSixteen.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | import * as base from 'base16' 4 | 5 | class HyperSixteen { 6 | decorateConfig (config) { 7 | let scheme = base.default 8 | 9 | if (config.base16 && config.base16.scheme && base[config.base16.scheme]) { 10 | scheme = base[config.base16.scheme] 11 | } 12 | 13 | let base16 = Object.assign({ }, scheme, config.base16) 14 | 15 | let ansi = { 16 | black: base16.base00, 17 | red: base16.base08, 18 | green: base16.base0B, 19 | yellow: base16.base0A, 20 | blue: base16.base0D, 21 | magenta: base16.base0E, 22 | cyan: base16.base0C, 23 | white: base16.base05, 24 | lightBlack: base16.base02, 25 | lightRed: base16.base08, 26 | lightGreen: base16.base0B, 27 | lightYellow: base16.base0A, 28 | lightBlue: base16.base0D, 29 | lightMagenta: base16.base0E, 30 | lightCyan: base16.base0C, 31 | lightWhite: base16.base05 32 | } 33 | 34 | let backgroundColor = config.backgroundColor || base16.base00 35 | let darkBackgroundColor = this.shade(backgroundColor, -0.4) 36 | let foregroundColor = config.foregroundColor || ansi.white 37 | let cursorColor = config.cursorColor || ansi.white 38 | let borderColor = config.borderColor || darkBackgroundColor 39 | 40 | let CSS = ` 41 | .tabs_nav, 42 | .tabs_list, 43 | .tab_tab:not(.tab_active) { 44 | background-color: ${darkBackgroundColor}; 45 | } 46 | 47 | .tabs_list { 48 | border: none; 49 | } 50 | 51 | .tab_tab:not(.tab_active) { 52 | color: ${base16.base02}; 53 | } 54 | 55 | .tabs_title, 56 | .tab_active { 57 | background-color: ${backgroundColor}; 58 | color: ${foregroundColor}; 59 | } 60 | 61 | .tab_active:before, 62 | .tab_icon { 63 | display: none; 64 | } 65 | 66 | ${config.css || ''} 67 | ` 68 | 69 | let termCSS = ` 70 | /* hyperlinks support */ 71 | x-screen a { 72 | color: ${ansi.red}; 73 | } 74 | 75 | ${config.termCSS || ''} 76 | ` 77 | 78 | return Object.assign({ }, config, { 79 | backgroundColor: backgroundColor, 80 | foregroundColor: foregroundColor, 81 | cursorColor: cursorColor, 82 | borderColor: borderColor, 83 | colors: ansi, 84 | css: CSS, 85 | termCSS 86 | }) 87 | } 88 | 89 | // Credit to http://stackoverflow.com/a/13542669. 90 | shade (color, percent) { 91 | let f = parseInt(color.slice(1), 16) 92 | let t = percent < 0 ? 0 : 255 93 | let p = percent < 0 ? percent * -1 : percent 94 | 95 | let r = f >> 16 96 | let g = f >> 8 & 0x00FF 97 | let b = f & 0x0000FF 98 | 99 | return '#' + (0x1000000 + (Math.round((t - r) * p) + r) * 0x10000 + (Math.round((t - g) * p) + g) * 0x100 + (Math.round((t - b) * p) + b)).toString(16).slice(1) 100 | } 101 | } 102 | 103 | export default HyperSixteen 104 | -------------------------------------------------------------------------------- /lib/HyperSixteen.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | 7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 8 | 9 | var _base = require('base16'); 10 | 11 | var base = _interopRequireWildcard(_base); 12 | 13 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } 14 | 15 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 16 | 17 | var HyperSixteen = function () { 18 | function HyperSixteen() { 19 | _classCallCheck(this, HyperSixteen); 20 | } 21 | 22 | _createClass(HyperSixteen, [{ 23 | key: 'decorateConfig', 24 | value: function decorateConfig(config) { 25 | var scheme = base.default; 26 | 27 | if (config.base16 && config.base16.scheme && base[config.base16.scheme]) { 28 | scheme = base[config.base16.scheme]; 29 | } 30 | 31 | var base16 = Object.assign({}, scheme, config.base16); 32 | 33 | var ansi = { 34 | black: base16.base00, 35 | red: base16.base08, 36 | green: base16.base0B, 37 | yellow: base16.base0A, 38 | blue: base16.base0D, 39 | magenta: base16.base0E, 40 | cyan: base16.base0C, 41 | white: base16.base05, 42 | lightBlack: base16.base02, 43 | lightRed: base16.base08, 44 | lightGreen: base16.base0B, 45 | lightYellow: base16.base0A, 46 | lightBlue: base16.base0D, 47 | lightMagenta: base16.base0E, 48 | lightCyan: base16.base0C, 49 | lightWhite: base16.base05 50 | }; 51 | 52 | var backgroundColor = config.backgroundColor || base16.base00; 53 | var darkBackgroundColor = this.shade(backgroundColor, -0.4); 54 | var foregroundColor = config.foregroundColor || ansi.white; 55 | var cursorColor = config.cursorColor || ansi.white; 56 | var borderColor = config.borderColor || darkBackgroundColor; 57 | 58 | var CSS = '\n .tabs_nav,\n .tabs_list,\n .tab_tab:not(.tab_active) {\n background-color: ' + darkBackgroundColor + ';\n }\n\n .tabs_list {\n border: none;\n }\n\n .tab_tab:not(.tab_active) {\n color: ' + base16.base02 + ';\n }\n\n .tabs_title,\n .tab_active {\n background-color: ' + backgroundColor + ';\n color: ' + foregroundColor + ';\n }\n\n .tab_active:before,\n .tab_icon {\n display: none;\n }\n\n ' + (config.css || '') + '\n '; 59 | 60 | var termCSS = '\n /* hyperlinks support */\n x-screen a {\n color: ' + ansi.red + ';\n }\n\n ' + (config.termCSS || '') + '\n '; 61 | 62 | return Object.assign({}, config, { 63 | backgroundColor: backgroundColor, 64 | foregroundColor: foregroundColor, 65 | cursorColor: cursorColor, 66 | borderColor: borderColor, 67 | colors: ansi, 68 | css: CSS, 69 | termCSS: termCSS 70 | }); 71 | } 72 | 73 | // Credit to http://stackoverflow.com/a/13542669. 74 | 75 | }, { 76 | key: 'shade', 77 | value: function shade(color, percent) { 78 | var f = parseInt(color.slice(1), 16); 79 | var t = percent < 0 ? 0 : 255; 80 | var p = percent < 0 ? percent * -1 : percent; 81 | 82 | var r = f >> 16; 83 | var g = f >> 8 & 0x00FF; 84 | var b = f & 0x0000FF; 85 | 86 | return '#' + (0x1000000 + (Math.round((t - r) * p) + r) * 0x10000 + (Math.round((t - g) * p) + g) * 0x100 + (Math.round((t - b) * p) + b)).toString(16).slice(1); 87 | } 88 | }]); 89 | 90 | return HyperSixteen; 91 | }(); 92 | 93 | exports.default = HyperSixteen; 94 | //# sourceMappingURL=HyperSixteen.js.map -------------------------------------------------------------------------------- /lib/HyperSixteen.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["../src/HyperSixteen.js"],"names":["base","HyperSixteen","config","scheme","default","base16","Object","assign","ansi","black","base00","red","base08","green","base0B","yellow","base0A","blue","base0D","magenta","base0E","cyan","base0C","white","base05","lightBlack","base02","lightRed","lightGreen","lightYellow","lightBlue","lightMagenta","lightCyan","lightWhite","backgroundColor","darkBackgroundColor","shade","foregroundColor","cursorColor","borderColor","CSS","css","termCSS","colors","color","percent","f","parseInt","slice","t","p","r","g","b","Math","round","toString"],"mappings":"AAAA;;;;;;;;AAEA;;IAAYA,I;;;;;;IAENC,Y;;;;;;;mCACYC,M,EAAQ;AACtB,UAAIC,SAASH,KAAKI,OAAlB;;AAEA,UAAIF,OAAOG,MAAP,IAAiBH,OAAOG,MAAP,CAAcF,MAA/B,IAAyCH,KAAKE,OAAOG,MAAP,CAAcF,MAAnB,CAA7C,EAAyE;AACvEA,iBAASH,KAAKE,OAAOG,MAAP,CAAcF,MAAnB,CAAT;AACD;;AAED,UAAIE,SAASC,OAAOC,MAAP,CAAc,EAAd,EAAmBJ,MAAnB,EAA2BD,OAAOG,MAAlC,CAAb;;AAEA,UAAIG,OAAO;AACTC,eAAOJ,OAAOK,MADL;AAETC,aAAKN,OAAOO,MAFH;AAGTC,eAAOR,OAAOS,MAHL;AAITC,gBAAQV,OAAOW,MAJN;AAKTC,cAAMZ,OAAOa,MALJ;AAMTC,iBAASd,OAAOe,MANP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CAAV,GAAc,CAAd,GAAkB,GAA1B;AACA,UAAIK,IAAIL,UAAU,CAAV,GAAcA,UAAU,CAAC,CAAzB,GAA6BA,OAArC;;AAEA,UAAIM,IAAIL,KAAK,EAAb;AACA,UAAIM,IAAIN,KAAK,CAAL,GAAS,MAAjB;AACA,UAAIO,IAAIP,IAAI,QAAZ;;AAEA,aAAO,MAAM,CAAC,YAAY,CAACQ,KAAKC,KAAL,CAAW,CAACN,IAAIE,CAAL,IAAUD,CAArB,IAA0BC,CAA3B,IAAgC,OAA5C,GAAsD,CAACG,KAAKC,KAAL,CAAW,CAACN,IAAIG,CAAL,IAAUF,CAArB,IAA0BE,CAA3B,IAAgC,KAAtF,IAA+FE,KAAKC,KAAL,CAAW,CAACN,IAAII,CAAL,IAAUH,CAArB,IAA0BG,CAAzH,CAAD,EAA8HG,QAA9H,CAAuI,EAAvI,EAA2IR,KAA3I,CAAiJ,CAAjJ,CAAb;AACD;;;;;;kBAGY/C,Y","file":"HyperSixteen.js","sourcesContent":["'use strict'\n\nimport * as base from 'base16'\n\nclass HyperSixteen {\n decorateConfig (config) {\n let scheme = base.default\n\n if (config.base16 && config.base16.scheme && base[config.base16.scheme]) {\n scheme = base[config.base16.scheme]\n }\n\n let base16 = Object.assign({ }, scheme, config.base16)\n\n let ansi = {\n black: base16.base00,\n red: base16.base08,\n green: base16.base0B,\n yellow: base16.base0A,\n blue: base16.base0D,\n magenta: base16.base0E,\n cyan: base16.base0C,\n white: base16.base05,\n lightBlack: base16.base02,\n lightRed: base16.base08,\n lightGreen: base16.base0B,\n lightYellow: base16.base0A,\n lightBlue: base16.base0D,\n lightMagenta: base16.base0E,\n lightCyan: base16.base0C,\n lightWhite: base16.base05\n }\n\n let backgroundColor = config.backgroundColor || base16.base00\n let darkBackgroundColor = this.shade(backgroundColor, -0.4)\n let foregroundColor = config.foregroundColor || ansi.white\n let cursorColor = config.cursorColor || ansi.white\n let borderColor = config.borderColor || darkBackgroundColor\n\n let CSS = `\n .tabs_nav,\n .tabs_list,\n .tab_tab:not(.tab_active) {\n background-color: ${darkBackgroundColor};\n }\n\n .tabs_list {\n border: none;\n }\n\n .tab_tab:not(.tab_active) {\n color: ${base16.base02};\n }\n\n .tabs_title,\n .tab_active {\n background-color: ${backgroundColor};\n color: ${foregroundColor};\n }\n\n .tab_active:before,\n .tab_icon {\n display: none;\n }\n\n ${config.css || ''}\n `\n\n let termCSS = `\n /* hyperlinks support */\n x-screen a {\n color: ${ansi.red};\n }\n\n ${config.termCSS || ''}\n `\n\n return Object.assign({ }, config, {\n backgroundColor: backgroundColor,\n foregroundColor: foregroundColor,\n cursorColor: cursorColor,\n borderColor: borderColor,\n colors: ansi,\n css: CSS,\n termCSS\n })\n }\n\n // Credit to http://stackoverflow.com/a/13542669.\n shade (color, percent) {\n let f = parseInt(color.slice(1), 16)\n let t = percent < 0 ? 0 : 255\n let p = percent < 0 ? percent * -1 : percent\n\n let r = f >> 16\n let g = f >> 8 & 0x00FF\n let b = f & 0x0000FF\n\n return '#' + (0x1000000 + (Math.round((t - r) * p) + r) * 0x10000 + (Math.round((t - g) * p) + g) * 0x100 + (Math.round((t - b) * p) + b)).toString(16).slice(1)\n }\n}\n\nexport default HyperSixteen\n"]} --------------------------------------------------------------------------------