-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHyperSixteen.js
103 lines (84 loc) · 2.46 KB
/
HyperSixteen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
'use strict'
import * as base from 'base16'
class HyperSixteen {
decorateConfig (config) {
let scheme = base.default
if (config.base16 && config.base16.scheme && base[config.base16.scheme]) {
scheme = base[config.base16.scheme]
}
let base16 = Object.assign({ }, scheme, config.base16)
let ansi = {
black: base16.base00,
red: base16.base08,
green: base16.base0B,
yellow: base16.base0A,
blue: base16.base0D,
magenta: base16.base0E,
cyan: base16.base0C,
white: base16.base05,
lightBlack: base16.base02,
lightRed: base16.base08,
lightGreen: base16.base0B,
lightYellow: base16.base0A,
lightBlue: base16.base0D,
lightMagenta: base16.base0E,
lightCyan: base16.base0C,
lightWhite: base16.base05
}
let backgroundColor = config.backgroundColor || base16.base00
let darkBackgroundColor = this.shade(backgroundColor, -0.4)
let foregroundColor = config.foregroundColor || ansi.white
let cursorColor = config.cursorColor || ansi.white
let borderColor = config.borderColor || darkBackgroundColor
let CSS = `
.tabs_nav,
.tabs_list,
.tab_tab:not(.tab_active) {
background-color: ${darkBackgroundColor};
}
.tabs_list {
border: none;
}
.tab_tab:not(.tab_active) {
color: ${base16.base02};
}
.tabs_title,
.tab_active {
background-color: ${backgroundColor};
color: ${foregroundColor};
}
.tab_active:before,
.tab_icon {
display: none;
}
${config.css || ''}
`
let termCSS = `
/* hyperlinks support */
x-screen a {
color: ${ansi.red};
}
${config.termCSS || ''}
`
return Object.assign({ }, config, {
backgroundColor: backgroundColor,
foregroundColor: foregroundColor,
cursorColor: cursorColor,
borderColor: borderColor,
colors: ansi,
css: CSS,
termCSS
})
}
// Credit to http://stackoverflow.com/a/13542669.
shade (color, percent) {
let f = parseInt(color.slice(1), 16)
let t = percent < 0 ? 0 : 255
let p = percent < 0 ? percent * -1 : percent
let r = f >> 16
let g = f >> 8 & 0x00FF
let b = f & 0x0000FF
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)
}
}
export default HyperSixteen