go to appropriate line when coming from another cell

Sets the cursor on the last line of the cell when moved up from the top
of the cell below, and sets the cursors to the first line when moving
down from the bottom of a last line.

Here, we retain the character that the cursor was on, so that users
wishing to have up-down functionality like one document can still use
this shortcut handler and simple adjust the at_top and at_bottom methods
This commit is contained in:
Paul Ivanov 2014-03-17 15:48:36 -07:00
parent 61b47695e4
commit 8f17444c27

View File

@ -107,12 +107,16 @@ var IPython = (function (IPython) {
IPython.notebook.command_mode();
IPython.notebook.select_prev();
IPython.notebook.edit_mode();
var cm = IPython.notebook.get_selected_cell().code_mirror;
var prev_cursor = cell.code_mirror.getCursor();
cm.setCursor(cm.lastLine(), prev_cursor.ch)
return false;
} else if (cell) {
var cm = cell.code_mirror;
var cursor = cm.getCursor();
cursor.line -= 1;
cm.setCursor(cursor);
return false;
}
}
}
@ -129,12 +133,16 @@ var IPython = (function (IPython) {
IPython.notebook.command_mode();
IPython.notebook.select_next();
IPython.notebook.edit_mode();
var cm = IPython.notebook.get_selected_cell().code_mirror;
var prev_cursor = cell.code_mirror.getCursor();
cm.setCursor(0, prev_cursor.ch);
return false;
} else if (cell) {
var cm = cell.code_mirror;
var cursor = cm.getCursor();
cursor.line += 1;
cm.setCursor(cursor);
return false;
}
}
}