mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-02-23 08:08:16 +00:00
add doubleWidthPerfect option.
This commit is contained in:
parent
3f73e08dd7
commit
1b1775a4c2
@ -266,6 +266,9 @@ The screen on which every other node renders.
|
|||||||
overlapping, depending on position (__experimental__). for example:
|
overlapping, depending on position (__experimental__). for example:
|
||||||
- __doubleWidth__ - allow for rendering of East Asian double-width characters.
|
- __doubleWidth__ - allow for rendering of East Asian double-width characters.
|
||||||
this is behind an option because it may affect performance negatively.
|
this is behind an option because it may affect performance negatively.
|
||||||
|
- __doubleWidthPerfect__ - handle high code point double-width characters,
|
||||||
|
without this option, high code point double width characters just show up as
|
||||||
|
`?`. that being said, this option will slow content parsing a fair amount.
|
||||||
|
|
||||||
These border-overlapped elements:
|
These border-overlapped elements:
|
||||||
|
|
||||||
|
@ -2335,6 +2335,29 @@ Element.prototype.parseContent = function(noTags) {
|
|||||||
content = content.replace(wideChars, '?');
|
content = content.replace(wideChars, '?');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.screen.options.doubleWidthPerfect) {
|
||||||
|
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.options.doubleWidth
|
||||||
|
&& (this.screen.tput.unicode
|
||||||
|
|| this.screen.tput.numbers.U8 === 1)) {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
@ -8591,7 +8614,14 @@ function hsort(obj) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var wideChars = new RegExp('(['
|
var wideChars = new RegExp('('
|
||||||
|
// 0x20000 - 0x2fffd:
|
||||||
|
// + '[\\ud840-\\ud87f][\\udc00-\\udffd]'
|
||||||
|
// + '|'
|
||||||
|
// 0x30000 - 0x3fffd:
|
||||||
|
// + '[\\ud880-\\ud8bf][\\udc00-\\udffd]'
|
||||||
|
// + '|'
|
||||||
|
+ '['
|
||||||
+ '\\u1100-\\u115f' /* Hangul Jamo init. consonants */
|
+ '\\u1100-\\u115f' /* Hangul Jamo init. consonants */
|
||||||
+ '\\u2329\\u232a'
|
+ '\\u2329\\u232a'
|
||||||
+ '\\u2e80-\\u303e\\u3040-\\ua4cf' /* CJK ... Yi */
|
+ '\\u2e80-\\u303e\\u3040-\\ua4cf' /* CJK ... Yi */
|
||||||
@ -8606,7 +8636,8 @@ var wideChars = new RegExp('(['
|
|||||||
// however, the next char on the screen will be eaten.
|
// however, the next char on the screen will be eaten.
|
||||||
// + '\\u20000-\\u2fffd'
|
// + '\\u20000-\\u2fffd'
|
||||||
// + '\\u30000-\\u3fffd'
|
// + '\\u30000-\\u3fffd'
|
||||||
+ '])', 'g');
|
+ ']'
|
||||||
|
+ ')', 'g');
|
||||||
|
|
||||||
function findFile(start, target) {
|
function findFile(start, target) {
|
||||||
return (function read(dir) {
|
return (function read(dir) {
|
||||||
|
@ -5,10 +5,12 @@ screen = blessed.screen({
|
|||||||
dump: __dirname + '/logs/eaw.log',
|
dump: __dirname + '/logs/eaw.log',
|
||||||
smartCSR: true,
|
smartCSR: true,
|
||||||
dockBorders: true,
|
dockBorders: true,
|
||||||
doubleWidth: true
|
doubleWidth: true,
|
||||||
|
doubleWidthPerfect: true
|
||||||
});
|
});
|
||||||
|
|
||||||
var DW = '杜';
|
var DW = '杜';
|
||||||
|
var DW2 = String.fromCodePoint ? String.fromCodePoint(0x30000) : 'a';
|
||||||
|
|
||||||
// At cols=44, the bug that is avoided by this occurs:
|
// At cols=44, the bug that is avoided by this occurs:
|
||||||
// || angles[line[x + 1][1]]) {
|
// || angles[line[x + 1][1]]) {
|
||||||
@ -59,6 +61,7 @@ var lorem = 'Non eram nescius Brute cum quae summis ingeniis exquisitaque'
|
|||||||
+ ' legantur';
|
+ ' legantur';
|
||||||
|
|
||||||
lorem = lorem.replace(/e/gi, DW);
|
lorem = lorem.replace(/e/gi, DW);
|
||||||
|
lorem = lorem.replace(/a/gi, DW2);
|
||||||
|
|
||||||
var main = blessed.box({
|
var main = blessed.box({
|
||||||
parent: screen,
|
parent: screen,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user