From 9826a17ae21ec522bc3cf256c40e9136dce284b4 Mon Sep 17 00:00:00 2001 From: Brian Granger Date: Thu, 31 May 2012 13:24:10 -0700 Subject: [PATCH] Removing cell from execute callbacks in kernel.js. --- .../html/notebook/static/js/codecell.js | 7 ++++++- .../html/notebook/static/js/kernel.js | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js index a53b87ce7..8accb9218 100644 --- a/IPython/frontend/html/notebook/static/js/codecell.js +++ b/IPython/frontend/html/notebook/static/js/codecell.js @@ -161,7 +161,7 @@ var IPython = (function (IPython) { 'execute_reply': $.proxy(this._handle_execute_reply, this), 'output': $.proxy(this.output_area.handle_output, this.output_area), 'clear_output': $.proxy(this.output_area.handle_clear_output, this.output_area), - 'cell': this + 'set_next_input': $.proxy(this._handle_set_next_input, this) }; var msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false}); }; @@ -173,6 +173,11 @@ var IPython = (function (IPython) { // this.dirty = true; } + CodeCell.prototype._handle_set_next_input = function (text) { + var data = {'cell': this, 'text': text} + $([IPython.events]).trigger('set_next_input.Notebook', data); + } + // Basic cell manipulation. CodeCell.prototype.select = function () { diff --git a/IPython/frontend/html/notebook/static/js/kernel.js b/IPython/frontend/html/notebook/static/js/kernel.js index 04a2218e5..e7a42abca 100644 --- a/IPython/frontend/html/notebook/static/js/kernel.js +++ b/IPython/frontend/html/notebook/static/js/kernel.js @@ -216,7 +216,7 @@ var IPython = (function (IPython) { // 'execute_reply': execute_reply_callback, // 'output': output_callback, // 'clear_output': clear_output_callback, - // 'cell': cell + // 'set_next_input': set_next_input_callback // } // // The execute_reply_callback will be passed the content object of the execute_reply @@ -233,8 +233,8 @@ var IPython = (function (IPython) { // The clear_output_callback will be passed a content object that contains // stdout, stderr and other fields that are booleans. // - // The cell value will contain the a cell object that the notebook can use for the - // set_next_input payload. + // The set_next_input_callback will bepassed the text that should become the next + // input cell. var content = { code : code, @@ -321,14 +321,14 @@ var IPython = (function (IPython) { } }; - if (content.payload !== undefined && callbacks.cell !== undefined) { + if (content.payload !== undefined) { var payload = content.payload || []; - this._handle_payload(callbacks.cell, payload); + this._handle_payload(callbacks, payload); } }; - Kernel.prototype._handle_payload = function (cell, payload) { + Kernel.prototype._handle_payload = function (callbacks, payload) { var l = payload.length; // Payloads are handled by triggering events because we don't want the Kernel // to depend on the Notebook or Pager classes. @@ -336,9 +336,10 @@ var IPython = (function (IPython) { if (payload[i].source === 'IPython.zmq.page.page') { var data = {'text':payload[i].text} $([IPython.events]).trigger('open_with_text.Pager', data); - } else if (payload[i].source === 'IPython.zmq.zmqshell.ZMQInteractiveShell.set_next_input' && cell !== undefined) { - var data = {'cell': cell, 'text': payload[i].text} - $([IPython.events]).trigger('set_next_input.Notebook', data); + } else if (payload[i].source === 'IPython.zmq.zmqshell.ZMQInteractiveShell.set_next_input') { + if (callbacks.set_next_input !== undefined) { + callbacks.set_next_input(payload[i].text) + } } }; };