mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-17 12:39:54 +08:00
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:
parent
61b47695e4
commit
8f17444c27
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user