Show More
@@ -233,6 +233,14 b' var IPython = (function (IPython) {' | |||||
233 | CodeCell.prototype.finish_completing = function (matched_text, matches) { |
|
233 | CodeCell.prototype.finish_completing = function (matched_text, matches) { | |
234 |
|
234 | |||
235 | // smart completion, sort kwarg ending with '=' |
|
235 | // smart completion, sort kwarg ending with '=' | |
|
236 | var key = { tab:9, | |||
|
237 | esc:8, | |||
|
238 | space:13, | |||
|
239 | shift:16, | |||
|
240 | enter:32, | |||
|
241 | // _ is 189 | |||
|
242 | isCompSymbol : function (code) {return ((code>64 && code <=122)|| code == 189)} | |||
|
243 | } | |||
236 | var newm = new Array(); |
|
244 | var newm = new Array(); | |
237 | if(this.notebook.smart_completer) |
|
245 | if(this.notebook.smart_completer) | |
238 | { |
|
246 | { | |
@@ -320,22 +328,20 b' var IPython = (function (IPython) {' | |||||
320 | insert(select.val()[0]); |
|
328 | insert(select.val()[0]); | |
321 | }; |
|
329 | }; | |
322 |
|
330 | |||
323 | // if only one match, complete to it, don't ask user |
|
|||
324 | if (matches.length === 1) { |
|
|||
325 | insert(matches[0]); |
|
|||
326 | return; |
|
|||
327 | }; |
|
|||
328 |
|
||||
329 |
|
331 | |||
330 | // Define function to clear the completer, refill it with the new |
|
332 | // Define function to clear the completer, refill it with the new | |
331 | // matches, update the pseuso typing field. Note that this is case |
|
333 | // matches, update the pseuso typing field. Note that this is case | |
332 | // insensitive for now |
|
334 | // insensitive for now | |
333 | var complete_with = function(matches,typed_text) |
|
335 | var complete_with = function(matches,typed_text,autopick) | |
334 | { |
|
336 | { | |
335 | //clear the previous completion if any |
|
337 | // If autopick an only one match, past. | |
|
338 | // Used to 'pick' when pressing tab | |||
336 | if (matches.length < 1) { |
|
339 | if (matches.length < 1) { | |
337 | insert(typed_text); |
|
340 | insert(typed_text); | |
|
341 | } else if (autopick && matches.length==1) { | |||
|
342 | insert(matches[0]); | |||
338 | } |
|
343 | } | |
|
344 | //clear the previous completion if any | |||
339 | complete.children().children().remove(); |
|
345 | complete.children().children().remove(); | |
340 | $('#asyoutype').text(typed_text); |
|
346 | $('#asyoutype').text(typed_text); | |
341 | select=$('#asyoutypeselect'); |
|
347 | select=$('#asyoutypeselect'); | |
@@ -364,25 +370,25 b' var IPython = (function (IPython) {' | |||||
364 | $('body').append(complete); |
|
370 | $('body').append(complete); | |
365 |
|
371 | |||
366 | //do a first actual completion |
|
372 | //do a first actual completion | |
367 | complete_with(matches,matched_text); |
|
373 | fastForward = sharedStart(matches) | |
368 |
|
374 | typed_characters= fastForward.substr(matched_text.length); | ||
|
375 | complete_with(matches,matched_text+typed_characters,true); | |||
|
376 | filterd=matches; | |||
369 | // Give focus to select, and make it filter the match as the user type |
|
377 | // Give focus to select, and make it filter the match as the user type | |
370 | // by filtering the previous matches |
|
378 | // by filtering the previous matches | |
371 | typed_characters = ""; |
|
|||
372 | var downandpress = function (event,press_or_down) { |
|
379 | var downandpress = function (event,press_or_down) { | |
|
380 | var code = event.which; | |||
|
381 | var autopick = false; // auto 'pick' if only one match | |||
373 | if (press_or_down === 0){ |
|
382 | if (press_or_down === 0){ | |
374 | press=true; |
|
383 | press=true; down=false; //Are we called from keypress or keydown | |
375 | down=false; |
|
|||
376 | } else if (press_or_down == 1){ |
|
384 | } else if (press_or_down == 1){ | |
377 | press=false; |
|
385 | press=false; down=true; | |
378 | down=true; |
|
|||
379 | } |
|
386 | } | |
380 |
|
|
387 | if (code === key.shift) { | |
381 | if (code === 16) { |
|
|||
382 | // nothing on Shift |
|
388 | // nothing on Shift | |
383 | return; |
|
389 | return; | |
384 | } |
|
390 | } | |
385 |
if (code === |
|
391 | if (code === key.space || code === key.enter) { | |
386 | // Pressing SPACE or ENTER will cause a pick |
|
392 | // Pressing SPACE or ENTER will cause a pick | |
387 | event.stopPropagation(); |
|
393 | event.stopPropagation(); | |
388 | event.preventDefault(); |
|
394 | event.preventDefault(); | |
@@ -391,20 +397,21 b' var IPython = (function (IPython) {' | |||||
391 | // We don't want the document keydown handler to handle UP/DOWN, |
|
397 | // We don't want the document keydown handler to handle UP/DOWN, | |
392 | // but we want the default action. |
|
398 | // but we want the default action. | |
393 | event.stopPropagation(); |
|
399 | event.stopPropagation(); | |
394 |
} else if ( |
|
400 | //} else if ( key.isCompSymbol(code)|| (code==key.backspace)||(code==key.tab && down)){ | |
|
401 | } else if ( (code==key.backspace)||(code==key.tab) || press || key.isCompSymbol(code)){ | |||
395 | // issues with _-.. on chrome at least |
|
402 | // issues with _-.. on chrome at least | |
396 |
if(code != |
|
403 | if((code != key.backspace) && (code != key.tab) && press) | |
397 | { |
|
404 | { | |
398 | var newchar = String.fromCharCode(code); |
|
405 | var newchar = String.fromCharCode(code); | |
399 | typed_characters=typed_characters+newchar; |
|
406 | typed_characters=typed_characters+newchar; | |
400 |
} else if (code == |
|
407 | } else if (code == key.tab) { | |
401 | fastForward = sharedStart(filterd) |
|
408 | fastForward = sharedStart(filterd) | |
402 | ffsub = fastForward.substr(matched_text.length+typed_characters.length); |
|
409 | ffsub = fastForward.substr(matched_text.length+typed_characters.length); | |
403 | typed_characters=typed_characters+ffsub; |
|
410 | typed_characters=typed_characters+ffsub; | |
404 | console.log("Fast forded by :"+ffsub); |
|
411 | autopick=true; | |
405 | event.stopPropagation(); |
|
412 | event.stopPropagation(); | |
406 | event.preventDefault(); |
|
413 | event.preventDefault(); | |
407 |
} else if (code == |
|
414 | } else if (code == key.backspace) { | |
408 | // 8 is backspace remove 1 char cancel if |
|
415 | // 8 is backspace remove 1 char cancel if | |
409 | // user have erase everything, otherwise |
|
416 | // user have erase everything, otherwise | |
410 | // decrease what we filter with |
|
417 | // decrease what we filter with | |
@@ -416,10 +423,10 b' var IPython = (function (IPython) {' | |||||
416 | } |
|
423 | } | |
417 | re = new RegExp("^"+"\%?"+matched_text+typed_characters,""); |
|
424 | re = new RegExp("^"+"\%?"+matched_text+typed_characters,""); | |
418 | filterd= matches.filter(function(x){return re.test(x)}); |
|
425 | filterd= matches.filter(function(x){return re.test(x)}); | |
419 | complete_with(filterd,matched_text+typed_characters); |
|
426 | complete_with(filterd,matched_text+typed_characters,autopick); | |
420 | } else if(down){ // abort only on press |
|
427 | } else if(down){ // abort only on press | |
421 | // abort with what the user have pressed until now |
|
428 | // abort with what the user have pressed until now | |
422 | console.log('aborting with keycode : '+code); |
|
429 | console.log('aborting with keycode : '+code+press); | |
423 | insert(matched_text+typed_characters); |
|
430 | insert(matched_text+typed_characters); | |
424 | } |
|
431 | } | |
425 | } |
|
432 | } |
@@ -171,7 +171,7 b' var IPython = (function (IPython) {' | |||||
171 | }; |
|
171 | }; | |
172 |
|
172 | |||
173 | Kernel.prototype.object_info_request = function (objname) { |
|
173 | Kernel.prototype.object_info_request = function (objname) { | |
174 | if(typeof(objname)!=null) |
|
174 | if(typeof(objname)!=null && objname!=null) | |
175 | { |
|
175 | { | |
176 | var content = { |
|
176 | var content = { | |
177 | oname : objname.toString(), |
|
177 | oname : objname.toString(), |
General Comments 0
You need to be logged in to leave comments.
Login now