Skip to content

Commit 18a7d48

Browse files
authored
Merge pull request #9 from dwyatte/shortcuts
enable ctrl-enter
2 parents 5aaa623 + 8712931 commit 18a7d48

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

main.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ define(function (require, exports, module) {
4141
cell.refresh();
4242
this.collapse();
4343

44-
// override shift-enter to execute me if I'm focused instead of the notebook's cell
44+
// override ctrl/shift-enter to execute me if I'm focused instead of the notebook's cell
45+
var execute_and_select_action = this.km.actions.register({
46+
handler: $.proxy(this.execute_and_select_event, this),
47+
}, 'scratchpad-execute-and-select');
4548
var execute_action = this.km.actions.register({
4649
handler: $.proxy(this.execute_event, this),
4750
}, 'scratchpad-execute');
@@ -50,7 +53,8 @@ define(function (require, exports, module) {
5053
}, 'scratchpad-toggle');
5154

5255
var shortcuts = {
53-
'shift-enter': execute_action,
56+
'shift-enter': execute_and_select_action,
57+
'ctrl-enter': execute_action,
5458
'ctrl-b': toggle_action,
5559
}
5660
this.km.edit_shortcuts.add_shortcuts(shortcuts);
@@ -93,14 +97,22 @@ define(function (require, exports, module) {
9397
this.cell.element.hide();
9498
};
9599

96-
Scratchpad.prototype.execute_event = function (evt) {
100+
Scratchpad.prototype.execute_and_select_event = function (evt) {
97101
if (utils.is_focused(this.element)) {
98102
this.cell.execute();
99103
} else {
100104
this.notebook.execute_cell_and_select_below();
101105
}
102106
};
103107

108+
Scratchpad.prototype.execute_event = function (evt) {
109+
if (utils.is_focused(this.element)) {
110+
this.cell.execute();
111+
} else {
112+
this.notebook.execute_selected_cells();
113+
}
114+
};
115+
104116
function setup_scratchpad () {
105117
// lazy, hook it up to Jupyter.notebook as the handle on all the singletons
106118
console.log("Setting up scratchpad");

0 commit comments

Comments
 (0)