xterm-addon-unicode-graphemes - fix 'yarn test'
This commit is contained in:
@@ -26,6 +26,8 @@
|
|||||||
"addons/xterm-addon-serialize/benchmark/tsconfig.json",
|
"addons/xterm-addon-serialize/benchmark/tsconfig.json",
|
||||||
"addons/xterm-addon-unicode11/src/tsconfig.json",
|
"addons/xterm-addon-unicode11/src/tsconfig.json",
|
||||||
"addons/xterm-addon-unicode11/test/tsconfig.json",
|
"addons/xterm-addon-unicode11/test/tsconfig.json",
|
||||||
|
"addons/xterm-addon-unicode-graphemes/src/tsconfig.json",
|
||||||
|
"addons/xterm-addon-unicode-graphemes/test/tsconfig.json",
|
||||||
"addons/xterm-addon-web-links/src/tsconfig.json",
|
"addons/xterm-addon-web-links/src/tsconfig.json",
|
||||||
"addons/xterm-addon-web-links/test/tsconfig.json",
|
"addons/xterm-addon-web-links/test/tsconfig.json",
|
||||||
"addons/xterm-addon-webgl/src/tsconfig.json",
|
"addons/xterm-addon-webgl/src/tsconfig.json",
|
||||||
@@ -34,6 +36,9 @@
|
|||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"ignorePatterns": [
|
"ignorePatterns": [
|
||||||
|
"addons/xterm-addon-unicode-graphemes/src/tiny-inflate.ts",
|
||||||
|
"addons/xterm-addon-unicode-graphemes/src/unicode-trie.ts",
|
||||||
|
"addons/xterm-addon-unicode-graphemes/src/UnicodeProperties.ts",
|
||||||
"**/typings/*.d.ts",
|
"**/typings/*.d.ts",
|
||||||
"**/node_modules",
|
"**/node_modules",
|
||||||
"**/*.js"
|
"**/*.js"
|
||||||
|
|||||||
@@ -14,39 +14,36 @@ export class UnicodeGraphemeProvider implements IUnicodeVersionProvider {
|
|||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
charProperties(codepoint: number, preceding: UnicodeCharProperties): UnicodeCharProperties {
|
public charProperties(codepoint: number, preceding: UnicodeCharProperties): UnicodeCharProperties {
|
||||||
let charInfo = UC.getInfo(codepoint);
|
let charInfo = UC.getInfo(codepoint);
|
||||||
let w = UC.infoToWidthInfo(charInfo);
|
let w = UC.infoToWidthInfo(charInfo);
|
||||||
let shouldJoin = false;
|
let shouldJoin = false;
|
||||||
if (w >= 2) {
|
if (w >= 2) {
|
||||||
// Treat emoji_presentation_selector as WIDE.
|
// Treat emoji_presentation_selector as WIDE.
|
||||||
w = w == 3 || this.ambiguousCharsAreWide || codepoint === 0xfe0f ? 2 : 1;
|
w = w === 3 || this.ambiguousCharsAreWide || codepoint === 0xfe0f ? 2 : 1;
|
||||||
} else
|
} else {
|
||||||
w = 1;
|
w = 1;
|
||||||
|
}
|
||||||
if (preceding !== 0) {
|
if (preceding !== 0) {
|
||||||
let oldWidth = UnicodeService.extractWidth(preceding);
|
const oldWidth = UnicodeService.extractWidth(preceding);
|
||||||
charInfo = UC.shouldJoin(UnicodeService.extractCharKind(preceding), charInfo);
|
charInfo = UC.shouldJoin(UnicodeService.extractCharKind(preceding), charInfo);
|
||||||
shouldJoin = charInfo > 0;
|
shouldJoin = charInfo > 0;
|
||||||
if (shouldJoin) {
|
if (shouldJoin) {
|
||||||
if (oldWidth > w)
|
if (oldWidth > w) {
|
||||||
w = oldWidth;
|
w = oldWidth;
|
||||||
else if (charInfo === 32) // FIXME UC.GRAPHEME_BREAK_SAW_Regional_Pair)
|
} else if (charInfo === 32) { // UC.GRAPHEME_BREAK_SAW_Regional_Pair)
|
||||||
w = 2;
|
w = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return UnicodeService.createPropertyValue(charInfo, w, shouldJoin);
|
return UnicodeService.createPropertyValue(charInfo, w, shouldJoin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public wcwidth(codepoint: number): UnicodeCharWidth {
|
public wcwidth(codepoint: number): UnicodeCharWidth {
|
||||||
let charInfo = UC.getInfo(codepoint);
|
const charInfo = UC.getInfo(codepoint);
|
||||||
let w = UC.infoToWidthInfo(charInfo);
|
const w = UC.infoToWidthInfo(charInfo);
|
||||||
let kind = (charInfo & UC.GRAPHEME_BREAK_MASK) >> UC.GRAPHEME_BREAK_SHIFT;
|
const kind = (charInfo & UC.GRAPHEME_BREAK_MASK) >> UC.GRAPHEME_BREAK_SHIFT;
|
||||||
if (kind === UC.GRAPHEME_BREAK_Extend
|
return (kind === UC.GRAPHEME_BREAK_Extend || kind === UC.GRAPHEME_BREAK_Prepend) ? 0
|
||||||
|| kind === UC.GRAPHEME_BREAK_Prepend)
|
: (w >= 2 && (w === 3 || this.ambiguousCharsAreWide)) ? 2 : 1;
|
||||||
return 0;
|
|
||||||
else if (w >= 2)
|
|
||||||
return w == 3 || this.ambiguousCharsAreWide? 2 : 1;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -517,6 +517,8 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
bufferRow.setCellFromCodePoint(this._activeBuffer.x - 1, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended);
|
bufferRow.setCellFromCodePoint(this._activeBuffer.x - 1, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let precedingInfo = this._parser.precedingCodepoint === 0 ? 0
|
||||||
|
: this._parser.precedingJoinState;
|
||||||
for (let pos = start; pos < end; ++pos) {
|
for (let pos = start; pos < end; ++pos) {
|
||||||
code = data[pos];
|
code = data[pos];
|
||||||
|
|
||||||
@@ -530,14 +532,11 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const precedingInfo = this._parser.precedingCodepoint === 0 ? 0
|
|
||||||
: this._parser.precedingJoinState;
|
|
||||||
const currentInfo = this._unicodeService.charProperties(code, precedingInfo);
|
const currentInfo = this._unicodeService.charProperties(code, precedingInfo);
|
||||||
chWidth = UnicodeService.extractWidth(currentInfo);
|
chWidth = UnicodeService.extractWidth(currentInfo);
|
||||||
const shouldJoin = UnicodeService.extractShouldJoin(currentInfo);
|
const shouldJoin = UnicodeService.extractShouldJoin(currentInfo);
|
||||||
const oldWidth = shouldJoin ? UnicodeService.extractWidth(precedingInfo) : 0;
|
const oldWidth = shouldJoin ? UnicodeService.extractWidth(precedingInfo) : 0;
|
||||||
this._parser.precedingCodepoint = code;
|
precedingInfo = currentInfo;
|
||||||
this._parser.precedingJoinState = currentInfo;
|
|
||||||
|
|
||||||
if (screenReaderMode) {
|
if (screenReaderMode) {
|
||||||
this._onA11yChar.fire(stringFromCodePoint(code));
|
this._onA11yChar.fire(stringFromCodePoint(code));
|
||||||
@@ -631,6 +630,19 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._parser.precedingJoinState = precedingInfo;
|
||||||
|
// store last char in Parser.precedingCodepoint for REP to work correctly
|
||||||
|
// This needs to check whether:
|
||||||
|
// - combining: only base char gets carried on (bug in xterm?)
|
||||||
|
if (end - start > 0) {
|
||||||
|
bufferRow.loadCell(this._activeBuffer.x - 1, this._workCell);
|
||||||
|
if (this._workCell.isCombined()) {
|
||||||
|
this._parser.precedingCodepoint = this._workCell.getChars().charCodeAt(0);
|
||||||
|
} else {
|
||||||
|
this._parser.precedingCodepoint = this._workCell.content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// handle wide chars: reset cell to the right if it is second cell of a wide char
|
// handle wide chars: reset cell to the right if it is second cell of a wide char
|
||||||
if (this._activeBuffer.x < cols && end - start > 0 && bufferRow.getWidth(this._activeBuffer.x) === 0 && !bufferRow.hasContent(this._activeBuffer.x)) {
|
if (this._activeBuffer.x < cols && end - start > 0 && bufferRow.getWidth(this._activeBuffer.x) === 0 && !bufferRow.hasContent(this._activeBuffer.x)) {
|
||||||
bufferRow.setCellFromCodePoint(this._activeBuffer.x, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended);
|
bufferRow.setCellFromCodePoint(this._activeBuffer.x, 0, 1, curAttr.fg, curAttr.bg, curAttr.extended);
|
||||||
|
|||||||
Reference in New Issue
Block a user