clean up old surrogates code.

This commit is contained in:
Christopher Jeffrey 2015-04-15 10:08:18 -07:00
parent ea4e142757
commit 85be64273f
2 changed files with 5 additions and 45 deletions

View File

@ -1204,12 +1204,11 @@ Screen.prototype.draw = function(start, end) {
// If this is a surrogate pair double-width char, we can ignore it // If this is a surrogate pair double-width char, we can ignore it
// because parseContent already counted it as length=2. // because parseContent already counted it as length=2.
point = line[x][1].codePointAt(0); point = line[x][1].codePointAt(0);
// if (line[x][1].length === 1) {
if (point <= 0xffff) { if (point <= 0xffff) {
cwid = east_asian_width.char_width(point); cwid = east_asian_width.char_width(point);
if (cwid === 2) { if (cwid === 2) {
// Might also need: // Might also need: `line[x + 1][0] !== line[x][0]`
// `|| line[x + 1][0] !== line[x][0]` for borderless boxes? // for borderless boxes?
if (x === line.length - 1 || angles[line[x + 1][1]]) { if (x === line.length - 1 || angles[line[x + 1][1]]) {
ch = ' '; ch = ' ';
o[x][1] = ' '; o[x][1] = ' ';
@ -1222,20 +1221,6 @@ Screen.prototype.draw = function(start, end) {
} }
} }
// Find surrogate pairs that have been split:
// Pad after each character instead of end of line.
// XXX Doesn't work well.
// if (this.fullUnicode) {
// var code = line[x][1].charCodeAt(0);
// if (code >= 0xd800 && code <= 0xdbff) {
// var code2 = line[x + 1][1].charCodeAt(0);
// if (code2 >= 0xdc00 && code2 <= 0xdfff) {
// ch = line[x][1] + line[x + 1][1];
// line[x + 1][1] = ' ';
// }
// }
// }
// Attempt to use ACS for supported characters. // Attempt to use ACS for supported characters.
// This is not ideal, but it's how ncurses works. // This is not ideal, but it's how ncurses works.
// There are a lot of terminals that support ACS // There are a lot of terminals that support ACS
@ -1249,9 +1234,8 @@ Screen.prototype.draw = function(start, end) {
// supports UTF8, but I imagine it's unlikely. // supports UTF8, but I imagine it's unlikely.
// Maybe remove !this.tput.unicode check, however, // Maybe remove !this.tput.unicode check, however,
// this seems to be the way ncurses does it. // this seems to be the way ncurses does it.
if (this.tput.strings.enter_alt_charset_mode && !this.tput.brokenACS if (this.tput.strings.enter_alt_charset_mode
// Necessary for handling unicode when not supported: && !this.tput.brokenACS && (this.tput.acscr[ch] || acs)) {
&& (this.tput.acscr[ch] || acs)) {
// Fun fact: even if this.tput.brokenACS wasn't checked here, // Fun fact: even if this.tput.brokenACS wasn't checked here,
// the linux console would still work fine because the acs // the linux console would still work fine because the acs
// table would fail the check of: this.tput.acscr[ch] // table would fail the check of: this.tput.acscr[ch]
@ -2354,30 +2338,6 @@ Element.prototype.parseContent = function(noTags) {
content = content.replace(/[\ud800-\udbff][\udc00-\udfff]/g, '?'); content = content.replace(/[\ud800-\udbff][\udc00-\udfff]/g, '?');
} }
// XXX Because 0x20000 - 0x2fffd and 0x30000 - 0x3fffd are surrogate pairs,
// the length is computed as `2` in javascript, which coincidentally helps
// since they are double width. This may not be necessary.
// if (this.screen.options.fullUnicode) {
// var _content = content;
// content = '';
// for (var i = 0; i < _content.length; i++) {
// var point = _content.codePointAt(i);
// if ((point >= 0x20000 && point <= 0x2fffd)
// || (point >= 0x30000 && point <= 0x3fffd)) {
// if (this.screen._unicode) {
// content += _content[i] + ' ';
// } else {
// // NOTE: could use two chars: '? ' depending on what is intended.
// // if we did, we could remove the unicode checks above in this if
// // statement.
// content += '?';
// }
// } else {
// content += _content[i];
// }
// }
// }
if (!noTags) { if (!noTags) {
content = this._parseTags(content); content = this._parseTags(content);
} }

View File

@ -5,7 +5,7 @@ screen = blessed.screen({
dump: __dirname + '/logs/eaw.log', dump: __dirname + '/logs/eaw.log',
smartCSR: true, smartCSR: true,
dockBorders: true, dockBorders: true,
fullUnicode: true fullUnicode: process.argv[2] === '-' ? false : true
}); });
// screen.options.fullUnicode = false; // screen.options.fullUnicode = false;