Remove Terminal.send
This commit is contained in:
+17
-17
@@ -40,7 +40,7 @@ class RequestTerminfo implements IDcsHandler {
|
|||||||
}
|
}
|
||||||
unhook(): void {
|
unhook(): void {
|
||||||
// invalid: DCS 0 + r Pt ST
|
// invalid: DCS 0 + r Pt ST
|
||||||
this._terminal.send(`${C0.ESC}P0+r${this._data}${C0.ESC}\\`);
|
this._terminal.handler(`${C0.ESC}P0+r${this._data}${C0.ESC}\\`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,25 +68,25 @@ class DECRQSS implements IDcsHandler {
|
|||||||
switch (this._data) {
|
switch (this._data) {
|
||||||
// valid: DCS 1 $ r Pt ST (xterm)
|
// valid: DCS 1 $ r Pt ST (xterm)
|
||||||
case '"q': // DECSCA
|
case '"q': // DECSCA
|
||||||
return this._terminal.send(`${C0.ESC}P1$r0"q${C0.ESC}\\`);
|
return this._terminal.handler(`${C0.ESC}P1$r0"q${C0.ESC}\\`);
|
||||||
case '"p': // DECSCL
|
case '"p': // DECSCL
|
||||||
return this._terminal.send(`${C0.ESC}P1$r61"p${C0.ESC}\\`);
|
return this._terminal.handler(`${C0.ESC}P1$r61"p${C0.ESC}\\`);
|
||||||
case 'r': // DECSTBM
|
case 'r': // DECSTBM
|
||||||
const pt = '' + (this._terminal.buffer.scrollTop + 1) +
|
const pt = '' + (this._terminal.buffer.scrollTop + 1) +
|
||||||
';' + (this._terminal.buffer.scrollBottom + 1) + 'r';
|
';' + (this._terminal.buffer.scrollBottom + 1) + 'r';
|
||||||
return this._terminal.send(`${C0.ESC}P1$r${pt}${C0.ESC}\\`);
|
return this._terminal.handler(`${C0.ESC}P1$r${pt}${C0.ESC}\\`);
|
||||||
case 'm': // SGR
|
case 'm': // SGR
|
||||||
// TODO: report real settings instead of 0m
|
// TODO: report real settings instead of 0m
|
||||||
return this._terminal.send(`${C0.ESC}P1$r0m${C0.ESC}\\`);
|
return this._terminal.handler(`${C0.ESC}P1$r0m${C0.ESC}\\`);
|
||||||
case ' q': // DECSCUSR
|
case ' q': // DECSCUSR
|
||||||
const STYLES: {[key: string]: number} = {'block': 2, 'underline': 4, 'bar': 6};
|
const STYLES: {[key: string]: number} = {'block': 2, 'underline': 4, 'bar': 6};
|
||||||
let style = STYLES[this._terminal.getOption('cursorStyle')];
|
let style = STYLES[this._terminal.getOption('cursorStyle')];
|
||||||
style -= this._terminal.getOption('cursorBlink');
|
style -= this._terminal.getOption('cursorBlink');
|
||||||
return this._terminal.send(`${C0.ESC}P1$r${style} q${C0.ESC}\\`);
|
return this._terminal.handler(`${C0.ESC}P1$r${style} q${C0.ESC}\\`);
|
||||||
default:
|
default:
|
||||||
// invalid: DCS 0 $ r Pt ST (xterm)
|
// invalid: DCS 0 $ r Pt ST (xterm)
|
||||||
this._terminal.error('Unknown DCS $q %s', this._data);
|
this._terminal.error('Unknown DCS $q %s', this._data);
|
||||||
this._terminal.send(`${C0.ESC}P0$r${this._data}${C0.ESC}\\`);
|
this._terminal.handler(`${C0.ESC}P0$r${this._data}${C0.ESC}\\`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1032,24 +1032,24 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
|
|
||||||
if (!collect) {
|
if (!collect) {
|
||||||
if (this._terminal.is('xterm') || this._terminal.is('rxvt-unicode') || this._terminal.is('screen')) {
|
if (this._terminal.is('xterm') || this._terminal.is('rxvt-unicode') || this._terminal.is('screen')) {
|
||||||
this._terminal.send(C0.ESC + '[?1;2c');
|
this._terminal.handler(C0.ESC + '[?1;2c');
|
||||||
} else if (this._terminal.is('linux')) {
|
} else if (this._terminal.is('linux')) {
|
||||||
this._terminal.send(C0.ESC + '[?6c');
|
this._terminal.handler(C0.ESC + '[?6c');
|
||||||
}
|
}
|
||||||
} else if (collect === '>') {
|
} else if (collect === '>') {
|
||||||
// xterm and urxvt
|
// xterm and urxvt
|
||||||
// seem to spit this
|
// seem to spit this
|
||||||
// out around ~370 times (?).
|
// out around ~370 times (?).
|
||||||
if (this._terminal.is('xterm')) {
|
if (this._terminal.is('xterm')) {
|
||||||
this._terminal.send(C0.ESC + '[>0;276;0c');
|
this._terminal.handler(C0.ESC + '[>0;276;0c');
|
||||||
} else if (this._terminal.is('rxvt-unicode')) {
|
} else if (this._terminal.is('rxvt-unicode')) {
|
||||||
this._terminal.send(C0.ESC + '[>85;95;0c');
|
this._terminal.handler(C0.ESC + '[>85;95;0c');
|
||||||
} else if (this._terminal.is('linux')) {
|
} else if (this._terminal.is('linux')) {
|
||||||
// not supported by linux console.
|
// not supported by linux console.
|
||||||
// linux console echoes parameters.
|
// linux console echoes parameters.
|
||||||
this._terminal.send(params[0] + 'c');
|
this._terminal.handler(params[0] + 'c');
|
||||||
} else if (this._terminal.is('screen')) {
|
} else if (this._terminal.is('screen')) {
|
||||||
this._terminal.send(C0.ESC + '[>83;40003;0c');
|
this._terminal.handler(C0.ESC + '[>83;40003;0c');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1733,19 +1733,19 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
// no printer
|
// no printer
|
||||||
// this.send(C0.ESC + '[?11n');
|
// this.handler(C0.ESC + '[?11n');
|
||||||
break;
|
break;
|
||||||
case 25:
|
case 25:
|
||||||
// dont support user defined keys
|
// dont support user defined keys
|
||||||
// this.send(C0.ESC + '[?21n');
|
// this.handler(C0.ESC + '[?21n');
|
||||||
break;
|
break;
|
||||||
case 26:
|
case 26:
|
||||||
// north american keyboard
|
// north american keyboard
|
||||||
// this.send(C0.ESC + '[?27;1;0;0n');
|
// this.handler(C0.ESC + '[?27;1;0;0n');
|
||||||
break;
|
break;
|
||||||
case 53:
|
case 53:
|
||||||
// no dec locator/mouse
|
// no dec locator/mouse
|
||||||
// this.send(C0.ESC + '[?50n');
|
// this.handler(C0.ESC + '[?50n');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-27
@@ -135,7 +135,6 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
public cursorHidden: boolean;
|
public cursorHidden: boolean;
|
||||||
public convertEol: boolean;
|
public convertEol: boolean;
|
||||||
|
|
||||||
private _sendDataQueue: string;
|
|
||||||
private _customKeyEventHandler: CustomKeyEventHandler;
|
private _customKeyEventHandler: CustomKeyEventHandler;
|
||||||
|
|
||||||
// modes
|
// modes
|
||||||
@@ -270,7 +269,6 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
|
|
||||||
this.cursorState = 0;
|
this.cursorState = 0;
|
||||||
this.cursorHidden = false;
|
this.cursorHidden = false;
|
||||||
this._sendDataQueue = '';
|
|
||||||
this._customKeyEventHandler = null;
|
this._customKeyEventHandler = null;
|
||||||
|
|
||||||
// modes
|
// modes
|
||||||
@@ -486,7 +484,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
*/
|
*/
|
||||||
private _onTextAreaFocus(): void {
|
private _onTextAreaFocus(): void {
|
||||||
if (this.sendFocus) {
|
if (this.sendFocus) {
|
||||||
this.send(C0.ESC + '[I');
|
this.handler(C0.ESC + '[I');
|
||||||
}
|
}
|
||||||
this.element.classList.add('focus');
|
this.element.classList.add('focus');
|
||||||
this.showCursor();
|
this.showCursor();
|
||||||
@@ -510,7 +508,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
this.textarea.value = '';
|
this.textarea.value = '';
|
||||||
this.refresh(this.buffer.y, this.buffer.y);
|
this.refresh(this.buffer.y, this.buffer.y);
|
||||||
if (this.sendFocus) {
|
if (this.sendFocus) {
|
||||||
this.send(C0.ESC + '[O');
|
this.handler(C0.ESC + '[O');
|
||||||
}
|
}
|
||||||
this.element.classList.remove('focus');
|
this.element.classList.remove('focus');
|
||||||
this.emit('blur');
|
this.emit('blur');
|
||||||
@@ -860,7 +858,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
else if (button === 3) return;
|
else if (button === 3) return;
|
||||||
else data += '0';
|
else data += '0';
|
||||||
data += '~[' + pos.x + ',' + pos.y + ']\r';
|
data += '~[' + pos.x + ',' + pos.y + ']\r';
|
||||||
self.send(data);
|
self.handler(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -873,7 +871,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
else if (button === 1) button = 4;
|
else if (button === 1) button = 4;
|
||||||
else if (button === 2) button = 6;
|
else if (button === 2) button = 6;
|
||||||
else if (button === 3) button = 3;
|
else if (button === 3) button = 3;
|
||||||
self.send(C0.ESC + '['
|
self.handler(C0.ESC + '['
|
||||||
+ button
|
+ button
|
||||||
+ ';'
|
+ ';'
|
||||||
+ (button === 3 ? 4 : 0)
|
+ (button === 3 ? 4 : 0)
|
||||||
@@ -893,14 +891,14 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
pos.y -= 32;
|
pos.y -= 32;
|
||||||
pos.x++;
|
pos.x++;
|
||||||
pos.y++;
|
pos.y++;
|
||||||
self.send(C0.ESC + '[' + button + ';' + pos.x + ';' + pos.y + 'M');
|
self.handler(C0.ESC + '[' + button + ';' + pos.x + ';' + pos.y + 'M');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.sgrMouse) {
|
if (self.sgrMouse) {
|
||||||
pos.x -= 32;
|
pos.x -= 32;
|
||||||
pos.y -= 32;
|
pos.y -= 32;
|
||||||
self.send(C0.ESC + '[<'
|
self.handler(C0.ESC + '[<'
|
||||||
+ (((button & 3) === 3 ? button & ~3 : button) - 32)
|
+ (((button & 3) === 3 ? button & ~3 : button) - 32)
|
||||||
+ ';'
|
+ ';'
|
||||||
+ pos.x
|
+ pos.x
|
||||||
@@ -916,7 +914,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
encode(data, pos.x);
|
encode(data, pos.x);
|
||||||
encode(data, pos.y);
|
encode(data, pos.y);
|
||||||
|
|
||||||
self.send(C0.ESC + '[M' + String.fromCharCode.apply(String, data));
|
self.handler(C0.ESC + '[M' + String.fromCharCode.apply(String, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getButton(ev: MouseEvent): number {
|
function getButton(ev: MouseEvent): number {
|
||||||
@@ -1065,7 +1063,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
for (let i = 0; i < Math.abs(amount); i++) {
|
for (let i = 0; i < Math.abs(amount); i++) {
|
||||||
data += sequence;
|
data += sequence;
|
||||||
}
|
}
|
||||||
this.send(data);
|
this.handler(data);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1279,7 +1277,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
if (this.options.useFlowControl && !this._xoffSentToCatchUp && this.writeBuffer.length >= WRITE_BUFFER_PAUSE_THRESHOLD) {
|
if (this.options.useFlowControl && !this._xoffSentToCatchUp && this.writeBuffer.length >= WRITE_BUFFER_PAUSE_THRESHOLD) {
|
||||||
// XOFF - stop pty pipe
|
// XOFF - stop pty pipe
|
||||||
// XON will be triggered by emulator before processing data chunk
|
// XON will be triggered by emulator before processing data chunk
|
||||||
this.send(C0.DC3);
|
this.handler(C0.DC3);
|
||||||
this._xoffSentToCatchUp = true;
|
this._xoffSentToCatchUp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1301,7 +1299,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
// If XOFF was sent in order to catch up with the pty process, resume it if
|
// If XOFF was sent in order to catch up with the pty process, resume it if
|
||||||
// the writeBuffer is empty to allow more data to come in.
|
// the writeBuffer is empty to allow more data to come in.
|
||||||
if (this._xoffSentToCatchUp && writeBatch.length === 0 && this.writeBuffer.length === 0) {
|
if (this._xoffSentToCatchUp && writeBatch.length === 0 && this.writeBuffer.length === 0) {
|
||||||
this.send(C0.DC1);
|
this.handler(C0.DC1);
|
||||||
this._xoffSentToCatchUp = false;
|
this._xoffSentToCatchUp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1576,21 +1574,6 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send data for handling to the terminal
|
|
||||||
* @param {string} data
|
|
||||||
*/
|
|
||||||
public send(data: string): void {
|
|
||||||
if (!this._sendDataQueue) {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.handler(this._sendDataQueue);
|
|
||||||
this._sendDataQueue = '';
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
this._sendDataQueue += data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ring the bell.
|
* Ring the bell.
|
||||||
* Note: We could do sweet things with webaudio here
|
* Note: We could do sweet things with webaudio here
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ export interface IInputHandlingTerminal extends IEventEmitter {
|
|||||||
eraseLeft(x: number, y: number): void;
|
eraseLeft(x: number, y: number): void;
|
||||||
blankLine(cur?: boolean, isWrapped?: boolean): LineData;
|
blankLine(cur?: boolean, isWrapped?: boolean): LineData;
|
||||||
is(term: string): boolean;
|
is(term: string): boolean;
|
||||||
send(data: string): void;
|
|
||||||
setgCharset(g: number, charset: ICharset): void;
|
setgCharset(g: number, charset: ICharset): void;
|
||||||
resize(x: number, y: number): void;
|
resize(x: number, y: number): void;
|
||||||
log(text: string, data?: any): void;
|
log(text: string, data?: any): void;
|
||||||
@@ -225,7 +224,6 @@ export interface ITerminal extends PublicTerminal, IElementAccessor, IBufferAcce
|
|||||||
* @param data The data to populate in the event.
|
* @param data The data to populate in the event.
|
||||||
*/
|
*/
|
||||||
handler(data: string): void;
|
handler(data: string): void;
|
||||||
send(data: string): void;
|
|
||||||
scrollLines(disp: number, suppressScrollEvent?: boolean): void;
|
scrollLines(disp: number, suppressScrollEvent?: boolean): void;
|
||||||
cancel(ev: Event, force?: boolean): boolean | void;
|
cancel(ev: Event, force?: boolean): boolean | void;
|
||||||
log(text: string): void;
|
log(text: string): void;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export class AltClickHandler {
|
|||||||
*/
|
*/
|
||||||
public move(): void {
|
public move(): void {
|
||||||
if (this._mouseEvent.altKey && this._endCol !== undefined && this._endRow !== undefined) {
|
if (this._mouseEvent.altKey && this._endCol !== undefined && this._endRow !== undefined) {
|
||||||
this._terminal.send(this._arrowSequences());
|
this._terminal.handler(this._arrowSequences());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,9 +84,6 @@ export class MockTerminal implements ITerminal {
|
|||||||
write(data: string): void {
|
write(data: string): void {
|
||||||
throw new Error('Method not implemented.');
|
throw new Error('Method not implemented.');
|
||||||
}
|
}
|
||||||
send(data: string): void {
|
|
||||||
throw new Error('Method not implemented.');
|
|
||||||
}
|
|
||||||
bracketedPasteMode: boolean;
|
bracketedPasteMode: boolean;
|
||||||
mouseHelper: IMouseHelper;
|
mouseHelper: IMouseHelper;
|
||||||
renderer: IRenderer;
|
renderer: IRenderer;
|
||||||
@@ -240,9 +237,6 @@ export class MockInputHandlingTerminal implements IInputHandlingTerminal {
|
|||||||
is(term: string): boolean {
|
is(term: string): boolean {
|
||||||
throw new Error('Method not implemented.');
|
throw new Error('Method not implemented.');
|
||||||
}
|
}
|
||||||
send(data: string): void {
|
|
||||||
throw new Error('Method not implemented.');
|
|
||||||
}
|
|
||||||
setgCharset(g: number, charset: { [key: string]: string; }): void {
|
setgCharset(g: number, charset: { [key: string]: string; }): void {
|
||||||
throw new Error('Method not implemented.');
|
throw new Error('Method not implemented.');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user