diff --git a/IPython/html/static/notebook/js/keyboardmanager.js b/IPython/html/static/notebook/js/keyboardmanager.js index 757007d..150d8ab 100644 --- a/IPython/html/static/notebook/js/keyboardmanager.js +++ b/IPython/html/static/notebook/js/keyboardmanager.js @@ -120,16 +120,6 @@ define([ 'h' : 'ipython.show-keyboard-shortcut-help-dialog', 'z' : 'ipython.undo-last-cell-deletion', 'q' : 'ipython.close-pager', - 'i,e,e,e,e,e' : function(){console.log('[[===>>> 5E <<<===]]');}, - 'i,d,d,q,d' : function(){console.log('[[===>>> Trigger god mode <<<===]]');}, - 'i,d,d' : function(){console.log('[[===>>> should warn at registration <<<===]]');}, - 'i,d,k' : function(){console.log('[[===>>> Trigger shadow mode <<<===]]');}, - 'i,d,k,r,q' : function(){console.log('[[===>>> Trigger invisibility mode <<<===]]');}, - ';,up,down,up,down,left,right,left,right,b,a' : function(){console.log('[[===>>> Konami <<<===]]');}, - 'ctrl-x,meta-c,meta-b,u,t,t,e,r,f,l,y' : function(){ - console.log('[[Are you a real Programmer ?]]'); - window.open('http://xkcd.com/378/','_blank'); - }, }; }; diff --git a/IPython/html/tests/base/keyboard.js b/IPython/html/tests/base/keyboard.js index d74113f..0c50cf0 100644 --- a/IPython/html/tests/base/keyboard.js +++ b/IPython/html/tests/base/keyboard.js @@ -13,7 +13,9 @@ var to_normalize = [ var unshifted = "` 1 2 3 4 5 6 7 8 9 0 - = q w e r t y u i o p [ ] \\ a s d f g h j k l ; ' z x c v b n m , . /"; // shifted = '~ ! @ # $ % ^ & * ( ) _ + Q W E R T Y U I O P { } | A S D F G H J K L : " Z X C V B N M < > ?'; + casper.notebook_test(function () { + var that = this; this.then(function () { this.each(unshifted.split(' '), function (self, item) { @@ -46,4 +48,37 @@ casper.notebook_test(function () { }); }); + this.then(function(){ + + var shortcuts_test = { + 'i,e,e,e,e,e' : '[[5E]]', + 'i,d,d,q,d' : '[[TEST1]]', + 'i,d,d' : '[[TEST1 WILL BE SHADOWED]]', + 'i,d,k' : '[[SHOULD SHADOW TEST2]]', + 'i,d,k,r,q' : '[[TEST2 NOT SHADOWED]]', + ';,up,down,up,down,left,right,left,right,b,a' : '[[KONAMI]]', + 'ctrl-x,meta-c,meta-b,u,t,t,e,r,f,l,y' : '[[XKCD]]' + + }; + + that.msgs = []; + that.on('remote.message', function(msg) { + that.msgs.push(msg); + }) + that.evaluate(function (obj) { + for(var k in obj){ + IPython.keyboard_manager.command_shortcuts.add_shortcut(k, function(){console.log(obj[k])}); + } + }, shortcuts_test); + + var longer_first = false; + var longer_last = false; + for(var m in that.msgs){ + longer_first = longer_first||(that.msgs[m].match(/you are overriting/)!= null); + longer_last = longer_last ||(that.msgs[m].match(/will be shadowed/) != null); + } + this.test.assert(longer_first, 'no warnign if registering shorter shortut'); + this.test.assert(longer_last , 'no warnign if registering longer shortut'); + }) + });