Switch to Renegade style color codes as default pipe code system
This commit is contained in:
parent
727f9fdb1f
commit
3ffccc35da
|
@ -159,7 +159,7 @@ ClientTerminal.prototype.rawWrite = function(s) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientTerminal.prototype.pipeWrite = function(s, spec) {
|
ClientTerminal.prototype.pipeWrite = function(s, spec) {
|
||||||
spec = spec || 'enigma';
|
spec = spec || 'renegade';
|
||||||
|
|
||||||
var conv = {
|
var conv = {
|
||||||
enigma : enigmaToAnsi,
|
enigma : enigmaToAnsi,
|
||||||
|
|
|
@ -7,10 +7,10 @@ var getPredefinedMCIValue = require('./predefined_mci.js').getPredefinedMCIValue
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
|
|
||||||
exports.pipeToAnsi = exports.enigmaToAnsi = enigmaToAnsi;
|
exports.enigmaToAnsi = enigmaToAnsi;
|
||||||
exports.stripPipeCodes = exports.stripEnigmaCodes = stripEnigmaCodes;
|
exports.stripPipeCodes = exports.stripEnigmaCodes = stripEnigmaCodes;
|
||||||
exports.pipeStrLen = exports.enigmaStrLen = enigmaStrLen;
|
exports.pipeStrLen = exports.enigmaStrLen = enigmaStrLen;
|
||||||
exports.renegadeToAnsi = renegadeToAnsi;
|
exports.pipeToAnsi = exports.renegadeToAnsi = renegadeToAnsi;
|
||||||
|
|
||||||
// :TODO: Not really happy with the module name of "color_codes". Would like something better
|
// :TODO: Not really happy with the module name of "color_codes". Would like something better
|
||||||
|
|
||||||
|
@ -83,13 +83,13 @@ function enigmaStrLen(s) {
|
||||||
return stripEnigmaCodes(s).length;
|
return stripEnigmaCodes(s).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renegadeToAnsi(s) {
|
function renegadeToAnsi(s, client) {
|
||||||
if(-1 == s.indexOf('|')) {
|
if(-1 == s.indexOf('|')) {
|
||||||
return s; // no pipe codes present
|
return s; // no pipe codes present
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = '';
|
var result = '';
|
||||||
var re = /\|(\d{2}|\|)/g;
|
var re = /\|([A-Z\d]{2}|\|)/g;
|
||||||
var m;
|
var m;
|
||||||
var lastIndex = 0;
|
var lastIndex = 0;
|
||||||
while((m = re.exec(s))) {
|
while((m = re.exec(s))) {
|
||||||
|
@ -103,40 +103,44 @@ if(-1 == s.indexOf('|')) {
|
||||||
// convert to number
|
// convert to number
|
||||||
val = parseInt(val, 10);
|
val = parseInt(val, 10);
|
||||||
if(isNaN(val)) {
|
if(isNaN(val)) {
|
||||||
val = 0;
|
val = getPredefinedMCIValue(client, m[1]) || ('|' + m[1]); // value itself or literal
|
||||||
}
|
}
|
||||||
assert(val >= 0 && val <= 23);
|
|
||||||
|
|
||||||
var attr = ansi.sgr({
|
if(_.isString(val)) {
|
||||||
0 : [ 'reset', 'black' ],
|
result += s.substr(lastIndex, m.index - lastIndex) + val;
|
||||||
1 : [ 'reset', 'blue' ],
|
} else {
|
||||||
2 : [ 'reset', 'green' ],
|
var attr = ansi.sgr({
|
||||||
3 : [ 'reset', 'cyan' ],
|
0 : [ 'reset', 'black' ],
|
||||||
4 : [ 'reset', 'red' ],
|
1 : [ 'reset', 'blue' ],
|
||||||
5 : [ 'reset', 'magenta' ],
|
2 : [ 'reset', 'green' ],
|
||||||
6 : [ 'reset', 'yellow' ],
|
3 : [ 'reset', 'cyan' ],
|
||||||
7 : [ 'reset', 'white' ],
|
4 : [ 'reset', 'red' ],
|
||||||
|
5 : [ 'reset', 'magenta' ],
|
||||||
|
6 : [ 'reset', 'yellow' ],
|
||||||
|
7 : [ 'reset', 'white' ],
|
||||||
|
|
||||||
8 : [ 'bold', 'black' ],
|
8 : [ 'bold', 'black' ],
|
||||||
9 : [ 'bold', 'blue' ],
|
9 : [ 'bold', 'blue' ],
|
||||||
10 : [ 'bold', 'green' ],
|
10 : [ 'bold', 'green' ],
|
||||||
11 : [ 'bold', 'cyan' ],
|
11 : [ 'bold', 'cyan' ],
|
||||||
12 : [ 'bold', 'red' ],
|
12 : [ 'bold', 'red' ],
|
||||||
13 : [ 'bold', 'magenta' ],
|
13 : [ 'bold', 'magenta' ],
|
||||||
14 : [ 'bold', 'yellow' ],
|
14 : [ 'bold', 'yellow' ],
|
||||||
15 : [ 'bold', 'white' ],
|
15 : [ 'bold', 'white' ],
|
||||||
|
|
||||||
16 : [ 'blackBG' ],
|
16 : [ 'blackBG' ],
|
||||||
17 : [ 'blueBG' ],
|
17 : [ 'blueBG' ],
|
||||||
18 : [ 'greenBG' ],
|
18 : [ 'greenBG' ],
|
||||||
19 : [ 'cyanBG' ],
|
19 : [ 'cyanBG' ],
|
||||||
20 : [ 'redBG' ],
|
20 : [ 'redBG' ],
|
||||||
21 : [ 'magentaBG' ],
|
21 : [ 'magentaBG' ],
|
||||||
22 : [ 'yellowBG' ],
|
22 : [ 'yellowBG' ],
|
||||||
23 : [ 'whiteBG' ],
|
23 : [ 'whiteBG' ],
|
||||||
}[val] || 'normal');
|
}[val] || 'normal');
|
||||||
|
|
||||||
|
result += s.substr(lastIndex, m.index - lastIndex) + attr;
|
||||||
|
}
|
||||||
|
|
||||||
result += s.substr(lastIndex, m.index - lastIndex) + attr;
|
|
||||||
lastIndex = re.lastIndex;
|
lastIndex = re.lastIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,9 +78,9 @@ function prepareTerminal(term) {
|
||||||
|
|
||||||
function displayBanner(term) {
|
function displayBanner(term) {
|
||||||
term.pipeWrite(
|
term.pipeWrite(
|
||||||
'|33Conected to |32EN|33|01i|00|32|22GMA|32|01½|00 |33BBS version|31|01 |VN\n' +
|
'|06Conected to |02EN|10i|02GMA|10½ |06BBS version |12|VN\n' +
|
||||||
'|00|33Copyright (c) 2014-2015 Bryan Ashby |33|01- |31|01http://l33t.codes/\n' +
|
'|06Copyright (c) 2014-2015 Bryan Ashby |14- |12http://l33t.codes/\n' +
|
||||||
'|00|33Updates & source |01- |31|01https://github.com/NuSkooler/enigma-bbs/\n' +
|
'|06Updates & source |14- |12https://github.com/NuSkooler/enigma-bbs/\n' +
|
||||||
'|00');
|
'|00');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ function VerticalMenuView(options) {
|
||||||
// :TODO: shoudl we detect if pipe codes are used?
|
// :TODO: shoudl we detect if pipe codes are used?
|
||||||
self.client.term.write(
|
self.client.term.write(
|
||||||
ansi.goto(item.row, self.position.col) +
|
ansi.goto(item.row, self.position.col) +
|
||||||
colorCodes.enigmaToAnsi(text)
|
colorCodes.pipeToAnsi(text, self.client)
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue