Show More
@@ -936,6 +936,9 b' pre,code,kbd,samp{white-space:pre-wrap;}' | |||||
936 | a{text-decoration:underline;} |
|
936 | a{text-decoration:underline;} | |
937 | p{margin-bottom:0;} |
|
937 | p{margin-bottom:0;} | |
938 | a.heading-anchor:link,a.heading-anchor:visited{text-decoration:none;color:inherit;} |
|
938 | a.heading-anchor:link,a.heading-anchor:visited{text-decoration:none;color:inherit;} | |
|
939 | span.input_prompt{font-family:monospace;} | |||
|
940 | input.raw_input{width: auto; font-family: monospace;} | |||
|
941 | ||||
939 | @media print{body{overflow:visible !important;} div#notebook{overflow:visible !important;} .ui-widget-content{border:0px;} #save_widget{margin:0px !important;} #header,#pager,#pager_splitter,#menubar,#toolbar{display:none !important;} .cell{border:none !important;} .toolbar{display:none;}}.rendered_html{color:black;}.rendered_html em{font-style:italic;} |
|
942 | @media print{body{overflow:visible !important;} div#notebook{overflow:visible !important;} .ui-widget-content{border:0px;} #save_widget{margin:0px !important;} #header,#pager,#pager_splitter,#menubar,#toolbar{display:none !important;} .cell{border:none !important;} .toolbar{display:none;}}.rendered_html{color:black;}.rendered_html em{font-style:italic;} | |
940 | .rendered_html strong{font-weight:bold;} |
|
943 | .rendered_html strong{font-weight:bold;} | |
941 | .rendered_html u{text-decoration:underline;} |
|
944 | .rendered_html u{text-decoration:underline;} |
@@ -245,7 +245,8 b' var IPython = (function (IPython) {' | |||||
245 | 'execute_reply': $.proxy(this._handle_execute_reply, this), |
|
245 | 'execute_reply': $.proxy(this._handle_execute_reply, this), | |
246 | 'output': $.proxy(this.output_area.handle_output, this.output_area), |
|
246 | 'output': $.proxy(this.output_area.handle_output, this.output_area), | |
247 | 'clear_output': $.proxy(this.output_area.handle_clear_output, this.output_area), |
|
247 | 'clear_output': $.proxy(this.output_area.handle_clear_output, this.output_area), | |
248 | 'set_next_input': $.proxy(this._handle_set_next_input, this) |
|
248 | 'set_next_input': $.proxy(this._handle_set_next_input, this), | |
|
249 | 'input_request': $.proxy(this._handle_input_request, this) | |||
249 | }; |
|
250 | }; | |
250 | var msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false}); |
|
251 | var msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false}); | |
251 | }; |
|
252 | }; | |
@@ -260,10 +261,23 b' var IPython = (function (IPython) {' | |||||
260 | $([IPython.events]).trigger('set_dirty.Notebook', {'value': true}); |
|
261 | $([IPython.events]).trigger('set_dirty.Notebook', {'value': true}); | |
261 | } |
|
262 | } | |
262 |
|
263 | |||
|
264 | /** | |||
|
265 | * @method _handle_set_next_input | |||
|
266 | * @private | |||
|
267 | */ | |||
263 | CodeCell.prototype._handle_set_next_input = function (text) { |
|
268 | CodeCell.prototype._handle_set_next_input = function (text) { | |
264 | var data = {'cell': this, 'text': text} |
|
269 | var data = {'cell': this, 'text': text} | |
265 | $([IPython.events]).trigger('set_next_input.Notebook', data); |
|
270 | $([IPython.events]).trigger('set_next_input.Notebook', data); | |
266 | } |
|
271 | } | |
|
272 | ||||
|
273 | /** | |||
|
274 | * @method _handle_input_request | |||
|
275 | * @private | |||
|
276 | */ | |||
|
277 | CodeCell.prototype._handle_input_request = function (content) { | |||
|
278 | this.output_area.append_raw_input(content); | |||
|
279 | } | |||
|
280 | ||||
267 |
|
281 | |||
268 | // Basic cell manipulation. |
|
282 | // Basic cell manipulation. | |
269 |
|
283 |
@@ -168,6 +168,10 b' var IPython = (function (IPython) {' | |||||
168 | this.shell_channel.onmessage = $.proxy(this._handle_shell_reply, this); |
|
168 | this.shell_channel.onmessage = $.proxy(this._handle_shell_reply, this); | |
169 | this.iopub_channel.onmessage = $.proxy(this._handle_iopub_reply, this); |
|
169 | this.iopub_channel.onmessage = $.proxy(this._handle_iopub_reply, this); | |
170 | this.stdin_channel.onmessage = $.proxy(this._handle_input_request, this); |
|
170 | this.stdin_channel.onmessage = $.proxy(this._handle_input_request, this); | |
|
171 | ||||
|
172 | $([IPython.events]).on('send_input_reply.Kernel', function(evt, data) { | |||
|
173 | that.send_input_reply(data); | |||
|
174 | }); | |||
171 | }; |
|
175 | }; | |
172 |
|
176 | |||
173 | /** |
|
177 | /** | |
@@ -283,8 +287,11 b' var IPython = (function (IPython) {' | |||||
283 | silent : true, |
|
287 | silent : true, | |
284 | user_variables : [], |
|
288 | user_variables : [], | |
285 | user_expressions : {}, |
|
289 | user_expressions : {}, | |
286 |
allow_stdin : |
|
290 | allow_stdin : false | |
287 | }; |
|
291 | }; | |
|
292 | if (callbacks.input_request !== undefined) { | |||
|
293 | content.allow_stdin = true; | |||
|
294 | } | |||
288 | $.extend(true, content, options) |
|
295 | $.extend(true, content, options) | |
289 | $([IPython.events]).trigger('execution_request.Kernel', {kernel: this, content:content}); |
|
296 | $([IPython.events]).trigger('execution_request.Kernel', {kernel: this, content:content}); | |
290 | var msg = this._get_msg("execute_request", content); |
|
297 | var msg = this._get_msg("execute_request", content); | |
@@ -344,8 +351,7 b' var IPython = (function (IPython) {' | |||||
344 | }; |
|
351 | }; | |
345 | }; |
|
352 | }; | |
346 |
|
353 | |||
347 |
Kernel.prototype.send_input_reply = function (input |
|
354 | Kernel.prototype.send_input_reply = function (input) { | |
348 |
|
||||
349 | var content = { |
|
355 | var content = { | |
350 | value : input, |
|
356 | value : input, | |
351 | }; |
|
357 | }; | |
@@ -447,7 +453,6 b' var IPython = (function (IPython) {' | |||||
447 |
|
453 | |||
448 | Kernel.prototype._handle_input_request = function (e) { |
|
454 | Kernel.prototype._handle_input_request = function (e) { | |
449 | var request = $.parseJSON(e.data); |
|
455 | var request = $.parseJSON(e.data); | |
450 | console.log("input", request); |
|
|||
451 | var header = request.header; |
|
456 | var header = request.header; | |
452 | var content = request.content; |
|
457 | var content = request.content; | |
453 | var metadata = request.metadata; |
|
458 | var metadata = request.metadata; | |
@@ -456,7 +461,13 b' var IPython = (function (IPython) {' | |||||
456 | console.log("Invalid input request!", request); |
|
461 | console.log("Invalid input request!", request); | |
457 | return; |
|
462 | return; | |
458 | } |
|
463 | } | |
459 | $([IPython.events]).trigger('input_request.Kernel', {kernel: this, request:request}); |
|
464 | var callbacks = this.get_callbacks_for_msg(request.parent_header.msg_id); | |
|
465 | if (callbacks !== undefined) { | |||
|
466 | var cb = callbacks[msg_type]; | |||
|
467 | if (cb !== undefined) { | |||
|
468 | cb(content, metadata); | |||
|
469 | } | |||
|
470 | }; | |||
460 | }; |
|
471 | }; | |
461 |
|
472 | |||
462 |
|
473 |
@@ -115,34 +115,6 b' var IPython = (function (IPython) {' | |||||
115 | var index = that.find_cell_index(data.cell); |
|
115 | var index = that.find_cell_index(data.cell); | |
116 | that.select(index); |
|
116 | that.select(index); | |
117 | }); |
|
117 | }); | |
118 | $([IPython.events]).on('input_request.Kernel', function (event, data) { |
|
|||
119 | var dialog = $('<div/>').attr('id','input_form').append( |
|
|||
120 | $('<form/>') |
|
|||
121 | .attr("action", "javascript:$('#input_form').parent().find('button').click();") |
|
|||
122 | .append( |
|
|||
123 | $('<input/>') |
|
|||
124 | .attr('id', 'input_prompt_dialog') |
|
|||
125 | .attr('type', 'text') |
|
|||
126 | .attr('name', 'input') |
|
|||
127 | )); |
|
|||
128 | $(document).append(dialog); |
|
|||
129 | dialog.dialog({ |
|
|||
130 | resizable: false, |
|
|||
131 | modal: true, |
|
|||
132 | title: data.request.content.prompt, |
|
|||
133 | closeText: '', |
|
|||
134 | buttons : { |
|
|||
135 | "Okay": function () { |
|
|||
136 | IPython.notebook.kernel.send_input_reply( |
|
|||
137 | $("input#input_prompt_dialog").attr('value'), |
|
|||
138 | data.request.header |
|
|||
139 | ); |
|
|||
140 | $(this).dialog('close'); |
|
|||
141 | dialog.remove(); |
|
|||
142 | } |
|
|||
143 | } |
|
|||
144 | }); |
|
|||
145 | }); |
|
|||
146 |
|
118 | |||
147 |
|
119 | |||
148 | $(document).keydown(function (event) { |
|
120 | $(document).keydown(function (event) { |
@@ -74,6 +74,7 b' var IPython = (function (IPython) {' | |||||
74 |
|
74 | |||
75 | OutputArea.prototype.bind_events = function () { |
|
75 | OutputArea.prototype.bind_events = function () { | |
76 | var that = this; |
|
76 | var that = this; | |
|
77 | this._submit_raw_input_proxy = $.proxy(this._submit_raw_input, this); | |||
77 | this.prompt_overlay.dblclick(function () { that.toggle_output(); }); |
|
78 | this.prompt_overlay.dblclick(function () { that.toggle_output(); }); | |
78 | this.prompt_overlay.click(function () { that.toggle_scroll(); }); |
|
79 | this.prompt_overlay.click(function () { that.toggle_scroll(); }); | |
79 |
|
80 | |||
@@ -448,6 +449,51 b' var IPython = (function (IPython) {' | |||||
448 | toinsert.append(latex); |
|
449 | toinsert.append(latex); | |
449 | element.append(toinsert); |
|
450 | element.append(toinsert); | |
450 | }; |
|
451 | }; | |
|
452 | ||||
|
453 | OutputArea.prototype.append_raw_input = function (content) { | |||
|
454 | this.expand(); | |||
|
455 | this.flush_clear_timeout(); | |||
|
456 | var area = this.create_output_area(); | |||
|
457 | area.append( | |||
|
458 | $("<div/>") | |||
|
459 | .addClass("box-flex1 output_subarea raw_input") | |||
|
460 | .append( | |||
|
461 | $("<form/>") | |||
|
462 | .attr("action", "javascript:$([IPython.events]).trigger('submit_raw_input.OutputArea');") | |||
|
463 | .append( | |||
|
464 | $("<span/>") | |||
|
465 | .addClass("input_prompt") | |||
|
466 | .text(content.prompt) | |||
|
467 | ).append( | |||
|
468 | $("<input/>") | |||
|
469 | .attr("size", 80) | |||
|
470 | .addClass("raw_input") | |||
|
471 | ) | |||
|
472 | ) | |||
|
473 | ) | |||
|
474 | // clear events first | |||
|
475 | $([IPython.events]).off('submit_raw_input.OutputArea'); | |||
|
476 | $([IPython.events]).on('submit_raw_input.OutputArea', this._submit_raw_input_proxy); | |||
|
477 | this.element.append(area); | |||
|
478 | area.find("input.raw_input").focus(); | |||
|
479 | } | |||
|
480 | OutputArea.prototype._submit_raw_input = function (evt) { | |||
|
481 | var container = this.element.find("div.raw_input"); | |||
|
482 | var theprompt = container.find("span.input_prompt"); | |||
|
483 | var theinput = container.find("input.raw_input"); | |||
|
484 | var value = theinput.attr("value"); | |||
|
485 | var content = { | |||
|
486 | output_type : 'stream', | |||
|
487 | name : 'stdout', | |||
|
488 | text : theprompt.text() + value + '\n' | |||
|
489 | } | |||
|
490 | // remove form container | |||
|
491 | container.parent().remove(); | |||
|
492 | // replace with plaintext version in stdout | |||
|
493 | this.append_output(content, false); | |||
|
494 | $([IPython.events]).off('submit_raw_input.OutputArea', this._submit_raw_input_proxy); | |||
|
495 | $([IPython.events]).trigger('send_input_reply.Kernel', value); | |||
|
496 | } | |||
451 |
|
497 | |||
452 |
|
498 | |||
453 | OutputArea.prototype.handle_clear_output = function (content) { |
|
499 | OutputArea.prototype.handle_clear_output = function (content) { |
@@ -476,4 +476,12 b' margin-bottom:0;' | |||||
476 | a.heading-anchor:link, a.heading-anchor:visited { |
|
476 | a.heading-anchor:link, a.heading-anchor:visited { | |
477 | text-decoration: none; |
|
477 | text-decoration: none; | |
478 | color: inherit; |
|
478 | color: inherit; | |
|
479 | ||||
|
480 | /* raw_input styles */ | |||
|
481 | ||||
|
482 | span.input_prompt { | |||
|
483 | font-family: monospace; | |||
|
484 | } | |||
|
485 | input.raw_input { | |||
|
486 | width: auto; | |||
479 | } |
|
487 | } |
General Comments 0
You need to be logged in to leave comments.
Login now