Merge branch 'master' into layering4
This commit is contained in:
+32
-11
@@ -94,6 +94,7 @@ describe('Terminal', () => {
|
||||
expect(e.domEvent).to.be.an.instanceof(Object);
|
||||
done();
|
||||
});
|
||||
(<any>term).textarea = { value: '' };
|
||||
const evKeyDown = <KeyboardEvent>{
|
||||
preventDefault: () => { },
|
||||
stopPropagation: () => { },
|
||||
@@ -555,12 +556,16 @@ describe('Terminal', () => {
|
||||
afterEach(() => term.browser.isMac = originalIsMac);
|
||||
|
||||
it('should interfere with the alt key on keyDown', () => {
|
||||
(<any>term)._keyDownHandled = false;
|
||||
evKeyDown.altKey = true;
|
||||
evKeyDown.keyCode = 81;
|
||||
assert.equal(term.keyDown(evKeyDown), false);
|
||||
term.keyDown(evKeyDown);
|
||||
assert.equal((<any>term)._keyDownHandled, true);
|
||||
(<any>term)._keyDownHandled = false;
|
||||
evKeyDown.altKey = true;
|
||||
evKeyDown.keyCode = 192;
|
||||
assert.equal(term.keyDown(evKeyDown), false);
|
||||
term.keyDown(evKeyDown);
|
||||
assert.equal((<any>term)._keyDownHandled, true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -573,21 +578,29 @@ describe('Terminal', () => {
|
||||
afterEach(() => term.browser.isMac = originalIsMac);
|
||||
|
||||
it('should not interfere with the alt key on keyDown', () => {
|
||||
(<any>term)._keyDownHandled = false;
|
||||
evKeyDown.altKey = true;
|
||||
evKeyDown.keyCode = 81;
|
||||
assert.equal(term.keyDown(evKeyDown), true);
|
||||
term.keyDown(evKeyDown);
|
||||
assert.equal((<any>term)._keyDownHandled, false);
|
||||
(<any>term)._keyDownHandled = false;
|
||||
evKeyDown.altKey = true;
|
||||
evKeyDown.keyCode = 192;
|
||||
assert.equal(term.keyDown(evKeyDown), true);
|
||||
term.keyDown(evKeyDown);
|
||||
assert.equal((<any>term)._keyDownHandled, false);
|
||||
});
|
||||
|
||||
it('should interefere with the alt + arrow keys', () => {
|
||||
it('should interfere with the alt + arrow keys', () => {
|
||||
(<any>term)._keyDownHandled = false;
|
||||
evKeyDown.altKey = true;
|
||||
evKeyDown.keyCode = 37;
|
||||
assert.equal(term.keyDown(evKeyDown), false);
|
||||
term.keyDown(evKeyDown);
|
||||
assert.equal((<any>term)._keyDownHandled, true);
|
||||
(<any>term)._keyDownHandled = false;
|
||||
evKeyDown.altKey = true;
|
||||
evKeyDown.keyCode = 39;
|
||||
assert.equal(term.keyDown(evKeyDown), false);
|
||||
term.keyDown(evKeyDown);
|
||||
assert.equal((<any>term)._keyDownHandled, true);
|
||||
});
|
||||
|
||||
it('should emit key with alt + key on keyPress', (done) => {
|
||||
@@ -639,24 +652,32 @@ describe('Terminal', () => {
|
||||
afterEach(() => term.browser.isWindows = originalIsWindows);
|
||||
|
||||
it('should not interfere with the alt + ctrl key on keyDown', () => {
|
||||
(<any>term)._keyDownHandled = false;
|
||||
evKeyPress.altKey = true;
|
||||
evKeyPress.ctrlKey = true;
|
||||
evKeyPress.keyCode = 81;
|
||||
assert.equal(term.keyDown(evKeyPress), true);
|
||||
term.keyDown(evKeyPress);
|
||||
assert.equal((<any>term)._keyDownHandled, false);
|
||||
(<any>term)._keyDownHandled = false;
|
||||
evKeyDown.altKey = true;
|
||||
evKeyDown.ctrlKey = true;
|
||||
evKeyDown.keyCode = 81;
|
||||
assert.equal(term.keyDown(evKeyDown), true);
|
||||
term.keyDown(evKeyDown);
|
||||
assert.equal((<any>term)._keyDownHandled, false);
|
||||
});
|
||||
|
||||
it('should interefere with the alt + ctrl + arrow keys', () => {
|
||||
evKeyDown.altKey = true;
|
||||
evKeyDown.ctrlKey = true;
|
||||
|
||||
(<any>term)._keyDownHandled = false;
|
||||
evKeyDown.keyCode = 37;
|
||||
assert.equal(term.keyDown(evKeyDown), false);
|
||||
term.keyDown(evKeyDown);
|
||||
assert.equal((<any>term)._keyDownHandled, true);
|
||||
(<any>term)._keyDownHandled = false;
|
||||
evKeyDown.keyCode = 39;
|
||||
assert.equal(term.keyDown(evKeyDown), false);
|
||||
term.keyDown(evKeyDown);
|
||||
assert.equal((<any>term)._keyDownHandled, true);
|
||||
});
|
||||
|
||||
it('should emit key with alt + ctrl + key on keyPress', (done) => {
|
||||
|
||||
+23
-10
@@ -178,6 +178,13 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
// Store if user went browsing history in scrollback
|
||||
private _userScrolling: boolean;
|
||||
|
||||
/**
|
||||
* Records whether the keydown event has already been handled and triggered a data event, if so
|
||||
* the keypress event should not trigger a data event but should still print to the textarea so
|
||||
* screen readers will announce it.
|
||||
*/
|
||||
private _keyDownHandled: boolean = false;
|
||||
|
||||
private _inputHandler: InputHandler;
|
||||
public linkifier: ILinkifier;
|
||||
public viewport: IViewport;
|
||||
@@ -245,13 +252,13 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
this._instantiationService.setService(IOptionsService, this.optionsService);
|
||||
this._bufferService = this._instantiationService.createInstance(BufferService);
|
||||
this._instantiationService.setService(IBufferService, this._bufferService);
|
||||
this._logService = this._instantiationService.createInstance(LogService);
|
||||
this._instantiationService.setService(ILogService, this._logService);
|
||||
this._coreService = this._instantiationService.createInstance(CoreService, () => this.scrollToBottom());
|
||||
this._instantiationService.setService(ICoreService, this._coreService);
|
||||
this._coreService.onData(e => this._onData.fire(e));
|
||||
this._dirtyRowService = this._instantiationService.createInstance(DirtyRowService);
|
||||
this._instantiationService.setService(IDirtyRowService, this._dirtyRowService);
|
||||
this._logService = this._instantiationService.createInstance(LogService);
|
||||
this._instantiationService.setService(ILogService, this._logService);
|
||||
|
||||
this._setupOptionsListeners();
|
||||
this._setup();
|
||||
@@ -1514,6 +1521,8 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
* @param ev The keydown event to be handled.
|
||||
*/
|
||||
protected _keyDown(event: KeyboardEvent): boolean {
|
||||
this._keyDownHandled = false;
|
||||
|
||||
if (this._customKeyEventHandler && this._customKeyEventHandler(event) === false) {
|
||||
return false;
|
||||
}
|
||||
@@ -1529,12 +1538,6 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
|
||||
this.updateCursorStyle(event);
|
||||
|
||||
// if (result.key === C0.DC3) { // XOFF
|
||||
// this._writeStopped = true;
|
||||
// } else if (result.key === C0.DC1) { // XON
|
||||
// this._writeStopped = false;
|
||||
// }
|
||||
|
||||
if (result.type === KeyboardResultType.PAGE_DOWN || result.type === KeyboardResultType.PAGE_UP) {
|
||||
const scrollCount = this.rows - 1;
|
||||
this.scrollLines(result.type === KeyboardResultType.PAGE_UP ? -scrollCount : scrollCount);
|
||||
@@ -1558,11 +1561,17 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
return true;
|
||||
}
|
||||
|
||||
// If ctrl+c or enter is being sent, clear out the textarea. This is done so that screen readers
|
||||
// will announce deleted characters. This will not work 100% of the time but it should cover
|
||||
// most scenarios.
|
||||
if (result.key === C0.ETX || result.key === C0.CR) {
|
||||
this.textarea.value = '';
|
||||
}
|
||||
|
||||
this._keyDownHandled = true;
|
||||
this._onKey.fire({ key: result.key, domEvent: event });
|
||||
this.showCursor();
|
||||
this._coreService.triggerDataEvent(result.key, true);
|
||||
|
||||
return this.cancel(event, true);
|
||||
}
|
||||
|
||||
private _isThirdLevelShift(browser: IBrowser, ev: IKeyboardEvent): boolean {
|
||||
@@ -1620,6 +1629,10 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
protected _keyPress(ev: KeyboardEvent): boolean {
|
||||
let key;
|
||||
|
||||
if (this._keyDownHandled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this._customKeyEventHandler && this._customKeyEventHandler(ev) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { ICoreService, IOptionsService, IBufferService } from 'common/services/Services';
|
||||
import { ICoreService, ILogService, IOptionsService, IBufferService } from 'common/services/Services';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { IDecPrivateModes } from 'common/Types';
|
||||
import { clone } from 'common/Clone';
|
||||
@@ -26,6 +26,7 @@ export class CoreService implements ICoreService {
|
||||
// TODO: Move this into a service
|
||||
private readonly _scrollToBottom: () => void,
|
||||
@IBufferService private readonly _bufferService: IBufferService,
|
||||
@ILogService private readonly _logService: ILogService,
|
||||
@IOptionsService private readonly _optionsService: IOptionsService
|
||||
) {
|
||||
this.decPrivateModes = clone(DEFAULT_DEC_PRIVATE_MODES);
|
||||
@@ -53,6 +54,7 @@ export class CoreService implements ICoreService {
|
||||
}
|
||||
|
||||
// Fire onData API
|
||||
this._logService.debug('sending data', data);
|
||||
this._onData.fire(data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user