From 3053ec9f9b1c986e0e3dcfb26f313b6928dd3c08 Mon Sep 17 00:00:00 2001 From: Matthias BUSSONNIER Date: Mon, 7 Nov 2011 13:00:15 +0100 Subject: [PATCH 01/15] Add Tootip to notebook. When user press '(' and nothing for 1200ms, 'object_info_request' sent to the kernel. Then tooltip with 'definition' and beggining of 'docstring' shown to the user if non empty response. Unlike Completion + + Tooltip on tab: + + + +
From 2637d3c0e4bd38a13a95f97555a79b9519e9f12c Mon Sep 17 00:00:00 2001 From: Matthias BUSSONNIER Date: Mon, 14 Nov 2011 19:00:52 +0100 Subject: [PATCH 04/15] Make the time before activating a tooltip configurable add a section in the left pannel of the notebook to make the time before triggering a tooltip when pressign "(" configurable. Negative values will disable the tooltip (comparaison at each keypress for now, but can be improved) The syle of the field should be a little improve, why not a slider with jquerry --- IPython/frontend/html/notebook/static/js/codecell.js | 5 ++++- IPython/frontend/html/notebook/static/js/notebook.js | 6 ++++++ IPython/frontend/html/notebook/templates/notebook.html | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js index 1d4f17785..2fed320f7 100644 --- a/IPython/frontend/html/notebook/static/js/codecell.js +++ b/IPython/frontend/html/notebook/static/js/codecell.js @@ -64,8 +64,11 @@ var IPython = (function (IPython) { // handlers and is used to provide custom key handling. Its return // value is used to determine if CodeMirror should ignore the event: // true = ignore, false = don't ignore. - tooltip_wait_time = 2000; + // note that we are comparing and setting the time to wait at each key press. + // a better wqy might be to generate a new function on each time change and + // assign it to CodeCell.prototype.request_tooltip_after_time + tooltip_wait_time = this.notebook.time_before_tooltip; tooltip_on_tab = this.notebook.tooltip_on_tab; var that = this; diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index b6c36e11e..c0c2d2274 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -28,6 +28,7 @@ var IPython = (function (IPython) { this.create_elements(); this.bind_events(); this.set_tooltipontab(true); + this.set_timebeforetooltip(1200); }; @@ -622,6 +623,11 @@ var IPython = (function (IPython) { }; + Notebook.prototype.set_timebeforetooltip = function (time) { + console.log("change time before tooltip to : "+time); + this.time_before_tooltip = time; + }; + Notebook.prototype.set_tooltipontab = function (state) { console.log("change tooltip on tab to : "+state); this.tooltip_on_tab = state; diff --git a/IPython/frontend/html/notebook/templates/notebook.html b/IPython/frontend/html/notebook/templates/notebook.html index 299a76f56..c99e07c03 100644 --- a/IPython/frontend/html/notebook/templates/notebook.html +++ b/IPython/frontend/html/notebook/templates/notebook.html @@ -262,6 +262,12 @@ Tooltip on tab:
+
+ + + + Time before tooltip : +
From 7600221d1c708cced19a24a9aff59b20a2b4284b Mon Sep 17 00:00:00 2001 From: Matthias BUSSONNIER Date: Tue, 15 Nov 2011 22:14:54 +0100 Subject: [PATCH 05/15] smart kwarg completion change order of completion element so that the ones ending with '=' will be at the beginning of the list. When you complete inside a fonction call, you then have kwargs first add configuration in the left pannel --- .../frontend/html/notebook/static/css/notebook.css | 4 ++++ .../frontend/html/notebook/static/js/codecell.js | 13 +++++++++++++ .../frontend/html/notebook/static/js/notebook.js | 6 ++++++ .../frontend/html/notebook/templates/notebook.html | 6 ++++++ 4 files changed, 29 insertions(+) diff --git a/IPython/frontend/html/notebook/static/css/notebook.css b/IPython/frontend/html/notebook/static/css/notebook.css index 0a3470106..093b8525b 100644 --- a/IPython/frontend/html/notebook/static/css/notebook.css +++ b/IPython/frontend/html/notebook/static/css/notebook.css @@ -119,6 +119,10 @@ span.section_row_buttons a { float: right; } +#smartcompleter_span { + float: right; +} + .checkbox_label { font-size: 85%; float: right; diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js index 2fed320f7..7605bdec5 100644 --- a/IPython/frontend/html/notebook/static/js/codecell.js +++ b/IPython/frontend/html/notebook/static/js/codecell.js @@ -179,6 +179,19 @@ var IPython = (function (IPython) { CodeCell.prototype.finish_completing = function (matched_text, matches) { // console.log("Got matches", matched_text, matches); + var newm = new Array(); + if(this.notebook.smart_completer) + { + kwargs = new Array(); + other = new Array(); + for(var i=0;i= 0) { + }else if (event.which === 40 && event.type === 'keypress' && tooltip_wait_time >= 0) { + // triger aon keypress (!) otherwise inconsistent event.which depending on plateform + // browser and keyboard layout ! // Pressing '(' , request tooltip, don't forget to reappend it var cursor = editor.getCursor(); var pre_cursor = editor.getRange({line:cursor.line,ch:0},cursor).trim()+'('; From aa24495b5bf4cdf81f786ae3c357bf5b06157257 Mon Sep 17 00:00:00 2001 From: Matthias BUSSONNIER Date: Mon, 21 Nov 2011 10:09:51 +0100 Subject: [PATCH 08/15] add 'more...' and 'close' button to the pager 'more...' button execute 'foo?' **On the behalf of the current cell** which increase it's prompt number to the curent value, and give focus back --- .../html/notebook/static/js/codecell.js | 25 +++++++++++++++++-- .../html/notebook/static/js/notebook.js | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js index cfd497301..38ed22dd3 100644 --- a/IPython/frontend/html/notebook/static/js/codecell.js +++ b/IPython/frontend/html/notebook/static/js/codecell.js @@ -153,7 +153,10 @@ var IPython = (function (IPython) { $('#tooltip').remove(); } - CodeCell.prototype.finish_tooltip = function (defstring,docstring) { + CodeCell.prototype.finish_tooltip = function (reply) { + defstring=reply.definition; + docstring=reply.docstring; + name=reply.name; shortened = function(string){ if(string.length > 200){ return string.trim().substring(0,197)+'...'; @@ -166,7 +169,25 @@ var IPython = (function (IPython) { defstring_html= $('
').html(utils.fixConsole(defstring));
             tooltip.append(defstring_html);
         }
-        tooltip.append($('
').html(utils.fixConsole(shortened(docstring))));
+        var pre=$('
').html(utils.fixConsole(shortened(docstring)));
+        var more=$('