refactor attr.

This commit is contained in:
Christopher Jeffrey 2013-01-27 09:06:31 -06:00
parent b8739b581e
commit ea95d414fe
1 changed files with 71 additions and 139 deletions

View File

@ -554,173 +554,105 @@ Program.prototype.attr =
Program.prototype.charAttributes = function(param, val) {
switch (param) {
case 'normal':
this.write('\x1b[m');
break;
return this.write('\x1b[m');
case 'bold':
if (val === false) {
this.write('\x1b[22m');
} else {
this.write('\x1b[1m');
}
break;
return val === false
? this.write('\x1b[22m')
: this.write('\x1b[1m');
case 'underlined':
if (val === false) {
this.write('\x1b[24m');
} else {
this.write('\x1b[4m');
}
break;
return val === false
? this.write('\x1b[24m')
: this.write('\x1b[4m');
case 'blink':
if (val === false) {
this.write('\x1b[25m');
} else {
this.write('\x1b[5m');
}
break;
return val === false
? this.write('\x1b[25m')
: this.write('\x1b[5m');
case 'inverse':
if (val === false) {
this.write('\x1b[27m');
} else {
this.write('\x1b[7m');
}
return val === false
? this.write('\x1b[27m')
: this.write('\x1b[7m');
break;
case 'invisible':
if (val === false) {
this.write('\x1b[28m');
} else {
this.write('\x1b[8m');
}
break;
return val === false
? this.write('\x1b[28m')
: this.write('\x1b[8m');
case 'invisible':
if (val === false) {
this.write('\x1b[28m');
} else {
this.write('\x1b[8m');
}
break;
return val === false
? this.write('\x1b[28m')
: this.write('\x1b[8m');
case 'black fg':
if (val === false) {
this.write('\x1b[39m');
break;
}
this.write('\x1b[30m');
break;
return val === false
? this.write('\x1b[39m')
: this.write('\x1b[30m');
case 'red fg':
if (val === false) {
this.write('\x1b[39m');
break;
}
this.write('\x1b[31m');
break;
return val === false
? this.write('\x1b[39m')
: this.write('\x1b[31m');
case 'green fg':
if (val === false) {
this.write('\x1b[39m');
break;
}
this.write('\x1b[32m');
break;
return val === false
? this.write('\x1b[39m')
: this.write('\x1b[32m');
case 'yellow fg':
if (val === false) {
this.write('\x1b[39m');
break;
}
this.write('\x1b[33m');
break;
return val === false
? this.write('\x1b[39m')
: this.write('\x1b[33m');
case 'blue fg':
if (val === false) {
this.write('\x1b[39m');
break;
}
this.write('\x1b[34m');
break;
return val === false
? this.write('\x1b[39m')
: this.write('\x1b[34m');
case 'magenta fg':
if (val === false) {
this.write('\x1b[39m');
break;
}
this.write('\x1b[35m');
break;
return val === false
? this.write('\x1b[39m')
: this.write('\x1b[35m');
case 'cyan fg':
if (val === false) {
this.write('\x1b[39m');
break;
}
this.write('\x1b[36m');
break;
return val === false
? this.write('\x1b[39m')
: this.write('\x1b[36m');
case 'white fg':
if (val === false) {
this.write('\x1b[39m');
break;
}
this.write('\x1b[37m');
break;
return val === false
? this.write('\x1b[39m')
: this.write('\x1b[37m');
case 'default fg':
this.write('\x1b[39m');
break;
return this.write('\x1b[39m');
case 'black bg':
if (val === false) {
this.write('\x1b[49m');
break;
}
this.write('\x1b[40m');
break;
return val === false
? this.write('\x1b[49m')
: this.write('\x1b[40m');
case 'red bg':
if (val === false) {
this.write('\x1b[49m');
break;
}
this.write('\x1b[41m');
break;
return val === false
? this.write('\x1b[49m')
: this.write('\x1b[41m');
case 'green bg':
if (val === false) {
this.write('\x1b[49m');
break;
}
this.write('\x1b[42m');
break;
return val === false
? this.write('\x1b[49m')
: this.write('\x1b[42m');
case 'yellow bg':
if (val === false) {
this.write('\x1b[49m');
break;
}
this.write('\x1b[43m');
break;
return val === false
? this.write('\x1b[49m')
: this.write('\x1b[43m');
case 'blue bg':
if (val === false) {
this.write('\x1b[49m');
break;
}
this.write('\x1b[44m');
break;
return val === false
? this.write('\x1b[49m')
: this.write('\x1b[44m');
case 'magenta bg':
if (val === false) {
this.write('\x1b[49m');
break;
}
this.write('\x1b[45m');
break;
return val === false
? this.write('\x1b[49m')
: this.write('\x1b[45m');
case 'cyan bg':
if (val === false) {
this.write('\x1b[49m');
break;
}
this.write('\x1b[46m');
break;
return val === false
? this.write('\x1b[49m')
: this.write('\x1b[46m');
case 'white bg':
if (val === false) {
this.write('\x1b[49m');
break;
}
this.write('\x1b[47m');
break;
return val === false
? this.write('\x1b[49m')
: this.write('\x1b[47m');
case 'default bg':
this.write('\x1b[49m');
break;
return this.write('\x1b[49m');
default:
this.write('\x1b[' + param + 'm');
break;
return this.write('\x1b[' + param + 'm');
}
};