##// END OF EJS Templates
usability and cross browser compat for completer...
Matthias BUSSONNIER -
Show More
@@ -244,9 +244,20 b' var IPython = (function (IPython) {'
244 space:13,
244 space:13,
245 shift:16,
245 shift:16,
246 enter:32,
246 enter:32,
247 // _ is 189
247 // _ is 95
248 isCompSymbol : function (code)
248 isCompSymbol : function (code)
249 {return ((code>64 && code <=122)|| code == 189)}
249 {
250 return (code > 64 && code <= 90)
251 || (code >= 97 && code <= 122)
252 || (code == 95)
253 },
254 dismissAndAppend : function (code)
255 {
256 chararr=['(',')','[',']','+','-','/','\\','.'];
257 codearr=chararr.map(function(x){return x.charCodeAt(0)});
258 return jQuery.inArray(code, codearr)!=-1;
259 }
260
250 }
261 }
251
262
252 // smart completion, sort kwarg ending with '='
263 // smart completion, sort kwarg ending with '='
@@ -409,6 +420,12 b' var IPython = (function (IPython) {'
409 // nothing on Shift
420 // nothing on Shift
410 return;
421 return;
411 }
422 }
423 if (key.dismissAndAppend(code) && press) {
424 var newchar = String.fromCharCode(code);
425 typed_characters=typed_characters+newchar;
426 insert(matched_text+typed_characters,event);
427 return
428 }
412 if (code === key.space || code === key.enter) {
429 if (code === key.space || code === key.enter) {
413 // Pressing SPACE or ENTER will cause a pick
430 // Pressing SPACE or ENTER will cause a pick
414 event.stopPropagation();
431 event.stopPropagation();
@@ -418,8 +435,7 b' var IPython = (function (IPython) {'
418 // 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,
419 // but we want the default action.
436 // but we want the default action.
420 event.stopPropagation();
437 event.stopPropagation();
421 //} else if ( key.isCompSymbol(code)|| (code==key.backspace)||(code==key.tab && down)){
438 } else if ( (code==key.backspace)||(code==key.tab && down) || press || key.isCompSymbol(code)){
422 } else if ( (code==key.backspace)||(code==key.tab && down) || press || key.isCompSymbol(code)){
423 if( key.isCompSymbol(code) && press)
439 if( key.isCompSymbol(code) && press)
424 {
440 {
425 var newchar = String.fromCharCode(code);
441 var newchar = String.fromCharCode(code);
@@ -437,13 +453,19 b' var IPython = (function (IPython) {'
437 if (typed_characters.length <= 0)
453 if (typed_characters.length <= 0)
438 {
454 {
439 insert(matched_text,event)
455 insert(matched_text,event)
456 return
440 }
457 }
441 typed_characters=typed_characters.substr(0,typed_characters.length-1);
458 typed_characters=typed_characters.substr(0,typed_characters.length-1);
442 }else{return}
459 } else if (press && code != key.backspace && code != key.tab && code != 0){
460 insert(matched_text+typed_characters,event);
461 return
462 } else {
463 return
464 }
443 re = new RegExp("^"+"\%?"+matched_text+typed_characters,"");
465 re = new RegExp("^"+"\%?"+matched_text+typed_characters,"");
444 filterd = matches.filter(function(x){return re.test(x)});
466 filterd = matches.filter(function(x){return re.test(x)});
445 complete_with(filterd,matched_text+typed_characters,autopick,event);
467 complete_with(filterd,matched_text+typed_characters,autopick,event);
446 } else if(down){ // abort only on .keydown
468 } else if( press || code==key.esc){ // abort only on .keypress or esc
447 // abort with what the user have pressed until now
469 // abort with what the user have pressed until now
448 console.log('aborting with keycode : '+code+' is down :'+down);
470 console.log('aborting with keycode : '+code+' is down :'+down);
449 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