DRY: factor out common handle_keyevent method

This method was identical in both CodeCell and TextCell
Paul Ivanov 12 years ago
parent 71d4c427c9
commit bf3ecdb35f

@ -229,6 +229,26 @@ var IPython = (function (IPython) {
}
};
/**
* Either delegates keyboard shortcut handling to either IPython keyboard
* manager when in command mode, or CodeMirror when in edit mode
*
* @method handle_keyevent
* @param {CodeMirror} editor - The codemirror instance bound to the cell
* @param {event} event -
* @return {Boolean} `true` if CodeMirror should ignore the event, `false` Otherwise
*/
CodeCell.prototype.handle_keyevent = function (editor, event) {
// console.log('CM', this.mode, event.which, event.type)
if (this.mode === 'command') {
return true;
} else if (this.mode === 'edit') {
return this.handle_codemirror_keyevent(editor, event);
}
};
/**
* @method at_top
* @return {Boolean}

@ -171,16 +171,6 @@ var IPython = (function (IPython) {
);
};
CodeCell.prototype.handle_keyevent = function (editor, event) {
// console.log('CM', this.mode, event.which, event.type)
if (this.mode === 'command') {
return true;
} else if (this.mode === 'edit') {
return this.handle_codemirror_keyevent(editor, event);
}
};
/**
* This method gets called in CodeMirror's onKeyDown/onKeyPress

@ -113,22 +113,11 @@ var IPython = (function (IPython) {
});
};
TextCell.prototype.handle_keyevent = function (editor, event) {
// console.log('CM', this.mode, event.which, event.type)
if (this.mode === 'command') {
return true;
} else if (this.mode === 'edit') {
return this.handle_codemirror_keyevent(editor, event);
}
};
/**
* This method gets called in CodeMirror's onKeyDown/onKeyPress
* handlers and is used to provide custom key handling.
*
* Subclass should override this method to have custom handeling
* Subclass should override this method to have custom handling
*
* @method handle_codemirror_keyevent
* @param {CodeMirror} editor - The codemirror instance bound to the cell

Loading…
Cancel
Save