From 5aaa623744872f42a1911dac5069e115c3a22f15 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 28 Mar 2016 17:16:49 -0700 Subject: [PATCH 1/4] use cjs require fixes jQuery loading thanks @jdfreder --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 042097576..60ac61300 100644 --- a/main.js +++ b/main.js @@ -1,4 +1,4 @@ -define(['require'], function (require) { +define(function (require, exports, module) { "use strict"; var $ = require('jquery'); var Jupyter = require('base/js/namespace'); From de75a09568339bed2a34bc39d8b56c4226b1496e Mon Sep 17 00:00:00 2001 From: "dean.wyatte" Date: Thu, 22 Sep 2016 09:31:25 -0600 Subject: [PATCH 2/4] enable ctrl-enter --- main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/main.js b/main.js index 60ac61300..e896affd7 100644 --- a/main.js +++ b/main.js @@ -51,6 +51,7 @@ define(function (require, exports, module) { var shortcuts = { 'shift-enter': execute_action, + 'ctrl-enter': execute_action, 'ctrl-b': toggle_action, } this.km.edit_shortcuts.add_shortcuts(shortcuts); From 43c13e581004fc2deb8bbf602e367828bbd328dd Mon Sep 17 00:00:00 2001 From: "dean.wyatte" Date: Thu, 22 Sep 2016 15:24:50 -0600 Subject: [PATCH 3/4] pass even through to notebook when scratchpad isn't focuesd --- main.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index e896affd7..4da01f304 100644 --- a/main.js +++ b/main.js @@ -41,7 +41,10 @@ define(function (require, exports, module) { cell.refresh(); this.collapse(); - // override shift-enter to execute me if I'm focused instead of the notebook's cell + // override ctrl/shift-enter to execute me if I'm focused instead of the notebook's cell + var execute_and_select_action = this.km.actions.register({ + handler: $.proxy(this.execute_and_select_event, this), + }, 'scratchpad-execute-and-select'); var execute_action = this.km.actions.register({ handler: $.proxy(this.execute_event, this), }, 'scratchpad-execute'); @@ -50,7 +53,7 @@ define(function (require, exports, module) { }, 'scratchpad-toggle'); var shortcuts = { - 'shift-enter': execute_action, + 'shift-enter': execute_and_select_action, 'ctrl-enter': execute_action, 'ctrl-b': toggle_action, } @@ -94,7 +97,7 @@ define(function (require, exports, module) { this.cell.element.hide(); }; - Scratchpad.prototype.execute_event = function (evt) { + Scratchpad.prototype.execute_and_select_event = function (evt) { if (utils.is_focused(this.element)) { this.cell.execute(); } else { @@ -102,6 +105,14 @@ define(function (require, exports, module) { } }; + Scratchpad.prototype.execute_event = function (evt) { + if (utils.is_focused(this.element)) { + this.cell.execute(); + } else { + this.notebook.execute_cell(); + } + }; + function setup_scratchpad () { // lazy, hook it up to Jupyter.notebook as the handle on all the singletons console.log("Setting up scratchpad"); From 8712931312e6ccc07a28a462be8bbaa2d4e1853a Mon Sep 17 00:00:00 2001 From: "dean.wyatte" Date: Thu, 22 Sep 2016 15:36:17 -0600 Subject: [PATCH 4/4] use forward-compatible function instead of alias --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 4da01f304..1c6921bd5 100644 --- a/main.js +++ b/main.js @@ -109,7 +109,7 @@ define(function (require, exports, module) { if (utils.is_focused(this.element)) { this.cell.execute(); } else { - this.notebook.execute_cell(); + this.notebook.execute_selected_cells(); } };