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