Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce options service, move options handling code into common #2171

Merged
merged 6 commits into from
Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Buffer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ describe('Buffer', () => {
const input = '\thttps://google.de';
terminal.writeSync(input);
const s = terminal.buffer.iterator(true).next().content;
assert.equal(s, Array(terminal.getOption('tabStopWidth') + 1).join(' ') + 'https://google.de');
assert.equal(s, Array(terminal.options.tabStopWidth + 1).join(' ') + 'https://google.de');
});
});
describe('BufferStringIterator', function(): void {
Expand Down
8 changes: 4 additions & 4 deletions src/InputHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1842,19 +1842,19 @@ export class InputHandler extends Disposable implements IInputHandler {
switch (param) {
case 1:
case 2:
this._terminal.setOption('cursorStyle', 'block');
this._terminal.options.cursorStyle = 'block';
break;
case 3:
case 4:
this._terminal.setOption('cursorStyle', 'underline');
this._terminal.options.cursorStyle = 'underline';
break;
case 5:
case 6:
this._terminal.setOption('cursorStyle', 'bar');
this._terminal.options.cursorStyle = 'bar';
break;
}
const isBlinking = param % 2 === 1;
this._terminal.setOption('cursorBlink', isBlinking);
this._terminal.options.cursorBlink = isBlinking;
}
}

Expand Down
6 changes: 0 additions & 6 deletions src/SoundManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@

import { ITerminal, ISoundManager } from './Types';

// Source: https://freesound.org/people/altemark/sounds/45759/
// This sound is released under the Creative Commons Attribution 3.0 Unported
// (CC BY 3.0) license. It was created by 'altemark'. No modifications have been
// made, apart from the conversion to base64.
export const DEFAULT_BELL_SOUND = 'data:audio/wav;base64,UklGRigBAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQBAADpAFgCwAMlBZoG/wdmCcoKRAypDQ8PbRDBEQQTOxRtFYcWlBePGIUZXhoiG88bcBz7HHIdzh0WHlMeZx51HmkeUx4WHs8dah0AHXwc3hs9G4saxRnyGBIYGBcQFv8U4RPAEoYRQBACD70NWwwHC6gJOwjWBloF7gOBAhABkf8b/qv8R/ve+Xf4Ife79W/0JfPZ8Z/wde9N7ijtE+wU6xvqM+lb6H7nw+YX5mrlxuQz5Mzje+Ma49fioeKD4nXiYeJy4pHitOL04j/jn+MN5IPkFOWs5U3mDefM55/ogOl36m7rdOyE7abuyu8D8Unyj/Pg9D/2qfcb+Yn6/vuK/Qj/lAAlAg==';

export class SoundManager implements ISoundManager {
private static _audioContext: AudioContext;

Expand Down
34 changes: 3 additions & 31 deletions src/Terminal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,14 @@ describe('Terminal', () => {
});

it('should not mutate the options parameter', () => {
term.setOption('cols', 1000);
term.options.cols = 1000;

assert.deepEqual(termOptions, {
cols: INIT_COLS,
rows: INIT_ROWS
});
});

describe('getOption', () => {
it('should retrieve the option correctly', () => {
// In the `options` namespace.
term.options.cursorBlink = true;
assert.equal(term.getOption('cursorBlink'), true);

// On the Terminal instance
delete term.options.cursorBlink;
term.options.cursorBlink = false;
assert.equal(term.getOption('cursorBlink'), false);
});
it('should throw when retrieving a non-existant option', () => {
assert.throws(term.getOption.bind(term, 'fake', true));
});
});

describe('events', () => {
it('should fire the onData evnet', (done) => {
term.onData(() => done());
Expand Down Expand Up @@ -335,18 +319,6 @@ describe('Terminal', () => {
});
});

describe('setOption', () => {
it('should set option correctly', () => {
term.setOption('cursorBlink', true);
assert.equal(term.options.cursorBlink, true);
term.setOption('cursorBlink', false);
assert.equal(term.options.cursorBlink, false);
});
it('should throw when setting a non-existant option', () => {
assert.throws(term.setOption.bind(term, 'fake', true));
});
});

describe('reset', () => {
it('should not affect cursorState', () => {
term.cursorState = 1;
Expand Down Expand Up @@ -625,7 +597,7 @@ describe('Terminal', () => {

describe('when scrollback === 0', () => {
beforeEach(() => {
term.setOption('scrollback', 0);
term.optionsService.setOption('scrollback', 0);
assert.equal(term.buffer.lines.maxLength, INIT_ROWS);
});

Expand Down Expand Up @@ -730,7 +702,7 @@ describe('Terminal', () => {
describe('with macOptionIsMeta', () => {
beforeEach(() => {
term.browser.isMac = true;
term.setOption('macOptionIsMeta', true);
term.options.macOptionIsMeta = true;
});

it('should interfere with the alt key on keyDown', () => {
Expand Down