@@ -357,6 +357,19 @@ Terminal.prototype.focus = function() {
|
|||||||
return this.textarea.focus();
|
return this.textarea.focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets an option on the terminal.
|
||||||
|
* @param {string} key The option key.
|
||||||
|
* @param {string} value The option value.
|
||||||
|
*/
|
||||||
|
Terminal.prototype.setOption = function(key, value) {
|
||||||
|
if (!(key in Terminal.defaults)) {
|
||||||
|
throw new Error('No option with key "' + key + '"');
|
||||||
|
}
|
||||||
|
this[key] = value;
|
||||||
|
this.options[key] = value;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds the desired focus behavior on a given terminal object.
|
* Binds the desired focus behavior on a given terminal object.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -10,6 +10,20 @@ describe('xterm.js', function() {
|
|||||||
xterm.refresh = function(){};
|
xterm.refresh = function(){};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('setOption', function() {
|
||||||
|
it('should set the option correctly', function() {
|
||||||
|
xterm.setOption('cursorBlink', true);
|
||||||
|
assert.equal(xterm.cursorBlink, true);
|
||||||
|
assert.equal(xterm.options.cursorBlink, true);
|
||||||
|
xterm.setOption('cursorBlink', false);
|
||||||
|
assert.equal(xterm.cursorBlink, false);
|
||||||
|
assert.equal(xterm.options.cursorBlink, false);
|
||||||
|
});
|
||||||
|
it('should throw when setting a non-existant option', function() {
|
||||||
|
assert.throws(xterm.setOption.bind(xterm, 'fake', true));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('evaluateKeyEscapeSequence', function() {
|
describe('evaluateKeyEscapeSequence', function() {
|
||||||
it('should return the correct escape sequence for unmodified keys', function() {
|
it('should return the correct escape sequence for unmodified keys', function() {
|
||||||
// Backspace
|
// Backspace
|
||||||
|
|||||||
Reference in New Issue
Block a user