From ec9daeb39529bebe873c6f4e9af1c2a18089c964 Mon Sep 17 00:00:00 2001 From: Pasi Eronen Date: Fri, 29 Aug 2014 13:36:10 +0300 Subject: [PATCH 1/5] Update karma version so that build works again --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b4e6b2..1e7b4c5 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "requirejs": "~2.1.10", "karma-requirejs": "~0.2.1", "karma-phantomjs-launcher": "~0.1.1", - "karma": "~0.10.9", + "karma": "~0.12.8", "karma-mocha": "~0.1.1", "karma-coverage": "~0.1.5" } From 9c6ea75a481eb0e6177f1d107889fa4bca40d8b4 Mon Sep 17 00:00:00 2001 From: Pasi Eronen Date: Fri, 29 Aug 2014 13:37:31 +0300 Subject: [PATCH 2/5] Don't depend on some random globally installed version of coffee-script and uglify-js --- Cakefile | 6 +++--- package.json | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Cakefile b/Cakefile index 8c3a330..2a2eece 100644 --- a/Cakefile +++ b/Cakefile @@ -1,15 +1,15 @@ {spawn, exec} = require 'child_process' task 'watch', 'Build and watch the CoffeeScript source files', -> - coffee = spawn 'coffee', ['-cw', '-o', 'lib', 'src'] - test = spawn 'coffee', ['-cw', 'test'] + coffee = spawn 'node_modules/coffee-script/bin/coffee', ['-cw', '-o', 'lib', 'src'] + test = spawn 'node_modules/coffee-script/bin/coffee', ['-cw', 'test'] log = (d)-> console.log d.toString() coffee.stdout.on 'data', log test.stdout.on 'data', log task 'build', 'Build minified file with uglify', -> console.log 'building...' - exec 'uglifyjs -m -o jqconsole.min.js lib/jqconsole.js', (err, res)-> + exec './node_modules/uglify-js/bin/uglifyjs -m -o jqconsole.min.js lib/jqconsole.js', (err, res)-> if err console.error 'failed with', err else diff --git a/package.json b/package.json index 1e7b4c5..3c3d57e 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,8 @@ "karma-phantomjs-launcher": "~0.1.1", "karma": "~0.12.8", "karma-mocha": "~0.1.1", - "karma-coverage": "~0.1.5" + "karma-coverage": "~0.1.5", + "coffee-script": "~1.6.3", + "uglify-js": "~2.4.15" } } From 1a08325b6d1746bda1e339d03cc13210d1340821 Mon Sep 17 00:00:00 2001 From: Pasi Eronen Date: Fri, 29 Aug 2014 16:09:14 +0300 Subject: [PATCH 3/5] Ignore generated .js under test/ --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ba2a97b..0e6f827 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules coverage +test/*.js From 06e61f746ab4a90ab88badad8713494b00d21485 Mon Sep 17 00:00:00 2001 From: Pasi Eronen Date: Fri, 29 Aug 2014 16:11:30 +0300 Subject: [PATCH 4/5] Handle AltGr (non-US keyboards) on Windows Chrome/IE properly, fix #64 --- src/jqconsole.coffee | 2 +- test/setup.coffee | 3 ++- test/shortcuts-test.coffee | 13 ++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/jqconsole.coffee b/src/jqconsole.coffee index 5621b3b..98f1f35 100644 --- a/src/jqconsole.coffee +++ b/src/jqconsole.coffee @@ -771,7 +771,7 @@ class JQConsole # We let the browser take over during output mode. # Skip everything when a modifier key other than shift is held. # Allow alt key to pass through for unicode & multibyte characters. - if @state == STATE_OUTPUT or event.metaKey or event.ctrlKey + if @state == STATE_OUTPUT or event.metaKey or (event.ctrlKey and !event.altKey) return true # IE & Chrome capture non-control characters and Enter. diff --git a/test/setup.coffee b/test/setup.coffee index 1a28c62..efdb2c5 100644 --- a/test/setup.coffee +++ b/test/setup.coffee @@ -13,9 +13,10 @@ window.jqconsoleSetup = -> $container.appendTo('body') jqconsole = new JQConsole($container, 'header', 'prompt_label', 'prompt_continue') typer = - typeA: -> + typeA: (options = {}) -> e = $.Event('keypress') e.which = 'a'.charCodeAt(0) + e[k] = v for k, v of options jqconsole.$input_source.trigger e keyDown: (code, options = {}) -> diff --git a/test/shortcuts-test.coffee b/test/shortcuts-test.coffee index 647f7ae..6bf64a5 100644 --- a/test/shortcuts-test.coffee +++ b/test/shortcuts-test.coffee @@ -1,4 +1,4 @@ -{jqconsole, typer: {keyDown}} = jqconsoleSetup() +{jqconsole, typer: {typeA, keyDown}} = jqconsoleSetup() describe 'Shortcuts', -> describe '#RegisterShortcut', -> @@ -58,3 +58,14 @@ describe 'Shortcuts', -> counter++ keyDown 'a'.charCodeAt(0), metaKey: on ok counter + + it 'altgr inputs character instead of invoking shortcut', -> + jqconsole.Prompt true, -> + counter = 0 + jqconsole.RegisterShortcut 'a', -> + strictEqual this, jqconsole + counter++ + keyDown 'a'.charCodeAt(0), ctrlKey: on, altKey: on + typeA(altKey: on, ctrlKey: on) + equal counter, 0 + equal jqconsole.$prompt.text().trim(), 'prompt_labela' From d2238f6311c4bc84a5a705760194d94b201a7673 Mon Sep 17 00:00:00 2001 From: Pasi Eronen Date: Tue, 30 Sep 2014 14:51:11 +0300 Subject: [PATCH 5/5] Re-build js and min.js files --- jqconsole.min.js | 2 +- lib/jqconsole.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jqconsole.min.js b/jqconsole.min.js index 107e23d..0c3a7fd 100644 --- a/jqconsole.min.js +++ b/jqconsole.min.js @@ -1 +1 @@ -(function(){var t,e,i,s,r,o,n,h,p,c,a,l,u,_,f,m,d,$,y,v,g,x,b,k,w,C,T,S,M,P,H,E,L,I,W,D,A,R=function(t,e){return function(){return t.apply(e,arguments)}},U=[].slice;t=jQuery;I=0;W=1;D=2;w=13;H=9;x=46;g=8;T=37;P=39;E=38;b=40;C=36;k=35;M=33;S=34;p="jqconsole-";r=""+p+"cursor";o=""+p+"header";c=""+p+"prompt";h=""+p+"old-prompt";n=""+p+"input";s=""+p+"blurred";y="keypress";m="";_="
";f=":empty";L="\n";u=">>> ";l="... ";a=2;i=""+p+"ansi-";d="";$=/\[(\d*)(?:;(\d*))*m/;e=function(){t.prototype.COLORS=["black","red","green","yellow","blue","magenta","cyan","white"];function t(){this.stylize=R(this.stylize,this);this._closeSpan=R(this._closeSpan,this);this._openSpan=R(this._openSpan,this);this.getClasses=R(this.getClasses,this);this._style=R(this._style,this);this._color=R(this._color,this);this._remove=R(this._remove,this);this._append=R(this._append,this);this.klasses=[]}t.prototype._append=function(t){t=""+i+t;if(this.klasses.indexOf(t)===-1){return this.klasses.push(t)}};t.prototype._remove=function(){var t,e,s,r,o,n;s=1<=arguments.length?U.call(arguments,0):[];n=[];for(r=0,o=s.length;r'+t};t.prototype._closeSpan=function(t){return""+t+""};t.prototype.stylize=function(t){var e,i,s,r,o,n;t=this._openSpan(t);s=0;while((s=t.indexOf(d,s))&&s!==-1){if(i=t.slice(s).match($)){n=i.slice(1);for(r=0,o=n.length;r'+(e||"")+""};v=function(){function i(i,s,r,n){this._HideComposition=R(this._HideComposition,this);this._ShowComposition=R(this._ShowComposition,this);this._UpdateComposition=R(this._UpdateComposition,this);this._EndComposition=R(this._EndComposition,this);this._StartComposition=R(this._StartComposition,this);this._CheckComposition=R(this._CheckComposition,this);this._ProcessMatch=R(this._ProcessMatch,this);this._HandleKey=R(this._HandleKey,this);this._HandleChar=R(this._HandleChar,this);this.isMobile=!!navigator.userAgent.match(/iPhone|iPad|iPod|Android/i);this.isIos=!!navigator.userAgent.match(/iPhone|iPad|iPod/i);this.isAndroid=!!navigator.userAgent.match(/Android/i);this.$window=t(window);this.header=s||"";this.prompt_label_main=typeof r==="string"?r:u;this.prompt_label_continue=n||l;this.indent_width=a;this.state=W;this.input_queue=[];this.input_callback=null;this.multiline_callback=null;this.history=[];this.history_index=0;this.history_new="";this.history_active=false;this.shortcuts={};this.$container=t("
").appendTo(i);this.$container.css({top:0,left:0,right:0,bottom:0,position:"absolute",overflow:"auto"});this.$console=t('
').appendTo(this.$container);this.$console.css({margin:0,position:"relative","min-height":"100%","box-sizing":"border-box","-moz-box-sizing":"border-box","-webkit-box-sizing":"border-box"});this.$console_focused=true;this.$input_container=t(_).appendTo(this.$container);this.$input_container.css({position:"absolute",width:1,height:0,overflow:"hidden"});this.$input_source=this.isAndroid?t(""):t("