Autoindentation fixed and enabled by default.

This commit is contained in:
Brian E. Granger 2011-08-11 14:30:44 -07:00
parent 0db7ab16a3
commit 3db421fb73
4 changed files with 6 additions and 8 deletions

View File

@ -10,9 +10,10 @@ var IPython = (function (IPython) {
var Cell = function (notebook) {
this.notebook = notebook;
this.selected = false;
this.element;
this.element = null;
this.create_element();
if (this.element !== undefined) {
if (this.element !== null) {
this.set_autoindent(true);
this.element.data("cell", this);
this.bind_events();
}

View File

@ -27,8 +27,6 @@ var IPython = (function (IPython) {
var input_area = $('<div/>').addClass('input_area box-flex1');
this.code_mirror = CodeMirror(input_area.get(0), {
indentUnit : 4,
enterMode : 'flat',
tabMode: 'shift',
mode: 'python',
theme: 'ipython',
onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this)
@ -64,7 +62,8 @@ var IPython = (function (IPython) {
IPython.notebook.complete_cell(this, line, cur.ch);
return true;
}
} else if (event.keyCode === 8) {
} else if (event.keyCode === 8 && event.type == 'keydown') {
console.log(event);
// If backspace and the line ends with 4 spaces, remove them.
var cur = editor.getCursor();
var line = editor.getLine(cur.line);

View File

@ -24,8 +24,6 @@ var IPython = (function (IPython) {
var input_area = $('<div/>').addClass('text_cell_input');
this.code_mirror = CodeMirror(input_area.get(0), {
indentUnit : 4,
enterMode : 'flat',
tabMode: 'shift',
mode: this.code_mirror_mode,
theme: 'default',
value: this.placeholder

View File

@ -121,7 +121,7 @@
</div>
<div class="section_row">
<span id="autoindent_span">
<input type="checkbox" id="autoindent"></input>
<input type="checkbox" id="autoindent" checked="true"></input>
</span>
<span class="checkbox_label">Autoindent:</span>
</div>