Merge pull request #7926 from Carreau/config-3.1

Fix configurability of codecell
This commit is contained in:
Min RK 2015-03-12 17:49:28 -07:00
commit 3a21271d7e
2 changed files with 25 additions and 16 deletions

View File

@ -572,8 +572,17 @@ define([
var regs = modes[mode].reg;
// only one key every time but regexp can't be keys...
for(var i=0; i<regs.length; i++) {
// here we handle non magic_modes
if(first_line.match(regs[i]) !== null) {
// here we handle non magic_modes.
// TODO :
// On 3.0 and below, these things were regex.
// But now should be string for json-able config.
// We should get rid of assuming they might be already
// in a later version of IPython.
var re = regs[i];
if(typeof(re) === 'string'){
re = new RegExp(re)
}
if(first_line.match(re) !== null) {
if(current_mode == mode){
return;
}

View File

@ -127,22 +127,22 @@ define([
},
mode: 'ipython',
theme: 'ipython',
matchBrackets: true
}
};
CodeCell.config_defaults = {
matchBrackets: true,
autoCloseBrackets: true
},
highlight_modes : {
'magic_javascript' :{'reg':[/^%%javascript/]},
'magic_perl' :{'reg':[/^%%perl/]},
'magic_ruby' :{'reg':[/^%%ruby/]},
'magic_python' :{'reg':[/^%%python3?/]},
'magic_shell' :{'reg':[/^%%bash/]},
'magic_r' :{'reg':[/^%%R/]},
'magic_text/x-cython' :{'reg':[/^%%cython/]},
'magic_javascript' :{'reg':['^%%javascript']},
'magic_perl' :{'reg':['^%%perl']},
'magic_ruby' :{'reg':['^%%ruby']},
'magic_python' :{'reg':['^%%python3?']},
'magic_shell' :{'reg':['^%%bash']},
'magic_r' :{'reg':['^%%R']},
'magic_text/x-cython' :{'reg':['^%%cython']},
},
};
CodeCell.config_defaults = CodeCell.options_default;
CodeCell.msg_cells = {};
CodeCell.prototype = Object.create(Cell.prototype);
@ -163,7 +163,7 @@ define([
notebook: this.notebook});
inner_cell.append(this.celltoolbar.element);
var input_area = $('<div/>').addClass('input_area');
this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config);
this.code_mirror = new CodeMirror(input_area.get(0), this.class_config.get_sync('cm_config'));
// In case of bugs that put the keyboard manager into an inconsistent state,
// ensure KM is enabled when CodeMirror is focused:
this.code_mirror.on('focus', function () {