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
|
#!/usr/bin/env node
_s = require('underscore.string');
var line = "\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\n \x0311,1Y\x03\x037,1O\x03\x037,1 \x03\x0313,1Y\x03\x0313,1O\x03\x0313,1 \x03\x036,1Y\x03\x036,1O\x03\x036,1!\x03\x036,1!\x03\x036,1!\x03\x036,1!\x03\n \x030,11 \x03\x030,11 \x03\x030,11 \x03\n \x030,11 \x03\x030,11 \x03\x030,11 \x03 \x030,11 \x03 \x030,11 \x03\n \x030,11 \x03\n \x030,12 \x03 \x030,12 \x03\n \x030,10 \x03\n \x030,10 \x03\x030,10 \x03 \x030,12 \x03\n \x030,12 \x03\x030,12 \x03\x030,12 \x03\n \x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\n \x030,4 \x03\x030,4 \x03\x030,4 \x03\x030,4 \x03\x030,4 \x03\x030,4 \x03\x030,4 \x03\n \x030,4 \x03\x030,4 \x03\x030,4 \x03 \x030,4 \x03\x030,4 \x03\x030,4 \x03\n \x030,4 \x03\x030,4 \x03\x030,4 \x03\n";
var parts = line.split("\x03");
var mirc =
{
'0':'white',
'1':'black',
'2':'blue',
'3':'green',
'4':'red',
'5':'brown',
'6':'purple',
'7':'orange',
'8':'yellow',
'9':'light green',
'10':'teal',
'11':'light cyan',
'12':'light blue',
'13':'pink',
'14':'gray',
'15':'light gray',
}
var term_background =
{
'white':'107',
'black':'40',
'blue':'44',
'green':'42',
'red':'41',
'purple':'45',
'yellow':'43',
'teal':'46',
'light gray':'47',
'dark gray':'100',
'orange':'101',
'light green':'102',
'light yellow':'103',
'light blue':'104',
'pink':'105',
'light cyan':'106',
}
var term_foreground =
{
'black':'30',
'red':'31',
'green':'32',
'yellow':'33',
'blue':'34',
'purple':'35',
'teal':'36',
'light gray':'37',
'dark gray':'90',
'orange':'91',
'light green':'92',
'light yellow':'93',
'light blue':'94',
'pink':'95',
'light cyan':'96',
'white':'97',
}
for(var i = 0; i < parts.length; i++){
var match = parts[i].match(/(\d+),(\d+)(.*)/);
if (match){
match_list = parts[i].split(/(\d+),(\d+)(.*)/);
var fg = mirc[match_list[1]];
var bg = mirc[match_list[2]];
var content = match_list[3];
var background_color = term_background[bg];
var foreground_color = term_foreground[fg];
// var result = _s.sprintf("foreground: %s, background: %s, content: %s\n", fg, bg, content);
var result = _s.sprintf("\\033[1;%s;%sm%s\\033[0m", foreground_color, background_color, content);
parts[i] = result;
// console.log(result)
// console.log(background_color);
if (typeof(background_color) === 'undefined'){
console.log(bg); process.exit(1);
}
}else{
var result = _s.sprintf("content: %s", parts[i]);
console.log(result);
}
};
console.log(parts.join());
|