Show More
@@ -218,7 +218,7 var IPython = (function (IPython) { | |||||
218 | tooltip.append(expandlink); |
|
218 | tooltip.append(expandlink); | |
219 | tooltip.append(morelink); |
|
219 | tooltip.append(morelink); | |
220 | if(defstring){ |
|
220 | if(defstring){ | |
221 | defstring_html= $('<pre/>').html(utils.fixConsole(defstring)); |
|
221 | defstring_html = $('<pre/>').html(utils.fixConsole(defstring)); | |
222 | tooltip.append(defstring_html); |
|
222 | tooltip.append(defstring_html); | |
223 | } |
|
223 | } | |
224 | tooltip.append(pre); |
|
224 | tooltip.append(pre); | |
@@ -253,9 +253,9 var IPython = (function (IPython) { | |||||
253 | }, |
|
253 | }, | |
254 | dismissAndAppend : function (code) |
|
254 | dismissAndAppend : function (code) | |
255 | { |
|
255 | { | |
256 | chararr=['(',')','[',']','+','-','/','\\','.']; |
|
256 | chararr = ['(',')','[',']','+','-','/','\\','.']; | |
257 | codearr=chararr.map(function(x){return x.charCodeAt(0)}); |
|
257 | codearr = chararr.map(function(x){return x.charCodeAt(0)}); | |
258 | return jQuery.inArray(code, codearr)!=-1; |
|
258 | return jQuery.inArray(code, codearr) != -1; | |
259 | } |
|
259 | } | |
260 |
|
260 | |||
261 | } |
|
261 | } | |
@@ -266,25 +266,25 var IPython = (function (IPython) { | |||||
266 | { |
|
266 | { | |
267 | kwargs = new Array(); |
|
267 | kwargs = new Array(); | |
268 | other = new Array(); |
|
268 | other = new Array(); | |
269 | for(var i=0;i<matches.length; ++i){ |
|
269 | for(var i = 0 ; i<matches.length ; ++i){ | |
270 | if(matches[i].substr(-1) === '='){ |
|
270 | if(matches[i].substr(-1) === '='){ | |
271 | kwargs.push(matches[i]); |
|
271 | kwargs.push(matches[i]); | |
272 | }else{other.push(matches[i]);} |
|
272 | }else{other.push(matches[i]);} | |
273 | } |
|
273 | } | |
274 | newm = kwargs.concat(other); |
|
274 | newm = kwargs.concat(other); | |
275 | matches=newm; |
|
275 | matches = newm; | |
276 | } |
|
276 | } | |
277 | // end sort kwargs |
|
277 | // end sort kwargs | |
278 |
|
278 | |||
279 | // give common prefix of a array of string |
|
279 | // give common prefix of a array of string | |
280 | function sharedStart(A){ |
|
280 | function sharedStart(A){ | |
281 | if(A.length > 1 ){ |
|
281 | if(A.length > 1 ){ | |
282 | var tem1, tem2, s, A= A.slice(0).sort(); |
|
282 | var tem1, tem2, s, A = A.slice(0).sort(); | |
283 | tem1= A[0]; |
|
283 | tem1 = A[0]; | |
284 | s= tem1.length; |
|
284 | s = tem1.length; | |
285 | tem2= A.pop(); |
|
285 | tem2 = A.pop(); | |
286 | while(s && tem2.indexOf(tem1)== -1){ |
|
286 | while(s && tem2.indexOf(tem1) == -1){ | |
287 | tem1= tem1.substring(0, --s); |
|
287 | tem1 = tem1.substring(0, --s); | |
288 | } |
|
288 | } | |
289 | return tem1; |
|
289 | return tem1; | |
290 | } |
|
290 | } | |
@@ -294,8 +294,8 var IPython = (function (IPython) { | |||||
294 |
|
294 | |||
295 | //try to check if the user is typing tab at least twice after a word |
|
295 | //try to check if the user is typing tab at least twice after a word | |
296 | // and completion is "done" |
|
296 | // and completion is "done" | |
297 | fallback_on_tooltip_after=2 |
|
297 | fallback_on_tooltip_after = 2 | |
298 | if(matches.length==1 && matched_text === matches[0]) |
|
298 | if(matches.length == 1 && matched_text === matches[0]) | |
299 | { |
|
299 | { | |
300 | if(this.npressed >fallback_on_tooltip_after && this.prevmatch==matched_text) |
|
300 | if(this.npressed >fallback_on_tooltip_after && this.prevmatch==matched_text) | |
301 | { |
|
301 | { | |
@@ -305,13 +305,13 var IPython = (function (IPython) { | |||||
305 | this.request_tooltip_after_time(matched_text+'(',0); |
|
305 | this.request_tooltip_after_time(matched_text+'(',0); | |
306 | return; |
|
306 | return; | |
307 | } |
|
307 | } | |
308 | this.prevmatch=matched_text |
|
308 | this.prevmatch = matched_text | |
309 | this.npressed=this.npressed+1; |
|
309 | this.npressed = this.npressed+1; | |
310 | } |
|
310 | } | |
311 | else |
|
311 | else | |
312 | { |
|
312 | { | |
313 | this.prevmatch=""; |
|
313 | this.prevmatch = ""; | |
314 | this.npressed=0; |
|
314 | this.npressed = 0; | |
315 | } |
|
315 | } | |
316 | // end fallback on tooltip |
|
316 | // end fallback on tooltip | |
317 | //================================== |
|
317 | //================================== | |
@@ -324,7 +324,7 var IPython = (function (IPython) { | |||||
324 | var close = function () { |
|
324 | var close = function () { | |
325 | if (done) return; |
|
325 | if (done) return; | |
326 | done = true; |
|
326 | done = true; | |
327 | if (complete!=undefined) |
|
327 | if (complete != undefined) | |
328 | {complete.remove();} |
|
328 | {complete.remove();} | |
329 | that.is_completing = false; |
|
329 | that.is_completing = false; | |
330 | that.completion_cursor = null; |
|
330 | that.completion_cursor = null; | |
@@ -361,13 +361,13 var IPython = (function (IPython) { | |||||
361 | // Used to 'pick' when pressing tab |
|
361 | // Used to 'pick' when pressing tab | |
362 | if (matches.length < 1) { |
|
362 | if (matches.length < 1) { | |
363 | insert(typed_text,event); |
|
363 | insert(typed_text,event); | |
364 | if(event !=null){ |
|
364 | if(event != null){ | |
365 | event.stopPropagation(); |
|
365 | event.stopPropagation(); | |
366 | event.preventDefault(); |
|
366 | event.preventDefault(); | |
367 | } |
|
367 | } | |
368 | } else if (autopick && matches.length==1) { |
|
368 | } else if (autopick && matches.length == 1) { | |
369 | insert(matches[0],event); |
|
369 | insert(matches[0],event); | |
370 | if(event !=null){ |
|
370 | if(event != null){ | |
371 | event.stopPropagation(); |
|
371 | event.stopPropagation(); | |
372 | event.preventDefault(); |
|
372 | event.preventDefault(); | |
373 | } |
|
373 | } | |
@@ -375,8 +375,8 var IPython = (function (IPython) { | |||||
375 | //clear the previous completion if any |
|
375 | //clear the previous completion if any | |
376 | complete.children().children().remove(); |
|
376 | complete.children().children().remove(); | |
377 | $('#asyoutype').text(typed_text); |
|
377 | $('#asyoutype').text(typed_text); | |
378 | select=$('#asyoutypeselect'); |
|
378 | select = $('#asyoutypeselect'); | |
379 | for (var i=0; i<matches.length; ++i) { |
|
379 | for (var i = 0; i<matches.length; ++i) { | |
380 | select.append($('<option/>').html(matches[i])); |
|
380 | select.append($('<option/>').html(matches[i])); | |
381 | } |
|
381 | } | |
382 | select.children().first().attr('selected','true'); |
|
382 | select.children().first().attr('selected','true'); | |
@@ -403,18 +403,18 var IPython = (function (IPython) { | |||||
403 | // So a first actual completion. see if all the completion start wit |
|
403 | // So a first actual completion. see if all the completion start wit | |
404 | // the same letter and complete if necessary |
|
404 | // the same letter and complete if necessary | |
405 | fastForward = sharedStart(matches) |
|
405 | fastForward = sharedStart(matches) | |
406 | typed_characters= fastForward.substr(matched_text.length); |
|
406 | typed_characters = fastForward.substr(matched_text.length); | |
407 | complete_with(matches,matched_text+typed_characters,true,null); |
|
407 | complete_with(matches,matched_text+typed_characters,true,null); | |
408 | filterd=matches; |
|
408 | filterd = matches; | |
409 | // Give focus to select, and make it filter the match as the user type |
|
409 | // Give focus to select, and make it filter the match as the user type | |
410 | // by filtering the previous matches. Called by .keypress and .keydown |
|
410 | // by filtering the previous matches. Called by .keypress and .keydown | |
411 | var downandpress = function (event,press_or_down) { |
|
411 | var downandpress = function (event,press_or_down) { | |
412 | var code = event.which; |
|
412 | var code = event.which; | |
413 | var autopick = false; // auto 'pick' if only one match |
|
413 | var autopick = false; // auto 'pick' if only one match | |
414 | if (press_or_down === 0){ |
|
414 | if (press_or_down === 0){ | |
415 | press=true; down=false; //Are we called from keypress or keydown |
|
415 | press = true; down = false; //Are we called from keypress or keydown | |
416 | } else if (press_or_down == 1){ |
|
416 | } else if (press_or_down == 1){ | |
417 | press=false; down=true; |
|
417 | press = false; down = true; | |
418 | } |
|
418 | } | |
419 | if (code === key.shift) { |
|
419 | if (code === key.shift) { | |
420 | // nothing on Shift |
|
420 | // nothing on Shift | |
@@ -422,7 +422,7 var IPython = (function (IPython) { | |||||
422 | } |
|
422 | } | |
423 | if (key.dismissAndAppend(code) && press) { |
|
423 | if (key.dismissAndAppend(code) && press) { | |
424 | var newchar = String.fromCharCode(code); |
|
424 | var newchar = String.fromCharCode(code); | |
425 | typed_characters=typed_characters+newchar; |
|
425 | typed_characters = typed_characters+newchar; | |
426 | insert(matched_text+typed_characters,event); |
|
426 | insert(matched_text+typed_characters,event); | |
427 | return |
|
427 | return | |
428 | } |
|
428 | } | |
@@ -435,16 +435,16 var IPython = (function (IPython) { | |||||
435 | // We don't want the document keydown handler to handle UP/DOWN, |
|
435 | // We don't want the document keydown handler to handle UP/DOWN, | |
436 | // but we want the default action. |
|
436 | // but we want the default action. | |
437 | event.stopPropagation(); |
|
437 | event.stopPropagation(); | |
438 | } else if ( (code==key.backspace)||(code==key.tab && down) || press || key.isCompSymbol(code)){ |
|
438 | } else if ( (code == key.backspace)||(code == key.tab && down) || press || key.isCompSymbol(code)){ | |
439 | if( key.isCompSymbol(code) && press) |
|
439 | if( key.isCompSymbol(code) && press) | |
440 | { |
|
440 | { | |
441 | var newchar = String.fromCharCode(code); |
|
441 | var newchar = String.fromCharCode(code); | |
442 | typed_characters=typed_characters+newchar; |
|
442 | typed_characters = typed_characters+newchar; | |
443 | } else if (code == key.tab) { |
|
443 | } else if (code == key.tab) { | |
444 | fastForward = sharedStart(filterd) |
|
444 | fastForward = sharedStart(filterd) | |
445 | ffsub = fastForward.substr(matched_text.length+typed_characters.length); |
|
445 | ffsub = fastForward.substr(matched_text.length+typed_characters.length); | |
446 | typed_characters=typed_characters+ffsub; |
|
446 | typed_characters = typed_characters+ffsub; | |
447 | autopick=true; |
|
447 | autopick = true; | |
448 | event.stopPropagation(); |
|
448 | event.stopPropagation(); | |
449 | event.preventDefault(); |
|
449 | event.preventDefault(); | |
450 | } else if (code == key.backspace && down) { |
|
450 | } else if (code == key.backspace && down) { | |
@@ -455,17 +455,17 var IPython = (function (IPython) { | |||||
455 | insert(matched_text,event) |
|
455 | insert(matched_text,event) | |
456 | return |
|
456 | return | |
457 | } |
|
457 | } | |
458 | typed_characters=typed_characters.substr(0,typed_characters.length-1); |
|
458 | typed_characters = typed_characters.substr(0,typed_characters.length-1); | |
459 | } else if (press && code != key.backspace && code != key.tab && code != 0){ |
|
459 | } else if (press && code != key.backspace && code != key.tab && code != 0){ | |
460 | insert(matched_text+typed_characters,event); |
|
460 | insert(matched_text+typed_characters,event); | |
461 | return |
|
461 | return | |
462 | } else { |
|
462 | } else { | |
463 | return |
|
463 | return | |
464 | } |
|
464 | } | |
465 | re = new RegExp("^"+"\%?"+matched_text+typed_characters,""); |
|
465 | re = new RegExp("^"+"\%?"+matched_text+typed_characters,""); | |
466 | filterd = matches.filter(function(x){return re.test(x)}); |
|
466 | filterd = matches.filter(function(x){return re.test(x)}); | |
467 | complete_with(filterd,matched_text+typed_characters,autopick,event); |
|
467 | complete_with(filterd,matched_text+typed_characters,autopick,event); | |
468 | } else if( press || code==key.esc){ // abort only on .keypress or esc |
|
468 | } else if( press || code == key.esc){ // abort only on .keypress or esc | |
469 | // abort with what the user have pressed until now |
|
469 | // abort with what the user have pressed until now | |
470 | console.log('aborting with keycode : '+code+' is down :'+down); |
|
470 | console.log('aborting with keycode : '+code+' is down :'+down); | |
471 | insert(matched_text+typed_characters,event); |
|
471 | insert(matched_text+typed_characters,event); |
General Comments 0
You need to be logged in to leave comments.
Login now