UNPKG

1.13 kBJavaScriptView Raw
1'use strict';
2
3module.exports = function (Terminal) {
4
5 // Colors 0-15
6 Terminal.colors = [
7 // dark:
8 '#2e3436', '#cc0000', '#4e9a06', '#c4a000', '#3465a4', '#75507b', '#06989a', '#d3d7cf',
9 // bright:
10 '#555753', '#ef2929', '#8ae234', '#fce94f', '#729fcf', '#ad7fa8', '#34e2e2', '#eeeeec'];
11
12 // Colors 16-255
13 // Much thanks to TooTallNate for writing this.
14 Terminal.colors = (function() {
15 var colors = Terminal.colors,
16 r = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff],
17 i;
18
19 // 16-231
20 i = 0;
21 for (; i < 216; i++) {
22 out(r[(i / 36) % 6 | 0], r[(i / 6) % 6 | 0], r[i % 6]);
23 }
24
25 // 232-255 (grey)
26 i = 0;
27 for (; i < 24; i++) {
28 r = 8 + i * 10;
29 out(r, r, r);
30 }
31
32 function out(r, g, b) {
33 colors.push('#' + hex(r) + hex(g) + hex(b));
34 }
35
36 function hex(c) {
37 c = c.toString(16);
38 return c.length < 2 ? '0' + c : c;
39 }
40
41 return colors;
42 })();
43
44 // Default BG/FG
45 Terminal.defaultColors = {
46 bg: '#000000',
47 fg: '#f0f0f0'
48 };
49
50 Terminal.colors[256] = Terminal.defaultColors.bg;
51 Terminal.colors[257] = Terminal.defaultColors.fg;
52};