Show More
@@ -20,6 +20,7 b' var IPython = (function (IPython) {' | |||
|
20 | 20 | this.completion_cursor = null; |
|
21 | 21 | this.outputs = []; |
|
22 | 22 | this.collapsed = false; |
|
23 | this.tooltip_timeout = null; | |
|
23 | 24 | IPython.Cell.apply(this, arguments); |
|
24 | 25 | }; |
|
25 | 26 | |
@@ -48,7 +49,8 b' var IPython = (function (IPython) {' | |||
|
48 | 49 | }; |
|
49 | 50 | |
|
50 | 51 | //TODO, try to diminish the number of parameters. |
|
51 |
CodeCell.prototype.request_tooltip_after_time = function (pre_cursor,time |
|
|
52 | CodeCell.prototype.request_tooltip_after_time = function (pre_cursor,time){ | |
|
53 | var that = this; | |
|
52 | 54 | if (pre_cursor === "" || pre_cursor === "(" ) { |
|
53 | 55 | // don't do anything if line beggin with '(' or is empty |
|
54 | 56 | } else { |
@@ -74,8 +76,7 b' var IPython = (function (IPython) {' | |||
|
74 | 76 | // whatever key is pressed, first, cancel the tooltip request before |
|
75 | 77 | // they are sent, and remove tooltip if any |
|
76 | 78 | if(event.type === 'keydown' ){ |
|
77 |
|
|
|
78 | that.tooltip_timeout=null; | |
|
79 | that.remove_and_cancel_tooltip(); | |
|
79 | 80 | } |
|
80 | 81 | |
|
81 | 82 | if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) { |
@@ -87,7 +88,7 b' var IPython = (function (IPython) {' | |||
|
87 | 88 | // Pressing '(' , request tooltip, don't forget to reappend it |
|
88 | 89 | var cursor = editor.getCursor(); |
|
89 | 90 | var pre_cursor = editor.getRange({line:cursor.line,ch:0},cursor).trim()+'('; |
|
90 |
|
|
|
91 | that.request_tooltip_after_time(pre_cursor,tooltip_wait_time); | |
|
91 | 92 | } else if (event.keyCode === 9 && event.type == 'keydown') { |
|
92 | 93 | // Tab completion. |
|
93 | 94 | var cur = editor.getCursor(); |
@@ -98,7 +99,7 b' var IPython = (function (IPython) {' | |||
|
98 | 99 | // is empty. In this case, let CodeMirror handle indentation. |
|
99 | 100 | return false; |
|
100 | 101 | } else if ((pre_cursor.substr(-1) === "("|| pre_cursor.substr(-1) === " ") && tooltip_on_tab ) { |
|
101 |
|
|
|
102 | that.request_tooltip_after_time(pre_cursor,0); | |
|
102 | 103 | } else { |
|
103 | 104 | pre_cursor.trim(); |
|
104 | 105 | // Autocomplete the current line. |
@@ -145,14 +146,15 b' var IPython = (function (IPython) {' | |||
|
145 | 146 | return false; |
|
146 | 147 | }; |
|
147 | 148 | |
|
148 |
CodeCell.prototype.remove_and_cancel_tooltip = function( |
|
|
149 | { | |
|
149 | CodeCell.prototype.remove_and_cancel_tooltip = function() { | |
|
150 | 150 | // note that we don't handle closing directly inside the calltip |
|
151 | 151 | // as in the completer, because it is not focusable, so won't |
|
152 | 152 | // get the event. |
|
153 | if(timeout != null) | |
|
154 |
|
|
|
155 | $('#tooltip').remove(); | |
|
153 | if (this.tooltip_timeout != null){ | |
|
154 | clearTimeout(this.tooltip_timeout); | |
|
155 | $('#tooltip').remove(); | |
|
156 | this.tooltip_timeout = null; | |
|
157 | } | |
|
156 | 158 | } |
|
157 | 159 | |
|
158 | 160 | CodeCell.prototype.finish_tooltip = function (reply) { |
@@ -194,7 +196,7 b' var IPython = (function (IPython) {' | |||
|
194 | 196 | morelink.click(function(){ |
|
195 | 197 | var msg_id = IPython.notebook.kernel.execute(name+"?"); |
|
196 | 198 | IPython.notebook.msg_cell_map[msg_id] = IPython.notebook.selected_cell().cell_id; |
|
197 |
|
|
|
199 | that.remove_and_cancel_tooltip(); | |
|
198 | 200 | setTimeout(function(){that.code_mirror.focus();}, 50); |
|
199 | 201 | }); |
|
200 | 202 | |
@@ -208,7 +210,7 b' var IPython = (function (IPython) {' | |||
|
208 | 210 | closespan.addClass('ui-icon-close'); |
|
209 | 211 | closelink.append(closespan); |
|
210 | 212 | closelink.click(function(){ |
|
211 |
|
|
|
213 | that.remove_and_cancel_tooltip(); | |
|
212 | 214 | setTimeout(function(){that.code_mirror.focus();}, 50); |
|
213 | 215 | }); |
|
214 | 216 | //construct the tooltip |
@@ -227,7 +229,7 b' var IPython = (function (IPython) {' | |||
|
227 | 229 | |
|
228 | 230 | // issues with cross-closing if multiple tooltip in less than 5sec |
|
229 | 231 | // keep it comented for now |
|
230 |
// setTimeout( |
|
|
232 | // setTimeout(that.remove_and_cancel_tooltip, 5000); | |
|
231 | 233 | }; |
|
232 | 234 | |
|
233 | 235 | // As you type completer |
@@ -289,7 +291,7 b' var IPython = (function (IPython) {' | |||
|
289 | 291 | console.log('Ok, you really want to complete after pressing tab '+this.npressed+' times !'); |
|
290 | 292 | console.log('You should understand that there is no (more) completion for that !'); |
|
291 | 293 | console.log("I'll show you the tooltip, will you stop bothering me ?"); |
|
292 |
this.request_tooltip_after_time(matched_text+'(',0 |
|
|
294 | this.request_tooltip_after_time(matched_text+'(',0); | |
|
293 | 295 | return; |
|
294 | 296 | } |
|
295 | 297 | this.prevmatch=matched_text |
General Comments 0
You need to be logged in to leave comments.
Login now