##// END OF EJS Templates
Factorise code in tooltip for julia monkeypatching
Matthias BUSSONNIER -
Show More
@@ -196,7 +196,10 b' var IPython = (function (IPython) {'
196 }, that.time_before_tooltip);
196 }, that.time_before_tooltip);
197 }
197 }
198
198
199 Tooltip.prototype._request_tooltip = function (cell, func) {
199 // easy access for julia monkey patching.
200 Tooltip.last_token_re = /[a-z_][0-9a-z._]+$/gi;
201
202 Tooltip.prototype.extract_oir_token = function(line){
200 // use internally just to make the request to the kernel
203 // use internally just to make the request to the kernel
201 // Feel free to shorten this logic if you are better
204 // Feel free to shorten this logic if you are better
202 // than me in regEx
205 // than me in regEx
@@ -205,21 +208,25 b' var IPython = (function (IPython) {'
205 // remove everything between matchin bracket (need to iterate)
208 // remove everything between matchin bracket (need to iterate)
206 var matchBracket = /\([^\(\)]+\)/g;
209 var matchBracket = /\([^\(\)]+\)/g;
207 var endBracket = /\([^\(]*$/g;
210 var endBracket = /\([^\(]*$/g;
208 var oldfunc = func;
211 var oldline = line;
209
212
210 func = func.replace(matchBracket, "");
213 line = line.replace(matchBracket, "");
211 while (oldfunc != func) {
214 while (oldline != line) {
212 oldfunc = func;
215 oldline = line;
213 func = func.replace(matchBracket, "");
216 line = line.replace(matchBracket, "");
214 }
217 }
215 // remove everything after last open bracket
218 // remove everything after last open bracket
216 func = func.replace(endBracket, "");
219 line = line.replace(endBracket, "");
220 return Tooltip.last_token_re.exec(line)
221 }
222
217
223
218 var re = /[a-z_][0-9a-z._]+$/gi; // casse insensitive
224 Tooltip.prototype._request_tooltip = function (cell, line) {
219 var callbacks = {
225 var callbacks = {
220 'object_info_reply': $.proxy(this._show, this)
226 'object_info_reply': $.proxy(this._show, this)
221 }
227 }
222 var msg_id = cell.kernel.object_info_request(re.exec(func), callbacks);
228 var oir_token = this.extract_oir_token(line)
229 cell.kernel.object_info_request(oir_token, callbacks);
223 }
230 }
224
231
225 // make an imediate completion request
232 // make an imediate completion request
General Comments 0
You need to be logged in to leave comments. Login now