acs work. potential wide char support.

This commit is contained in:
Christopher Jeffrey 2013-08-10 09:30:05 -05:00
parent 7f23ade08b
commit 2ba6dcc2b8

View File

@ -1061,7 +1061,8 @@ Screen.prototype.draw = function(start, end) {
// this seems to be the way ncurses does it. // this seems to be the way ncurses does it.
if (this.tput) { if (this.tput) {
if (this.tput.strings.enter_alt_charset_mode) { if (this.tput.strings.enter_alt_charset_mode) {
if (!this.tput.brokenACS || !this.tput.unicode) { //if (!this.tput.brokenACS || !this.tput.unicode) {
if (!this.tput.brokenACS) {
if (this.tput.acscr[ch]) { if (this.tput.acscr[ch]) {
if (acs) { if (acs) {
ch = this.tput.acscr[ch]; ch = this.tput.acscr[ch];
@ -1083,14 +1084,60 @@ Screen.prototype.draw = function(start, end) {
// are it does not support UTF8. This is probably // are it does not support UTF8. This is probably
// the "safest" way to do this. Should fix things // the "safest" way to do this. Should fix things
// like sun-color. // like sun-color.
// if (this.program.term('sun') && ch > '~') {
// if (this.tput.numbers.U8 !== 1 && ch > '~') { // if (this.tput.numbers.U8 !== 1 && ch > '~') {
// if ((!this.unicode || this.tput.numbers.U8 !== 1) && this.tput.utoa[ch]) {
if (this.tput.numbers.U8 !== 1 && this.tput.utoa[ch]) { if (this.tput.numbers.U8 !== 1 && this.tput.utoa[ch]) {
ch = this.tput.utoa[ch] || '?'; ch = this.tput.utoa[ch] || '?';
} }
} }
} }
// Attempt to use ACS for supported characters.
// This is not ideal, but it's how ncurses works.
// There are a lot of terminals that support ACS
// *and UTF8, but do not declare U8. So ACS ends
// up being used (slower than utf8). Terminals
// that do not support ACS and do not explicitly
// support UTF8 get their unicode characters
// replaced with really ugly ascii characters.
// It is possible there is a terminal out there
// somewhere that does not support ACS, but
// supports UTF8, but I imagine it's unlikely.
// Maybe remove !this.tput.unicode check, however,
// this seems to be the way ncurses does it.
if (0 && this.tput) {
if (this.tput.strings.enter_alt_charset_mode && !this.tput.brokenACS) {
if (this.tput.acscr[ch]) {
if (acs) {
ch = this.tput.acscr[ch];
} else {
ch = this.tput.smacs()
+ this.tput.acscr[ch];
acs = true;
}
} else if (acs) {
ch = this.tput.rmacs() + ch;
acs = false;
}
} else {
// U8 is not consistently correct. Some terminfo's
// terminals that do not declare it may actually
// support utf8 (e.g. urxvt), but if the terminal
// does not declare support for ACS (and U8), chances
// are it does not support UTF8. This is probably
// the "safest" way to do this. Should fix things
// like sun-color.
if ((!this.unicode
|| (!this.tput.strings.enter_alt_charset_mode
&& this.tput.numbers.U8 !== 1))
&& ch > '~') {
ch = this.tput.utoa[ch] || '?';
}
}
}
// if (wideChars.test(ch)) x++;
out += ch; out += ch;
attr = data; attr = data;
} }
@ -1978,7 +2025,7 @@ Element.prototype.parseContent = function(noTags) {
.replace(/\x1b(?!\[[\d;]*m)/g, '') .replace(/\x1b(?!\[[\d;]*m)/g, '')
.replace(/\r\n|\r/g, '\n') .replace(/\r\n|\r/g, '\n')
.replace(/\t/g, this.screen.tabc) .replace(/\t/g, this.screen.tabc)
.replace(dwidthChars, '?'); .replace(wideChars, '?');
if (!noTags) { if (!noTags) {
content = this._parseTags(content); content = this._parseTags(content);
@ -3089,6 +3136,12 @@ Element.prototype.render = function() {
lines[y][x][1] = ch; lines[y][x][1] = ch;
lines[y].dirty = true; lines[y].dirty = true;
} }
// if (wideChars.test(ch)) {
// x++;
// lines[y][x][0] = attr;
// lines[y][x][1] = ' ';
// }
} }
} }
@ -5811,7 +5864,7 @@ function hsort(obj) {
}); });
} }
var dwidthChars = new RegExp('([' var wideChars = new RegExp('(['
+ '\\uff01-\\uffbe' + '\\uff01-\\uffbe'
+ '\\uffc2-\\uffc7' + '\\uffc2-\\uffc7'
+ '\\uffca-\\uffcf' + '\\uffca-\\uffcf'