+22
-12
@@ -63,28 +63,33 @@ export const wcwidth = (function(opts: {nul: number, control: number}): (ucs: nu
|
|||||||
let min = 0;
|
let min = 0;
|
||||||
let max = data.length - 1;
|
let max = data.length - 1;
|
||||||
let mid;
|
let mid;
|
||||||
if (ucs < data[0][0] || ucs > data[max][1])
|
if (ucs < data[0][0] || ucs > data[max][1]) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
while (max >= min) {
|
while (max >= min) {
|
||||||
mid = (min + max) >> 1;
|
mid = (min + max) >> 1;
|
||||||
if (ucs > data[mid][1])
|
if (ucs > data[mid][1]) {
|
||||||
min = mid + 1;
|
min = mid + 1;
|
||||||
else if (ucs < data[mid][0])
|
} else if (ucs < data[mid][0]) {
|
||||||
max = mid - 1;
|
max = mid - 1;
|
||||||
else
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function wcwidthBMP(ucs: number): number {
|
function wcwidthBMP(ucs: number): number {
|
||||||
// test for 8-bit control characters
|
// test for 8-bit control characters
|
||||||
if (ucs === 0)
|
if (ucs === 0) {
|
||||||
return opts.nul;
|
return opts.nul;
|
||||||
if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))
|
}
|
||||||
|
if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) {
|
||||||
return opts.control;
|
return opts.control;
|
||||||
|
}
|
||||||
// binary search in table of non-spacing characters
|
// binary search in table of non-spacing characters
|
||||||
if (bisearch(ucs, COMBINING_BMP))
|
if (bisearch(ucs, COMBINING_BMP)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
// if we arrive here, ucs is not a combining or C0/C1 control character
|
// if we arrive here, ucs is not a combining or C0/C1 control character
|
||||||
if (isWideBMP(ucs)) {
|
if (isWideBMP(ucs)) {
|
||||||
return 2;
|
return 2;
|
||||||
@@ -106,8 +111,9 @@ export const wcwidth = (function(opts: {nul: number, control: number}): (ucs: nu
|
|||||||
(ucs >= 0xffe0 && ucs <= 0xffe6)));
|
(ucs >= 0xffe0 && ucs <= 0xffe6)));
|
||||||
}
|
}
|
||||||
function wcwidthHigh(ucs: number): 0 | 1 | 2 {
|
function wcwidthHigh(ucs: number): 0 | 1 | 2 {
|
||||||
if (bisearch(ucs, COMBINING_HIGH))
|
if (bisearch(ucs, COMBINING_HIGH)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {
|
if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
@@ -128,8 +134,9 @@ export const wcwidth = (function(opts: {nul: number, control: number}): (ucs: nu
|
|||||||
for (let i = 0; i < CONTAINERSIZE; ++i) {
|
for (let i = 0; i < CONTAINERSIZE; ++i) {
|
||||||
let num = 0;
|
let num = 0;
|
||||||
let pos = CODEPOINTS_PER_ITEM;
|
let pos = CODEPOINTS_PER_ITEM;
|
||||||
while (pos--)
|
while (pos--) {
|
||||||
num = (num << 2) | wcwidthBMP(CODEPOINTS_PER_ITEM * i + pos);
|
num = (num << 2) | wcwidthBMP(CODEPOINTS_PER_ITEM * i + pos);
|
||||||
|
}
|
||||||
table[i] = num;
|
table[i] = num;
|
||||||
}
|
}
|
||||||
return table;
|
return table;
|
||||||
@@ -148,13 +155,16 @@ export const wcwidth = (function(opts: {nul: number, control: number}): (ucs: nu
|
|||||||
// ==> n = n & 3 e.g. 000000000000000000000000000000XX
|
// ==> n = n & 3 e.g. 000000000000000000000000000000XX
|
||||||
return function (num: number): number {
|
return function (num: number): number {
|
||||||
num = num | 0; // get asm.js like optimization under V8
|
num = num | 0; // get asm.js like optimization under V8
|
||||||
if (num < 32)
|
if (num < 32) {
|
||||||
return control | 0;
|
return control | 0;
|
||||||
if (num < 127)
|
}
|
||||||
|
if (num < 127) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
let t = table || init_table();
|
let t = table || init_table();
|
||||||
if (num < 65536)
|
if (num < 65536) {
|
||||||
return t[num >> 4] >> ((num & 15) << 1) & 3;
|
return t[num >> 4] >> ((num & 15) << 1) & 3;
|
||||||
|
}
|
||||||
// do a full search for high codepoints
|
// do a full search for high codepoints
|
||||||
return wcwidthHigh(num);
|
return wcwidthHigh(num);
|
||||||
};
|
};
|
||||||
|
|||||||
+2
-1
@@ -69,8 +69,9 @@ export class InputHandler implements IInputHandler {
|
|||||||
(<any>this._terminal.buffer.lines.get(this._terminal.buffer.y)).isWrapped = true;
|
(<any>this._terminal.buffer.lines.get(this._terminal.buffer.y)).isWrapped = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (chWidth === 2) // FIXME: check for xterm behavior
|
if (chWidth === 2) { // FIXME: check for xterm behavior
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
row = this._terminal.buffer.y + this._terminal.buffer.ybase;
|
row = this._terminal.buffer.y + this._terminal.buffer.ybase;
|
||||||
|
|||||||
+2
-1
@@ -224,8 +224,9 @@ export class Parser {
|
|||||||
ch += data.charAt(this._position + 1);
|
ch += data.charAt(this._position + 1);
|
||||||
}
|
}
|
||||||
// surrogate low - already handled above
|
// surrogate low - already handled above
|
||||||
if (0xDC00 <= code && code <= 0xDFFF)
|
if (0xDC00 <= code && code <= 0xDFFF) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (this._state) {
|
switch (this._state) {
|
||||||
case ParserState.NORMAL:
|
case ParserState.NORMAL:
|
||||||
|
|||||||
@@ -538,8 +538,9 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
|
|||||||
private _onMouseUp(event: MouseEvent): void {
|
private _onMouseUp(event: MouseEvent): void {
|
||||||
this._removeMouseDownListeners();
|
this._removeMouseDownListeners();
|
||||||
|
|
||||||
if (this.hasSelection)
|
if (this.hasSelection) {
|
||||||
this._terminal.emit('selection');
|
this._terminal.emit('selection');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onBufferActivate(e: {activeBuffer: IBuffer, inactiveBuffer: IBuffer}): void {
|
private _onBufferActivate(e: {activeBuffer: IBuffer, inactiveBuffer: IBuffer}): void {
|
||||||
|
|||||||
+8
-6
@@ -1580,21 +1580,23 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
|||||||
break;
|
break;
|
||||||
case 36:
|
case 36:
|
||||||
// home
|
// home
|
||||||
if (modifiers)
|
if (modifiers) {
|
||||||
result.key = C0.ESC + '[1;' + (modifiers + 1) + 'H';
|
result.key = C0.ESC + '[1;' + (modifiers + 1) + 'H';
|
||||||
else if (this.applicationCursor)
|
} else if (this.applicationCursor) {
|
||||||
result.key = C0.ESC + 'OH';
|
result.key = C0.ESC + 'OH';
|
||||||
else
|
} else {
|
||||||
result.key = C0.ESC + '[H';
|
result.key = C0.ESC + '[H';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 35:
|
case 35:
|
||||||
// end
|
// end
|
||||||
if (modifiers)
|
if (modifiers) {
|
||||||
result.key = C0.ESC + '[1;' + (modifiers + 1) + 'F';
|
result.key = C0.ESC + '[1;' + (modifiers + 1) + 'F';
|
||||||
else if (this.applicationCursor)
|
} else if (this.applicationCursor) {
|
||||||
result.key = C0.ESC + 'OF';
|
result.key = C0.ESC + 'OF';
|
||||||
else
|
} else {
|
||||||
result.key = C0.ESC + '[F';
|
result.key = C0.ESC + '[F';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 33:
|
case 33:
|
||||||
// page up
|
// page up
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
true,
|
true,
|
||||||
"check-space"
|
"check-space"
|
||||||
],
|
],
|
||||||
|
"curly": [
|
||||||
|
true,
|
||||||
|
"ignore-same-line"
|
||||||
|
],
|
||||||
"indent": [
|
"indent": [
|
||||||
true,
|
true,
|
||||||
"spaces"
|
"spaces"
|
||||||
|
|||||||
Reference in New Issue
Block a user