diff --git a/jqconsole.min.js b/jqconsole.min.js
index 107e23d..d20306f 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("");this.$input_source.attr({wrap:"off",autocapitalize:"off",autocorrect:"off",spellcheck:"false",autocomplete:"off"});this.$input_source.css({position:"absolute",width:2});this.$input_source.appendTo(this.$input_container);this.$composition=t(_);this.$composition.addClass(""+p+"composition");this.$composition.css({display:"inline",position:"relative"});this.matchings={openings:{},closings:{},clss:[]};this.ansi=new e;this._InitPrompt();this._SetupEvents();this.Write(this.header,o);t(i).data("jqconsole",this)}i.prototype.ResetHistory=function(){return this.SetHistory([])};i.prototype.ResetShortcuts=function(){return this.shortcuts={}};i.prototype.ResetMatchings=function(){return this.matchings={openings:{},closings:{},clss:[]}};i.prototype.Reset=function(){if(this.state!==W){this.ClearPromptText(true)}this.state=W;this.input_queue=[];this.input_callback=null;this.multiline_callback=null;this.ResetHistory();this.ResetShortcuts();this.ResetMatchings();this.$prompt.detach();this.$input_container.detach();this.$console.html("");this.$prompt.appendTo(this.$console);this.$input_container.appendTo(this.$container);this.Write(this.header,o);return void 0};i.prototype.GetHistory=function(){return this.history};i.prototype.SetHistory=function(t){this.history=t.slice();return this.history_index=this.history.length};i.prototype._CheckKeyCode=function(t){if(isNaN(t)){t=t.charCodeAt(0)}else{t=parseInt(t,10)}if(!(0>> "))}else{o.push(t(i).text())}}return o}().join("")};i.prototype.GetState=function(){if(this.state===I){return"input"}else if(this.state===W){return"output"}else{return"prompt"}};i.prototype.Disable=function(){this.$input_source.attr("disabled",true);return this.$input_source.blur()};i.prototype.Enable=function(){return this.$input_source.attr("disabled",false)};i.prototype.IsDisabled=function(){return Boolean(this.$input_source.attr("disabled"))};i.prototype.MoveToStart=function(t){this._MoveTo(t,true);return void 0};i.prototype.MoveToEnd=function(t){this._MoveTo(t,false);return void 0};i.prototype.Clear=function(){this.$console.find("."+o).nextUntil("."+c).addBack().text("");this.$prompt_cursor.detach();return this.$prompt_after.before(this.$prompt_cursor)};i.prototype._CheckInputQueue=function(){if(this.input_queue.length){return this.input_queue.shift()()}};i.prototype._InitPrompt=function(){this.$prompt=t(A(n)).appendTo(this.$console);this.$prompt_before=t(m).appendTo(this.$prompt);this.$prompt_current=t(m).appendTo(this.$prompt);this.$prompt_after=t(m).appendTo(this.$prompt);this.$prompt_label=t(m).appendTo(this.$prompt_current);this.$prompt_left=t(m).appendTo(this.$prompt_current);this.$prompt_right=t(m).appendTo(this.$prompt_current);this.$prompt_right.css({position:"relative"});this.$prompt_cursor=t(A(r," "));this.$prompt_cursor.insertBefore(this.$prompt_right);this.$prompt_cursor.css({color:"transparent",display:"inline",zIndex:0});if(!this.isMobile){return this.$prompt_cursor.css("position","absolute")}};i.prototype._SetupEvents=function(){var t=this;if(this.isMobile){this.$console.click(function(e){e.preventDefault();return t.Focus()})}else{this.$console.mouseup(function(e){var i;if(e.which===2){return t.Focus()}else{i=function(){if(!window.getSelection().toString()){e.preventDefault();return t.Focus()}};return setTimeout(i,0)}})}this.$input_source.focus(function(){var e,i;t._ScrollToEnd();t.$console_focused=true;t.$console.removeClass(s);i=function(){if(t.$console_focused){return t.$console.removeClass(s)}};setTimeout(i,100);e=function(){if(t.isIos&&t.$console_focused){return t.$input_source.hide()}};return setTimeout(e,500)});this.$input_source.blur(function(){var e;t.$console_focused=false;if(t.isIos){t.$input_source.show()}e=function(){if(!t.$console_focused){return t.$console.addClass(s)}};return setTimeout(e,100)});this.$input_source.bind("paste",function(){var e;e=function(){if(t.in_composition){return}t._AppendPromptText(t.$input_source.val());t.$input_source.val("");return t.Focus()};return setTimeout(e,0)});this.$input_source.keypress(this._HandleChar);this.$input_source.keydown(this._HandleKey);this.$input_source.keydown(this._CheckComposition);this.$input_source.bind("compositionstart",this._StartComposition);this.$input_source.bind("compositionend",function(e){return setTimeout(function(){return t._EndComposition(e)},0)});if(this.isAndroid){this.$input_source.bind("input",this._StartComposition);return this.$input_source.bind("input",this._UpdateComposition)}else{return this.$input_source.bind("text",this._UpdateComposition)}};i.prototype._HandleChar=function(t){var e;if(this.state===W||t.metaKey||t.ctrlKey){return true}e=t.which;if(e===8||e===9||e===13){return false}this.$prompt_left.text(this.$prompt_left.text()+String.fromCharCode(e));this._ScrollToEnd();return false};i.prototype._HandleKey=function(e){var i;if(this.state===W){return true}i=e.keyCode||e.which;setTimeout(t.proxy(this._CheckMatchings,this),0);if(e.altKey){return true}else if(e.ctrlKey||e.metaKey){return this._HandleCtrlShortcut(i)}else if(e.shiftKey){switch(i){case w:this._HandleEnter(true);break;case H:this._Unindent();break;case E:this._MoveUp();break;case b:this._MoveDown();break;case M:this._ScrollPage("up");break;case S:this._ScrollPage("down");break;default:return true}return false}else{switch(i){case w:this._HandleEnter(false);break;case H:this._Indent();break;case x:this._Delete(false);break;case g:this._Backspace(false);break;case T:this._MoveLeft(false);break;case P:this._MoveRight(false);break;case E:this._HistoryPrevious();break;case b:this._HistoryNext();break;case C:this.MoveToStart(false);break;case k:this.MoveToEnd(false);break;case M:this._ScrollPage("up");break;case S:this._ScrollPage("down");break;default:return true}return false}};i.prototype._HandleCtrlShortcut=function(t){var e,i,s,r;switch(t){case x:this._Delete(true);break;case g:this._Backspace(true);break;case T:this._MoveLeft(true);break;case P:this._MoveRight(true);break;case E:this._MoveUp();break;case b:this._MoveDown();break;case k:this.MoveToEnd(true);break;case C:this.MoveToStart(true);break;default:if(t in this.shortcuts){r=this.shortcuts[t];for(i=0,s=r.length;ih;o=0<=h?++n:--n){if(t>0){c.push(s._Indent())}else{c.push(s._Unindent())}}return c}else{r=s.state===I?"input":"prompt";s.Write(s.GetPromptText(true)+L,""+p+"old-"+r);s.ClearPromptText(true);if(s.history_active){if(!s.history.length||s.history[s.history.length-1]!==i){s.history.push(i)}s.history_index=s.history.length}s.state=W;e=s.input_callback;s.input_callback=null;if(e){e(i)}return s._CheckInputQueue()}};if(this.multiline_callback){if(this.async_multiline){return this.multiline_callback(i,e)}else{return e(this.multiline_callback(i))}}else{return e(false)}}};i.prototype._GetDirectionals=function(e){var i,s,r,o,n,h,p,c;o=e?this.$prompt_left:this.$prompt_right;i=e?this.$prompt_right:this.$prompt_left;r=e?this.$prompt_before:this.$prompt_after;s=e?this.$prompt_after:this.$prompt_before;h=e?t.proxy(this.MoveToStart,this):t.proxy(this.MoveToEnd,this);n=e?t.proxy(this._MoveLeft,this):t.proxy(this._MoveRight,this);c=e?"last":"first";p=e?"prependTo":"appendTo";return{$prompt_which:o,$prompt_opposite:i,$prompt_relative:r,$prompt_rel_opposite:s,MoveToLimit:h,MoveDirection:n,which_end:c,where_append:p}};i.prototype._VerticalMove=function(t){var e,i,s,r,o,n,h,p;p=this._GetDirectionals(t),s=p.$prompt_which,e=p.$prompt_opposite,i=p.$prompt_relative,o=p.MoveToLimit,r=p.MoveDirection;if(i.is(f)){return}n=this.$prompt_left.text().length;o();r();h=s.text();e.text(t?h.slice(n):h.slice(0,n));return s.text(t?h.slice(0,n):h.slice(n))};i.prototype._MoveUp=function(){return this._VerticalMove(true)};i.prototype._MoveDown=function(){return this._VerticalMove()};i.prototype._HorizontalMove=function(e,i){var s,r,o,n,h,p,c,a,l,u,_,d,$,y;y=this._GetDirectionals(i),h=y.$prompt_which,r=y.$prompt_opposite,n=y.$prompt_relative,o=y.$prompt_rel_opposite,d=y.which_end,_=y.where_append;a=i?/\w*\W*$/:/^\w*\W*/;l=h.text();if(l){if(e){$=l.match(a);if(!$){return}$=$[0];u=r.text();r.text(i?$+u:u+$);c=$.length;return h.text(i?l.slice(0,-c):l.slice(c))}else{u=r.text();r.text(i?l.slice(-1)+u:u+l[0]);return h.text(i?l.slice(0,-1):l.slice(1))}}else if(!n.is(f)){p=t(m)[_](o);p.append(t(m).text(this.$prompt_label.text()));p.append(t(m).text(r.text()));s=n.children()[d]().detach();this.$prompt_label.text(s.children().first().text());h.text(s.children().last().text());return r.text("")}};i.prototype._MoveLeft=function(t){return this._HorizontalMove(t,true)};i.prototype._MoveRight=function(t){return this._HorizontalMove(t)};i.prototype._MoveTo=function(t,e){var i,s,r,o,n,h,p;h=this._GetDirectionals(e),r=h.$prompt_which,i=h.$prompt_opposite,s=h.$prompt_relative,n=h.MoveToLimit,o=h.MoveDirection;if(t){p=[];while(!(s.is(f)&&r.text()==="")){n(false);p.push(o(false))}return p}else{i.text(this.$prompt_left.text()+this.$prompt_right.text());return r.text("")}};i.prototype._Delete=function(t){var e,i,s;i=this.$prompt_right.text();if(i){if(t){s=i.match(/^\w*\W*/);if(!s){return}s=s[0];return this.$prompt_right.text(i.slice(s.length))}else{return this.$prompt_right.text(i.slice(1))}}else if(!this.$prompt_after.is(f)){e=this.$prompt_after.children().first().detach();return this.$prompt_right.text(e.children().last().text())}};i.prototype._Backspace=function(e){var i,s,r;setTimeout(t.proxy(this._ScrollToEnd,this),0);s=this.$prompt_left.text();if(s){if(e){r=s.match(/\w*\W*$/);if(!r){return}r=r[0];return this.$prompt_left.text(s.slice(0,-r.length))}else{return this.$prompt_left.text(s.slice(0,-1))}}else if(!this.$prompt_before.is(f)){i=this.$prompt_before.children().last().detach();this.$prompt_label.text(i.children().first().text());return this.$prompt_left.text(i.children().last().text())}};i.prototype._Indent=function(){var t;return this.$prompt_left.prepend(function(){var e,i,s;s=[];for(t=e=1,i=this.indent_width;1<=i?e<=i:e>=i;t=1<=i?++e:--e){s.push(" ")}return s}.call(this).join(""))};i.prototype._Unindent=function(){var t,e,i,s,r;t=this.$prompt_left.text()+this.$prompt_right.text();r=[];for(e=i=1,s=this.indent_width;1<=s?i<=s:i>=s;e=1<=s?++i:--i){if(!/^ /.test(t)){break}if(this.$prompt_left.text()){this.$prompt_left.text(this.$prompt_left.text().slice(1))}else{this.$prompt_right.text(this.$prompt_right.text().slice(1))}r.push(t=t.slice(1))}return r};i.prototype._InsertNewLine=function(e){var i,s,r;if(e==null){e=false}r=this._SelectPromptLabel(!this.$prompt_before.is(f));i=t(m).appendTo(this.$prompt_before);i.append(t(m).text(r));i.append(t(m).text(this.$prompt_left.text()));this.$prompt_label.text(this._SelectPromptLabel(true));if(e&&(s=this.$prompt_left.text().match(/^\s+/))){this.$prompt_left.text(s[0])}else{this.$prompt_left.text("")}return this._ScrollToEnd()};i.prototype._AppendPromptText=function(t){var e,i,s,r,o,n;i=t.split(L);this.$prompt_left.text(this.$prompt_left.text()+i[0]);o=i.slice(1);n=[];for(s=0,r=o.length;ss.top){return this.$window.scrollTop(i)}}else{if(o+ti){return this.$window.scrollTop(s.top)}}};i.prototype._SelectPromptLabel=function(t){if(this.state===D){if(t){return" \n"+this.prompt_label_continue}else{return this.prompt_label_main}}else{if(t){return"\n "}else{return" "}}};i.prototype._Wrap=function(t,e,i){var s,r;r=t.html();s=r.slice(0,e)+A(i,r[e])+r.slice(e+1);return t.html(s)};i.prototype._WalkCharacters=function(t,e,i,s,r){var o,n,h;n=r?t.length:0;t=t.split("");h=function(){var e,i,s,o;if(r){s=t,t=2<=s.length?U.call(s,0,i=s.length-1):(i=0,[]),e=s[i++]}else{o=t,e=o[0],t=2<=o.length?U.call(o,1):[]}if(e){n=n+(r?-1:+1)}return e};while(o=h()){if(o===e){s++}else if(o===i){s--}if(s===0){return{index:n,current_count:s}}}return{index:-1,current_count:s}};i.prototype._ProcessMatch=function(e,i,s){var r,o,n,h,p,c,a,l,u,_,f,m,d=this;_=i?[e["closing_char"],e["opening_char"]]:[e["opening_char"],e["closing_char"]],h=_[0],l=_[1];f=this._GetDirectionals(i),n=f.$prompt_which,o=f.$prompt_relative;p=1;c=false;u=n.html();if(!i){u=u.slice(1)}if(s&&i){u=u.slice(0,-1)}m=this._WalkCharacters(u,h,l,p,i),a=m.index,p=m.current_count;if(a>-1){this._Wrap(n,a,e.cls);c=true}else{r=o.children();r=i?Array.prototype.reverse.call(r):r;r.each(function(s,r){var o,n;o=t(r).children().last();u=o.html();n=d._WalkCharacters(u,h,l,p,i),a=n.index,p=n.current_count;if(a>-1){if(!i){a--}d._Wrap(o,a,e.cls);c=true;return false}})}return c};i.prototype._CheckMatchings=function(e){var i,s,r,o,n,h,p;r=e?this.$prompt_left.text().slice(this.$prompt_left.text().length-1):this.$prompt_right.text()[0];p=this.matchings.clss;for(n=0,h=p.length;n=this.history.length){return}if(this.history_index===this.history.length-1){this.history_index++;return this.SetPromptText(this.history_new)}else{return this.SetPromptText(this.history[++this.history_index])}};i.prototype._CheckComposition=function(t){var e;e=t.keyCode||t.which;if(e===229){if(this.in_composition){return this._UpdateComposition()}else{return this._StartComposition()}}};i.prototype._StartComposition=function(){if(this.in_composition){return}this.in_composition=true;this._ShowComposition();return setTimeout(this._UpdateComposition,0)};i.prototype._EndComposition=function(){if(!this.in_composition){return}this._HideComposition();this.$prompt_left.text(this.$prompt_left.text()+this.$composition.text());this.$composition.text("");this.$input_source.val("");return this.in_composition=false};i.prototype._UpdateComposition=function(t){var e,i=this;e=function(){if(!i.in_composition){return}return i.$composition.text(i.$input_source.val())};return setTimeout(e,0)};i.prototype._ShowComposition=function(){this.$composition.css("height",this.$prompt_cursor.height());this.$composition.empty();return this.$composition.appendTo(this.$prompt_left)};i.prototype._HideComposition=function(){return this.$composition.detach()};return i}();t.fn.jqconsole=function(t,e,i){return new v(this,t,e,i)};t.fn.jqconsole.JQConsole=v;t.fn.jqconsole.Ansi=e}).call(this);
\ No newline at end of file
+(function(){var t,e,i,s,r,o,n,h,p,c,u,a,l,_,f,m,d,$,y,v,g,x,b,k,w,C,T,S,M,P,H,E,L,I,W,D,A,R,U=function(t,e){return function(){return t.apply(e,arguments)}},G=[].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";l=">>> ";a="... ";u=2;i=""+p+"ansi-";d="";$=/\[(\d*)(?:;(\d*))*m/;A=function(t){return/[\<\>\{\}\[\]\(\)]/.test(t)};e=function(){t.prototype.COLORS=["black","red","green","yellow","blue","magenta","cyan","white"];function t(){this.stylize=U(this.stylize,this);this._closeSpan=U(this._closeSpan,this);this._openSpan=U(this._openSpan,this);this.getClasses=U(this.getClasses,this);this._style=U(this._style,this);this._color=U(this._color,this);this._remove=U(this._remove,this);this._append=U(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?G.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=U(this._HideComposition,this);this._ShowComposition=U(this._ShowComposition,this);this._UpdateComposition=U(this._UpdateComposition,this);this._EndComposition=U(this._EndComposition,this);this._StartComposition=U(this._StartComposition,this);this._CheckComposition=U(this._CheckComposition,this);this._ProcessMatch=U(this._ProcessMatch,this);this._HandleKey=U(this._HandleKey,this);this._HandleChar=U(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:l;this.prompt_label_continue=n||a;this.indent_width=u;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("");this.$input_source.attr({wrap:"off",autocapitalize:"off",autocorrect:"off",spellcheck:"false",autocomplete:"off"});this.$input_source.css({position:"absolute",width:2});this.$input_source.appendTo(this.$input_container);this.$composition=t(_);this.$composition.addClass(""+p+"composition");this.$composition.css({display:"inline",position:"relative"});this.matchings={openings:{},closings:{},clss:[]};this.ansi=new e;this._InitPrompt();this._SetupEvents();this.Write(this.header,o);t(i).data("jqconsole",this)}i.prototype.ResetHistory=function(){return this.SetHistory([])};i.prototype.ResetShortcuts=function(){return this.shortcuts={}};i.prototype.ResetMatchings=function(){return this.matchings={openings:{},closings:{},clss:[]}};i.prototype.Reset=function(){if(this.state!==W){this.ClearPromptText(true)}this.state=W;this.input_queue=[];this.input_callback=null;this.multiline_callback=null;this.ResetHistory();this.ResetShortcuts();this.ResetMatchings();this.$prompt.detach();this.$input_container.detach();this.$console.html("");this.$prompt.appendTo(this.$console);this.$input_container.appendTo(this.$container);this.Write(this.header,o);return void 0};i.prototype.GetHistory=function(){return this.history};i.prototype.SetHistory=function(t){this.history=t.slice();return this.history_index=this.history.length};i.prototype._CheckKeyCode=function(t){if(isNaN(t)){t=t.charCodeAt(0)}else{t=parseInt(t,10)}if(!(0>> "))}else{o.push(t(i).text())}}return o}().join("")};i.prototype.GetState=function(){if(this.state===I){return"input"}else if(this.state===W){return"output"}else{return"prompt"}};i.prototype.Disable=function(){this.$input_source.attr("disabled",true);return this.$input_source.blur()};i.prototype.Enable=function(){return this.$input_source.attr("disabled",false)};i.prototype.IsDisabled=function(){return Boolean(this.$input_source.attr("disabled"))};i.prototype.MoveToStart=function(t){this._MoveTo(t,true);return void 0};i.prototype.MoveToEnd=function(t){this._MoveTo(t,false);return void 0};i.prototype.Clear=function(){this.$console.find("."+o).nextUntil("."+c).addBack().text("");this.$prompt_cursor.detach();return this.$prompt_right.before(this.$prompt_cursor)};i.prototype._CheckInputQueue=function(){if(this.input_queue.length){return this.input_queue.shift()()}};i.prototype._InitPrompt=function(){this.$prompt=t(R(n)).appendTo(this.$console);this.$prompt_before=t(m).appendTo(this.$prompt);this.$prompt_current=t(m).appendTo(this.$prompt);this.$prompt_after=t(m).appendTo(this.$prompt);this.$prompt_label=t(m).appendTo(this.$prompt_current);this.$prompt_left=t(m).appendTo(this.$prompt_current);this.$prompt_right=t(m).appendTo(this.$prompt_current);this.$prompt_right.css({position:"relative"});this.$prompt_cursor=t(R(r," "));this.$prompt_cursor.insertBefore(this.$prompt_right);this.$prompt_cursor.css({color:"transparent",display:"inline",zIndex:0});if(!this.isMobile){return this.$prompt_cursor.css("position","absolute")}};i.prototype._SetupEvents=function(){if(this.isMobile){this.$console.click(function(t){return function(e){e.preventDefault();return t.Focus()}}(this))}else{this.$console.mouseup(function(t){return function(e){var i;if(e.which===2){return t.Focus()}else{i=function(){if(!window.getSelection().toString()){e.preventDefault();return t.Focus()}};return setTimeout(i,0)}}}(this))}this.$input_source.focus(function(t){return function(){var e,i;t._ScrollToEnd();t.$console_focused=true;t.$console.removeClass(s);i=function(){if(t.$console_focused){return t.$console.removeClass(s)}};setTimeout(i,100);e=function(){if(t.isIos&&t.$console_focused){return t.$input_source.hide()}};return setTimeout(e,500)}}(this));this.$input_source.blur(function(t){return function(){var e;t.$console_focused=false;if(t.isIos){t.$input_source.show()}e=function(){if(!t.$console_focused){return t.$console.addClass(s)}};return setTimeout(e,100)}}(this));this.$input_source.bind("paste",function(t){return function(){var e;e=function(){if(t.in_composition){return}t._AppendPromptText(t.$input_source.val());t.$input_source.val("");return t.Focus()};return setTimeout(e,0)}}(this));this.$input_source.keypress(this._HandleChar);this.$input_source.keydown(this._HandleKey);this.$input_source.keydown(this._CheckComposition);this.$input_source.bind("compositionstart",this._StartComposition);this.$input_source.bind("compositionend",function(t){return function(e){return setTimeout(function(){return t._EndComposition(e)},0)}}(this));if(this.isAndroid){this.$input_source.bind("input",this._StartComposition);return this.$input_source.bind("input",this._UpdateComposition)}else{return this.$input_source.bind("text",this._UpdateComposition)}};i.prototype._HandleChar=function(t){var e,i;i=t.which;if(i===8||i===9||i===13){return false}e=String.fromCharCode(i);if(this.state===W||t.metaKey||t.ctrlKey&&!A(e)){return true}this.$prompt_left.text(this.$prompt_left.text()+e);this._ScrollToEnd();return false};i.prototype._HandleKey=function(e){var i;if(this.state===W){return true}i=e.keyCode||e.which;setTimeout(t.proxy(this._CheckMatchings,this),0);if(e.altKey){return true}else if(e.ctrlKey||e.metaKey){return this._HandleCtrlShortcut(i)}else if(e.shiftKey){switch(i){case w:this._HandleEnter(true);break;case H:this._Unindent();break;case E:this._MoveUp();break;case b:this._MoveDown();break;case M:this._ScrollPage("up");break;case S:this._ScrollPage("down");break;default:return true}return false}else{switch(i){case w:this._HandleEnter(false);break;case H:this._Indent();break;case x:this._Delete(false);break;case g:this._Backspace(false);break;case T:this._MoveLeft(false);break;case P:this._MoveRight(false);break;case E:this._HistoryPrevious();break;case b:this._HistoryNext();break;case C:this.MoveToStart(false);break;case k:this.MoveToEnd(false);break;case M:this._ScrollPage("up");break;case S:this._ScrollPage("down");break;default:return true}return false}};i.prototype._HandleCtrlShortcut=function(t){var e,i,s,r;switch(t){case x:this._Delete(true);break;case g:this._Backspace(true);break;case T:this._MoveLeft(true);break;case P:this._MoveRight(true);break;case E:this._MoveUp();break;case b:this._MoveDown();break;case k:this.MoveToEnd(true);break;case C:this.MoveToStart(true);break;default:if(t in this.shortcuts){r=this.shortcuts[t];for(i=0,s=r.length;ih;o=0<=h?++n:--n){if(e>0){c.push(t._Indent())}else{c.push(t._Unindent())}}return c}else{r=t.state===I?"input":"prompt";t.Write(t.GetPromptText(true)+L,""+p+"old-"+r);t.ClearPromptText(true);if(t.history_active){if(!t.history.length||t.history[t.history.length-1]!==i){t.history.push(i)}t.history_index=t.history.length}t.state=W;s=t.input_callback;t.input_callback=null;if(s){s(i)}return t._CheckInputQueue()}}}(this);if(this.multiline_callback){if(this.async_multiline){return this.multiline_callback(i,e)}else{return e(this.multiline_callback(i))}}else{return e(false)}}};i.prototype._GetDirectionals=function(e){var i,s,r,o,n,h,p,c;o=e?this.$prompt_left:this.$prompt_right;i=e?this.$prompt_right:this.$prompt_left;r=e?this.$prompt_before:this.$prompt_after;s=e?this.$prompt_after:this.$prompt_before;h=e?t.proxy(this.MoveToStart,this):t.proxy(this.MoveToEnd,this);n=e?t.proxy(this._MoveLeft,this):t.proxy(this._MoveRight,this);c=e?"last":"first";p=e?"prependTo":"appendTo";return{$prompt_which:o,$prompt_opposite:i,$prompt_relative:r,$prompt_rel_opposite:s,MoveToLimit:h,MoveDirection:n,which_end:c,where_append:p}};i.prototype._VerticalMove=function(t){var e,i,s,r,o,n,h,p;p=this._GetDirectionals(t),s=p.$prompt_which,e=p.$prompt_opposite,i=p.$prompt_relative,o=p.MoveToLimit,r=p.MoveDirection;if(i.is(f)){return}n=this.$prompt_left.text().length;o();r();h=s.text();e.text(t?h.slice(n):h.slice(0,n));return s.text(t?h.slice(0,n):h.slice(n))};i.prototype._MoveUp=function(){return this._VerticalMove(true)};i.prototype._MoveDown=function(){return this._VerticalMove()};i.prototype._HorizontalMove=function(e,i){var s,r,o,n,h,p,c,u,a,l,_,d,$,y;y=this._GetDirectionals(i),h=y.$prompt_which,r=y.$prompt_opposite,n=y.$prompt_relative,o=y.$prompt_rel_opposite,d=y.which_end,_=y.where_append;u=i?/\w*\W*$/:/^\w*\W*/;a=h.text();if(a){if(e){$=a.match(u);if(!$){return}$=$[0];l=r.text();r.text(i?$+l:l+$);c=$.length;return h.text(i?a.slice(0,-c):a.slice(c))}else{l=r.text();r.text(i?a.slice(-1)+l:l+a[0]);return h.text(i?a.slice(0,-1):a.slice(1))}}else if(!n.is(f)){p=t(m)[_](o);p.append(t(m).text(this.$prompt_label.text()));p.append(t(m).text(r.text()));s=n.children()[d]().detach();this.$prompt_label.text(s.children().first().text());h.text(s.children().last().text());return r.text("")}};i.prototype._MoveLeft=function(t){return this._HorizontalMove(t,true)};i.prototype._MoveRight=function(t){return this._HorizontalMove(t)};i.prototype._MoveTo=function(t,e){var i,s,r,o,n,h,p;h=this._GetDirectionals(e),r=h.$prompt_which,i=h.$prompt_opposite,s=h.$prompt_relative,n=h.MoveToLimit,o=h.MoveDirection;if(t){p=[];while(!(s.is(f)&&r.text()==="")){n(false);p.push(o(false))}return p}else{i.text(this.$prompt_left.text()+this.$prompt_right.text());return r.text("")}};i.prototype._Delete=function(t){var e,i,s;i=this.$prompt_right.text();if(i){if(t){s=i.match(/^\w*\W*/);if(!s){return}s=s[0];return this.$prompt_right.text(i.slice(s.length))}else{return this.$prompt_right.text(i.slice(1))}}else if(!this.$prompt_after.is(f)){e=this.$prompt_after.children().first().detach();return this.$prompt_right.text(e.children().last().text())}};i.prototype._Backspace=function(e){var i,s,r;setTimeout(t.proxy(this._ScrollToEnd,this),0);s=this.$prompt_left.text();if(s){if(e){r=s.match(/\w*\W*$/);if(!r){return}r=r[0];return this.$prompt_left.text(s.slice(0,-r.length))}else{return this.$prompt_left.text(s.slice(0,-1))}}else if(!this.$prompt_before.is(f)){i=this.$prompt_before.children().last().detach();this.$prompt_label.text(i.children().first().text());return this.$prompt_left.text(i.children().last().text())}};i.prototype._Indent=function(){var t;return this.$prompt_left.prepend(function(){var e,i,s;s=[];for(t=e=1,i=this.indent_width;1<=i?e<=i:e>=i;t=1<=i?++e:--e){s.push(" ")}return s}.call(this).join(""))};i.prototype._Unindent=function(){var t,e,i,s,r;t=this.$prompt_left.text()+this.$prompt_right.text();r=[];for(e=i=1,s=this.indent_width;1<=s?i<=s:i>=s;e=1<=s?++i:--i){if(!/^ /.test(t)){break}if(this.$prompt_left.text()){this.$prompt_left.text(this.$prompt_left.text().slice(1))}else{this.$prompt_right.text(this.$prompt_right.text().slice(1))}r.push(t=t.slice(1))}return r};i.prototype._InsertNewLine=function(e){var i,s,r;if(e==null){e=false}r=this._SelectPromptLabel(!this.$prompt_before.is(f));i=t(m).appendTo(this.$prompt_before);i.append(t(m).text(r));i.append(t(m).text(this.$prompt_left.text()));this.$prompt_label.text(this._SelectPromptLabel(true));if(e&&(s=this.$prompt_left.text().match(/^\s+/))){this.$prompt_left.text(s[0])}else{this.$prompt_left.text("")}return this._ScrollToEnd()};i.prototype._AppendPromptText=function(t){var e,i,s,r,o,n;i=t.split(L);this.$prompt_left.text(this.$prompt_left.text()+i[0]);o=i.slice(1);n=[];for(s=0,r=o.length;ss.top){return this.$window.scrollTop(i)}}else{if(o+ti){return this.$window.scrollTop(s.top)}}};i.prototype._SelectPromptLabel=function(t){if(this.state===D){if(t){return" \n"+this.prompt_label_continue}else{return this.prompt_label_main}}else{if(t){return"\n "}else{return" "}}};i.prototype._Wrap=function(t,e,i){var s,r;r=t.html();s=r.slice(0,e)+R(i,r[e])+r.slice(e+1);return t.html(s)};i.prototype._WalkCharacters=function(t,e,i,s,r){var o,n,h;n=r?t.length:0;t=t.split("");h=function(){var e,i,s,o;if(r){s=t,t=2<=s.length?G.call(s,0,i=s.length-1):(i=0,[]),e=s[i++]}else{o=t,e=o[0],t=2<=o.length?G.call(o,1):[]}if(e){n=n+(r?-1:+1)}return e};while(o=h()){if(o===e){s++}else if(o===i){s--}if(s===0){return{index:n,current_count:s}}}return{index:-1,current_count:s}};i.prototype._ProcessMatch=function(e,i,s){var r,o,n,h,p,c,u,a,l,_,f,m;_=i?[e["closing_char"],e["opening_char"]]:[e["opening_char"],e["closing_char"]],h=_[0],a=_[1];f=this._GetDirectionals(i),n=f.$prompt_which,o=f.$prompt_relative;p=1;c=false;l=n.html();if(!i){l=l.slice(1)}if(s&&i){l=l.slice(0,-1)}m=this._WalkCharacters(l,h,a,p,i),u=m.index,p=m.current_count;if(u>-1){this._Wrap(n,u,e.cls);c=true}else{r=o.children();r=i?Array.prototype.reverse.call(r):r;r.each(function(s){return function(r,o){var n,_;n=t(o).children().last();l=n.html();_=s._WalkCharacters(l,h,a,p,i),u=_.index,p=_.current_count;if(u>-1){if(!i){u--}s._Wrap(n,u,e.cls);c=true;return false}}}(this))}return c};i.prototype._CheckMatchings=function(e){var i,s,r,o,n,h,p;r=e?this.$prompt_left.text().slice(this.$prompt_left.text().length-1):this.$prompt_right.text()[0];p=this.matchings.clss;for(n=0,h=p.length;n=this.history.length){return}if(this.history_index===this.history.length-1){this.history_index++;return this.SetPromptText(this.history_new)}else{return this.SetPromptText(this.history[++this.history_index])}};i.prototype._CheckComposition=function(t){var e;e=t.keyCode||t.which;if(e===229){if(this.in_composition){return this._UpdateComposition()}else{return this._StartComposition()}}};i.prototype._StartComposition=function(){if(this.in_composition){return}this.in_composition=true;this._ShowComposition();return setTimeout(this._UpdateComposition,0)};i.prototype._EndComposition=function(){if(!this.in_composition){return}this._HideComposition();this.$prompt_left.text(this.$prompt_left.text()+this.$composition.text());this.$composition.text("");this.$input_source.val("");return this.in_composition=false};i.prototype._UpdateComposition=function(t){var e;e=function(t){return function(){if(!t.in_composition){return}return t.$composition.text(t.$input_source.val())}}(this);return setTimeout(e,0)};i.prototype._ShowComposition=function(){this.$composition.css("height",this.$prompt_cursor.height());this.$composition.empty();return this.$composition.appendTo(this.$prompt_left)};i.prototype._HideComposition=function(){return this.$composition.detach()};return i}();t.fn.jqconsole=function(t,e,i){return new v(this,t,e,i)};t.fn.jqconsole.JQConsole=v;t.fn.jqconsole.Ansi=e}).call(this);
\ No newline at end of file
diff --git a/lib/jqconsole.js b/lib/jqconsole.js
index 96a16f4..d21b0d2 100644
--- a/lib/jqconsole.js
+++ b/lib/jqconsole.js
@@ -1,12 +1,12 @@
-// Generated by CoffeeScript 1.6.3
+// Generated by CoffeeScript 1.7.1
+
/*
Copyrights 2011, the repl.it project.
Licensed under the MIT license
-*/
-
+ */
(function() {
- var $, Ansi, CLASS_ANSI, CLASS_BLURRED, CLASS_CURSOR, CLASS_HEADER, CLASS_INPUT, CLASS_OLD_PROMPT, CLASS_PREFIX, CLASS_PROMPT, DEFAULT_INDENT_WIDTH, DEFAULT_PROMPT_CONINUE_LABEL, DEFAULT_PROMPT_LABEL, EMPTY_DIV, EMPTY_SELECTOR, EMPTY_SPAN, ESCAPE_CHAR, ESCAPE_SYNTAX, E_KEYPRESS, JQConsole, KEY_BACKSPACE, KEY_DELETE, KEY_DOWN, KEY_END, KEY_ENTER, KEY_HOME, KEY_LEFT, KEY_PAGE_DOWN, KEY_PAGE_UP, KEY_RIGHT, KEY_TAB, KEY_UP, NEWLINE, STATE_INPUT, STATE_OUTPUT, STATE_PROMPT, spanHtml,
+ var $, Ansi, CLASS_ANSI, CLASS_BLURRED, CLASS_CURSOR, CLASS_HEADER, CLASS_INPUT, CLASS_OLD_PROMPT, CLASS_PREFIX, CLASS_PROMPT, DEFAULT_INDENT_WIDTH, DEFAULT_PROMPT_CONINUE_LABEL, DEFAULT_PROMPT_LABEL, EMPTY_DIV, EMPTY_SELECTOR, EMPTY_SPAN, ESCAPE_CHAR, ESCAPE_SYNTAX, E_KEYPRESS, JQConsole, KEY_BACKSPACE, KEY_DELETE, KEY_DOWN, KEY_END, KEY_ENTER, KEY_HOME, KEY_LEFT, KEY_PAGE_DOWN, KEY_PAGE_UP, KEY_RIGHT, KEY_TAB, KEY_UP, NEWLINE, STATE_INPUT, STATE_OUTPUT, STATE_PROMPT, isBracket, spanHtml,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__slice = [].slice;
@@ -78,6 +78,10 @@ Licensed under the MIT license
ESCAPE_SYNTAX = /\[(\d*)(?:;(\d*))*m/;
+ isBracket = function(char) {
+ return /[\<\>\{\}\[\]\(\)]/.test(char);
+ };
+
Ansi = (function() {
Ansi.prototype.COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'];
@@ -402,8 +406,8 @@ Licensed under the MIT license
return this.history_index = this.history.length;
};
- /*------------------------ Shortcut Methods -----------------------------*/
+ /*------------------------ Shortcut Methods ----------------------------- */
JQConsole.prototype._CheckKeyCode = function(key_code) {
if (isNaN(key_code)) {
@@ -428,41 +432,43 @@ Licensed under the MIT license
};
JQConsole.prototype.RegisterShortcut = function(key_code, callback) {
- var addShortcut,
- _this = this;
+ var addShortcut;
key_code = this._CheckKeyCode(key_code);
if (typeof callback !== 'function') {
throw new Error('Callback must be a function, not ' + callback + '.');
}
- addShortcut = function(key) {
- if (!(key in _this.shortcuts)) {
- _this.shortcuts[key] = [];
- }
- return _this.shortcuts[key].push(callback);
- };
+ addShortcut = (function(_this) {
+ return function(key) {
+ if (!(key in _this.shortcuts)) {
+ _this.shortcuts[key] = [];
+ }
+ return _this.shortcuts[key].push(callback);
+ };
+ })(this);
this._LetterCaseHelper(key_code, addShortcut);
return void 0;
};
JQConsole.prototype.UnRegisterShortcut = function(key_code, handler) {
- var removeShortcut,
- _this = this;
+ var removeShortcut;
key_code = this._CheckKeyCode(key_code);
- removeShortcut = function(key) {
- if (key in _this.shortcuts) {
- if (handler) {
- return _this.shortcuts[key].splice(_this.shortcuts[key].indexOf(handler), 1);
- } else {
- return delete _this.shortcuts[key];
+ removeShortcut = (function(_this) {
+ return function(key) {
+ if (key in _this.shortcuts) {
+ if (handler) {
+ return _this.shortcuts[key].splice(_this.shortcuts[key].indexOf(handler), 1);
+ } else {
+ return delete _this.shortcuts[key];
+ }
}
- }
- };
+ };
+ })(this);
this._LetterCaseHelper(key_code, removeShortcut);
return void 0;
};
- /*---------------------- END Shortcut Methods ---------------------------*/
+ /*---------------------- END Shortcut Methods --------------------------- */
JQConsole.prototype.GetColumn = function() {
var lines;
@@ -564,21 +570,24 @@ Licensed under the MIT license
};
JQConsole.prototype.Input = function(input_callback) {
- var current_async_multiline, current_history_active, current_input_callback, current_multiline_callback,
- _this = this;
+ var current_async_multiline, current_history_active, current_input_callback, current_multiline_callback;
if (this.state === STATE_PROMPT) {
current_input_callback = this.input_callback;
current_multiline_callback = this.multiline_callback;
current_history_active = this.history_active;
current_async_multiline = this.async_multiline;
this.AbortPrompt();
- this.input_queue.unshift(function() {
- return _this.Prompt(current_history_active, current_input_callback, current_multiline_callback, current_async_multiline);
- });
+ this.input_queue.unshift((function(_this) {
+ return function() {
+ return _this.Prompt(current_history_active, current_input_callback, current_multiline_callback, current_async_multiline);
+ };
+ })(this));
} else if (this.state !== STATE_OUTPUT) {
- this.input_queue.push(function() {
- return _this.Input(input_callback);
- });
+ this.input_queue.push((function(_this) {
+ return function() {
+ return _this.Input(input_callback);
+ };
+ })(this));
return;
}
this.history_active = false;
@@ -593,11 +602,12 @@ Licensed under the MIT license
};
JQConsole.prototype.Prompt = function(history_enabled, result_callback, multiline_callback, async_multiline) {
- var _this = this;
if (this.state !== STATE_OUTPUT) {
- this.input_queue.push(function() {
- return _this.Prompt(history_enabled, result_callback, multiline_callback, async_multiline);
- });
+ this.input_queue.push((function(_this) {
+ return function() {
+ return _this.Prompt(history_enabled, result_callback, multiline_callback, async_multiline);
+ };
+ })(this));
return;
}
this.history_active = history_enabled;
@@ -713,11 +723,11 @@ Licensed under the MIT license
JQConsole.prototype.Clear = function() {
this.$console.find("." + CLASS_HEADER).nextUntil("." + CLASS_PROMPT).addBack().text('');
this.$prompt_cursor.detach();
- return this.$prompt_after.before(this.$prompt_cursor);
+ return this.$prompt_right.before(this.$prompt_cursor);
};
- /*------------------------ Private Methods -------------------------------*/
+ /*------------------------ Private Methods ------------------------------- */
JQConsole.prototype._CheckInputQueue = function() {
if (this.input_queue.length) {
@@ -749,80 +759,91 @@ Licensed under the MIT license
};
JQConsole.prototype._SetupEvents = function() {
- var _this = this;
if (this.isMobile) {
- this.$console.click(function(e) {
- e.preventDefault();
- return _this.Focus();
- });
- } else {
- this.$console.mouseup(function(e) {
- var fn;
- if (e.which === 2) {
+ this.$console.click((function(_this) {
+ return function(e) {
+ e.preventDefault();
return _this.Focus();
- } else {
- fn = function() {
- if (!window.getSelection().toString()) {
- e.preventDefault();
- return _this.Focus();
- }
- };
- return setTimeout(fn, 0);
- }
- });
+ };
+ })(this));
+ } else {
+ this.$console.mouseup((function(_this) {
+ return function(e) {
+ var fn;
+ if (e.which === 2) {
+ return _this.Focus();
+ } else {
+ fn = function() {
+ if (!window.getSelection().toString()) {
+ e.preventDefault();
+ return _this.Focus();
+ }
+ };
+ return setTimeout(fn, 0);
+ }
+ };
+ })(this));
}
- this.$input_source.focus(function() {
- var hideTextInput, removeClass;
- _this._ScrollToEnd();
- _this.$console_focused = true;
- _this.$console.removeClass(CLASS_BLURRED);
- removeClass = function() {
- if (_this.$console_focused) {
- return _this.$console.removeClass(CLASS_BLURRED);
- }
- };
- setTimeout(removeClass, 100);
- hideTextInput = function() {
- if (_this.isIos && _this.$console_focused) {
- return _this.$input_source.hide();
- }
+ this.$input_source.focus((function(_this) {
+ return function() {
+ var hideTextInput, removeClass;
+ _this._ScrollToEnd();
+ _this.$console_focused = true;
+ _this.$console.removeClass(CLASS_BLURRED);
+ removeClass = function() {
+ if (_this.$console_focused) {
+ return _this.$console.removeClass(CLASS_BLURRED);
+ }
+ };
+ setTimeout(removeClass, 100);
+ hideTextInput = function() {
+ if (_this.isIos && _this.$console_focused) {
+ return _this.$input_source.hide();
+ }
+ };
+ return setTimeout(hideTextInput, 500);
};
- return setTimeout(hideTextInput, 500);
- });
- this.$input_source.blur(function() {
- var addClass;
- _this.$console_focused = false;
- if (_this.isIos) {
- _this.$input_source.show();
- }
- addClass = function() {
- if (!_this.$console_focused) {
- return _this.$console.addClass(CLASS_BLURRED);
+ })(this));
+ this.$input_source.blur((function(_this) {
+ return function() {
+ var addClass;
+ _this.$console_focused = false;
+ if (_this.isIos) {
+ _this.$input_source.show();
}
+ addClass = function() {
+ if (!_this.$console_focused) {
+ return _this.$console.addClass(CLASS_BLURRED);
+ }
+ };
+ return setTimeout(addClass, 100);
};
- return setTimeout(addClass, 100);
- });
- this.$input_source.bind('paste', function() {
- var handlePaste;
- handlePaste = function() {
- if (_this.in_composition) {
- return;
- }
- _this._AppendPromptText(_this.$input_source.val());
- _this.$input_source.val('');
- return _this.Focus();
+ })(this));
+ this.$input_source.bind('paste', (function(_this) {
+ return function() {
+ var handlePaste;
+ handlePaste = function() {
+ if (_this.in_composition) {
+ return;
+ }
+ _this._AppendPromptText(_this.$input_source.val());
+ _this.$input_source.val('');
+ return _this.Focus();
+ };
+ return setTimeout(handlePaste, 0);
};
- return setTimeout(handlePaste, 0);
- });
+ })(this));
this.$input_source.keypress(this._HandleChar);
this.$input_source.keydown(this._HandleKey);
this.$input_source.keydown(this._CheckComposition);
this.$input_source.bind('compositionstart', this._StartComposition);
- this.$input_source.bind('compositionend', function(e) {
- return setTimeout((function() {
- return _this._EndComposition(e);
- }), 0);
- });
+ this.$input_source.bind('compositionend', (function(_this) {
+ return function(e) {
+ return setTimeout((function() {
+ return _this._EndComposition(e);
+ }), 0);
+ };
+ })(this));
if (this.isAndroid) {
this.$input_source.bind('input', this._StartComposition);
return this.$input_source.bind('input', this._UpdateComposition);
@@ -832,15 +853,16 @@ Licensed under the MIT license
};
JQConsole.prototype._HandleChar = function(event) {
- var char_code;
- if (this.state === STATE_OUTPUT || event.metaKey || event.ctrlKey) {
- return true;
- }
+ var char, char_code;
char_code = event.which;
if (char_code === 8 || char_code === 9 || char_code === 13) {
return false;
}
- this.$prompt_left.text(this.$prompt_left.text() + String.fromCharCode(char_code));
+ char = String.fromCharCode(char_code);
+ if (this.state === STATE_OUTPUT || event.metaKey || (event.ctrlKey && !isBracket(char))) {
+ return true;
+ }
+ this.$prompt_left.text(this.$prompt_left.text() + char);
this._ScrollToEnd();
return false;
};
@@ -968,46 +990,47 @@ Licensed under the MIT license
};
JQConsole.prototype._HandleEnter = function(shift) {
- var continuation, text,
- _this = this;
+ var continuation, text;
this._EndComposition();
if (shift) {
return this._InsertNewLine(true);
} else {
text = this.GetPromptText();
- continuation = function(indent) {
- var callback, cls_suffix, _, _i, _ref, _results;
- if (indent !== false) {
- _this.MoveToEnd(true);
- _this._InsertNewLine(true);
- _results = [];
- for (_ = _i = 0, _ref = Math.abs(indent); 0 <= _ref ? _i < _ref : _i > _ref; _ = 0 <= _ref ? ++_i : --_i) {
- if (indent > 0) {
- _results.push(_this._Indent());
- } else {
- _results.push(_this._Unindent());
+ continuation = (function(_this) {
+ return function(indent) {
+ var callback, cls_suffix, _, _i, _ref, _results;
+ if (indent !== false) {
+ _this.MoveToEnd(true);
+ _this._InsertNewLine(true);
+ _results = [];
+ for (_ = _i = 0, _ref = Math.abs(indent); 0 <= _ref ? _i < _ref : _i > _ref; _ = 0 <= _ref ? ++_i : --_i) {
+ if (indent > 0) {
+ _results.push(_this._Indent());
+ } else {
+ _results.push(_this._Unindent());
+ }
}
- }
- return _results;
- } else {
- cls_suffix = _this.state === STATE_INPUT ? 'input' : 'prompt';
- _this.Write(_this.GetPromptText(true) + NEWLINE, ("" + CLASS_PREFIX + "old-") + cls_suffix);
- _this.ClearPromptText(true);
- if (_this.history_active) {
- if (!_this.history.length || _this.history[_this.history.length - 1] !== text) {
- _this.history.push(text);
+ return _results;
+ } else {
+ cls_suffix = _this.state === STATE_INPUT ? 'input' : 'prompt';
+ _this.Write(_this.GetPromptText(true) + NEWLINE, ("" + CLASS_PREFIX + "old-") + cls_suffix);
+ _this.ClearPromptText(true);
+ if (_this.history_active) {
+ if (!_this.history.length || _this.history[_this.history.length - 1] !== text) {
+ _this.history.push(text);
+ }
+ _this.history_index = _this.history.length;
}
- _this.history_index = _this.history.length;
- }
- _this.state = STATE_OUTPUT;
- callback = _this.input_callback;
- _this.input_callback = null;
- if (callback) {
- callback(text);
+ _this.state = STATE_OUTPUT;
+ callback = _this.input_callback;
+ _this.input_callback = null;
+ if (callback) {
+ callback(text);
+ }
+ return _this._CheckInputQueue();
}
- return _this._CheckInputQueue();
- }
- };
+ };
+ })(this);
if (this.multiline_callback) {
if (this.async_multiline) {
return this.multiline_callback(text, continuation);
@@ -1328,8 +1351,7 @@ Licensed under the MIT license
};
JQConsole.prototype._ProcessMatch = function(config, back, before_char) {
- var $collection, $prompt_relative, $prompt_which, char, current_count, found, index, opposing_char, text, _ref, _ref1, _ref2,
- _this = this;
+ var $collection, $prompt_relative, $prompt_which, char, current_count, found, index, opposing_char, text, _ref, _ref1, _ref2;
_ref = back ? [config['closing_char'], config['opening_char']] : [config['opening_char'], config['closing_char']], char = _ref[0], opposing_char = _ref[1];
_ref1 = this._GetDirectionals(back), $prompt_which = _ref1.$prompt_which, $prompt_relative = _ref1.$prompt_relative;
current_count = 1;
@@ -1348,20 +1370,22 @@ Licensed under the MIT license
} else {
$collection = $prompt_relative.children();
$collection = back ? Array.prototype.reverse.call($collection) : $collection;
- $collection.each(function(i, elem) {
- var $elem, _ref3;
- $elem = $(elem).children().last();
- text = $elem.html();
- _ref3 = _this._WalkCharacters(text, char, opposing_char, current_count, back), index = _ref3.index, current_count = _ref3.current_count;
- if (index > -1) {
- if (!back) {
- index--;
+ $collection.each((function(_this) {
+ return function(i, elem) {
+ var $elem, _ref3;
+ $elem = $(elem).children().last();
+ text = $elem.html();
+ _ref3 = _this._WalkCharacters(text, char, opposing_char, current_count, back), index = _ref3.index, current_count = _ref3.current_count;
+ if (index > -1) {
+ if (!back) {
+ index--;
+ }
+ _this._Wrap($elem, index, config.cls);
+ found = true;
+ return false;
}
- _this._Wrap($elem, index, config.cls);
- found = true;
- return false;
- }
- });
+ };
+ })(this));
}
return found;
};
@@ -1453,14 +1477,15 @@ Licensed under the MIT license
};
JQConsole.prototype._UpdateComposition = function(e) {
- var cb,
- _this = this;
- cb = function() {
- if (!_this.in_composition) {
- return;
- }
- return _this.$composition.text(_this.$input_source.val());
- };
+ var cb;
+ cb = (function(_this) {
+ return function() {
+ if (!_this.in_composition) {
+ return;
+ }
+ return _this.$composition.text(_this.$input_source.val());
+ };
+ })(this);
return setTimeout(cb, 0);
};
diff --git a/src/jqconsole.coffee b/src/jqconsole.coffee
index 5621b3b..73f880c 100644
--- a/src/jqconsole.coffee
+++ b/src/jqconsole.coffee
@@ -52,6 +52,9 @@ CLASS_ANSI = "#{CLASS_PREFIX}ansi-"
ESCAPE_CHAR = '\x1B'
ESCAPE_SYNTAX = /\[(\d*)(?:;(\d*))*m/
+isBracket = (char) ->
+ /[\<\>\{\}\[\]\(\)]/.test char
+
class Ansi
COLORS: ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']
@@ -768,11 +771,6 @@ class JQConsole
# Handles a character key press.
# @arg event: The jQuery keyboard Event object to handle.
_HandleChar: (event) =>
- # 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
- return true
# IE & Chrome capture non-control characters and Enter.
# Mozilla and Opera capture everything.
@@ -784,7 +782,15 @@ class JQConsole
# These are handled in _HandleKey().
if char_code in [8, 9, 13] then return false
- @$prompt_left.text @$prompt_left.text() + String.fromCharCode char_code
+ char = String.fromCharCode char_code
+
+ # 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 && ! isBracket char)
+ return true
+
+ @$prompt_left.text @$prompt_left.text() + char
@_ScrollToEnd()
return false
diff --git a/test/prompt-test.coffee b/test/prompt-test.coffee
index e67f68a..d624993 100644
--- a/test/prompt-test.coffee
+++ b/test/prompt-test.coffee
@@ -68,7 +68,7 @@ describe 'Prompt Interaction', ->
describe '#SetPromptText', ->
beforeEach -> jqconsole.Prompt true, ->
afterEach -> jqconsole.AbortPrompt()
-
+
it 'sets the current prompt text', ->
type 'bar'
jqconsole.SetPromptText('foo')
@@ -343,6 +343,37 @@ describe 'Prompt Interaction', ->
setTimeout cb, 0
setTimeout cb, jQuery.fx.speeds.fast * 2
+ describe 'Brackets', ->
+ it 'adds [ ]', ->
+ type('[')
+ type(']')
+ equal jqconsole.GetPromptText(), '[]'
+ it 'adds {}', ->
+ type '{'
+ type '}'
+ equal jqconsole.GetPromptText(), '{}'
+ it 'adds <>', ->
+ type '<'
+ type '>'
+ equal jqconsole.GetPromptText(), '<>'
+
+ describe 'windows for Chrome', ->
+ it 'adds {}', ->
+ type '{',
+ ctrlKey: true
+ type '}',
+ ctrlKey: true
+ equal jqconsole.GetPromptText(), '{}'
+ it 'adds []', ->
+ type '[',
+ ctrlKey: true
+ type ']',
+ ctrlKey: true
+ equal jqconsole.GetPromptText(), '[]'
+
+
+
+
describe 'Multiline', ->
beforeEach ->
if jqconsole.GetState() is 'prompt'
diff --git a/test/setup.coffee b/test/setup.coffee
index 1a28c62..6aa2695 100644
--- a/test/setup.coffee
+++ b/test/setup.coffee
@@ -12,24 +12,21 @@ window.jqconsoleSetup = ->
position: 'relative'
$container.appendTo('body')
jqconsole = new JQConsole($container, 'header', 'prompt_label', 'prompt_continue')
+ triggerEvent = (type, charCode, options = {}) ->
+ e = $.Event(type)
+ e.which = charCode
+ e[k] = v for k, v of options
+ jqconsole.$input_source.trigger(e)
+
typer =
typeA: ->
- e = $.Event('keypress')
- e.which = 'a'.charCodeAt(0)
- jqconsole.$input_source.trigger e
+ triggerEvent 'keypress', 'a'.charCodeAt(0)
keyDown: (code, options = {}) ->
- e = $.Event('keydown')
- e.which = code
- e[k] = v for k, v of options
- jqconsole.$input_source.trigger e
+ triggerEvent 'keydown', code, options
- type: (str) ->
- type = (chr) ->
- e = $.Event('keypress')
- e.which = chr.charCodeAt(0)
- jqconsole.$input_source.trigger(e)
- type chr for chr in str
+ type: (str, options = {}) ->
+ triggerEvent 'keypress', chr.charCodeAt(0), options for chr in str
createScroll = ->
line_height = jqconsole.$prompt.height()