diff --git a/js/jquery.terminal-1.12.1.js b/js/jquery.terminal-1.12.1.js index a4f60fb04..7ef3d5500 100644 --- a/js/jquery.terminal-1.12.1.js +++ b/js/jquery.terminal-1.12.1.js @@ -32,7 +32,7 @@ * Copyright (c) 2007-2013 Alexandru Marasteanu * licensed under 3 clause BSD license * - * Date: Sat, 03 Mar 2018 22:50:58 +0000 + * Date: Sun, 04 Mar 2018 02:47:13 +0000 */ /* TODO: @@ -2592,7 +2592,7 @@ self.data('cmd', self); if (!('KeyboardEvent' in window && 'key' in window.KeyboardEvent.prototype)) { setTimeout(function() { - throw new Error('key event property not supported try https://github.'+ + throw new Error('key event property not supported try https://github.' + 'com/inexorabletash/polyfill/blob/master/keyboard.js'); }, 0); } @@ -2860,7 +2860,7 @@ } $.terminal = { version: 'DEV', - date: 'Sat, 03 Mar 2018 22:50:58 +0000', + date: 'Sun, 04 Mar 2018 02:47:13 +0000', // colors from http://www.w3.org/wiki/CSS/Properties/color/keywords color_names: [ 'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white', @@ -3136,12 +3136,33 @@ var line = array[i]; var first_index = 0; var output; + + // $.terminal.iterate_formatting won't trigger an + // callback after the last bracket of a line when + // there is no character following + // like: "A[[;;]\n]B" => ["A[[;;;;\\n]","]B"] + // => first line gets ignored + // Fix: we add a character if necessary and remove it later + var addchar = false; + if ( + line[line.length - 1] === "]" && + i < array.length - 1 && + array[i + 1][0] !== "[" // differentiate ]\n[ from ]\n] + ) + { + addchar = true; + } + var line_length = line.length; - $.terminal.iterate_formatting(line, function(data) { + + $.terminal.iterate_formatting(addchar ? line + " " : line, + function(data) { // we don't iterate over last closing bracket var last_bracket = data.index === line_length - 2 && line[data.index + 1] === ']'; - var last_iteraction = data.index === line_length - 1 || last_bracket; + var last_iteraction = + data.index === line_length - (addchar ? 0 : 1) || + last_bracket; if (data.length >= length || last_iteraction || (data.length === length - 1 && strlen(line[data.index + 1]) === 2)) { diff --git a/js/jquery.terminal-1.12.1.min.js b/js/jquery.terminal-1.12.1.min.js index ae0b02314..8bbaeab15 100644 --- a/js/jquery.terminal-1.12.1.min.js +++ b/js/jquery.terminal-1.12.1.min.js @@ -32,6 +32,6 @@ * Copyright (c) 2007-2013 Alexandru Marasteanu * licensed under 3 clause BSD license * - * Date: Sat, 03 Mar 2018 22:50:58 +0000 + * Date: Sun, 04 Mar 2018 02:47:13 +0000 */ -(function(e){var n=function(){if(!n.cache.hasOwnProperty(arguments[0])){n.cache[arguments[0]]=n.parse(arguments[0])}return n.format.call(null,n.cache[arguments[0]],arguments)};n.format=function(e,t){var o=1,a=e.length,s="",l,f=[],u,c,p,m,d,h;for(u=0;u>>0;break;case"x":l=l.toString(16);break;case"X":l=l.toString(16).toUpperCase();break}l=/[def]/.test(p[8])&&p[3]&&l>=0?" +"+l:l;d=p[4]?p[4]==="0"?"0":p[4].charAt(1):" ";h=p[6]-String(l).length;m=p[6]?i(d,h):"";f.push(p[5]?l+m:m+l)}}return f.join("")};n.cache={};n.parse=function(e){var n=e,t=[],r=[],i=0;while(n){if((t=/^[^\x25]+/.exec(n))!==null){r.push(t[0])}else if((t=/^\x25{2}/.exec(n))!==null){r.push("%")}else if((t=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(n))!==null){if(t[2]){i|=1;var o=[],a=t[2],s=[];if((s=/^([a-z_][a-z_\d]*)/i.exec(a))!==null){o.push(s[1]);while((a=a.substring(s[0].length))!==""){if((s=/^\.([a-z_][a-z_\d]*)/i.exec(a))!==null){o.push(s[1])}else if((s=/^\[(\d+)\]/.exec(a))!==null){o.push(s[1])}else{throw"[sprintf] huh?"}}}else{throw"[sprintf] huh?"}t[2]=o}else{i|=2}if(i===3){throw"[sprintf] mixing positional and named placeholders is not (yet) supported"}r.push(t)}else{throw"[sprintf] huh?"}n=n.substring(t[0].length)}return r};var t=function(e,t,r){r=t.slice(0);r.splice(0,0,e);return n.apply(null,r)};function r(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function i(e,n){for(var t=[];n>0;t[--n]=e){}return t.join("")}e.sprintf=n;e.vsprintf=t})(typeof global!=="undefined"?global:window);(function(e){if(typeof define==="function"&&define.amd){define(["jquery"],e)}else if(typeof module==="object"&&module.exports){module.exports=function(n,t){if(t===undefined){if(typeof window!=="undefined"){t=require("jquery")}else{t=require("jquery")(n)}}e(t);return t}}else{e(jQuery)}})(function(e,n){"use strict";function t(){var n=e.Callbacks();var t=false;this.resolve=function(){n.fire();t=true};this.add=function(e){if(t){e()}else{n.add(e)}}}e.omap=function(n,t){var r={};e.each(n,function(e,i){r[e]=t.call(n,e,i)});return r};e.fn.text_length=function(){return this.map(function(){return e(this).text().length}).get().reduce(function(e,n){return e+n},0)};var r={clone_object:function(n){var t={};if(typeof n==="object"){if(e.isArray(n)){return this.clone_array(n)}else if(n===null){return n}else{for(var r in n){if(e.isArray(n[r])){t[r]=this.clone_array(n[r])}else if(typeof n[r]==="object"){t[r]=this.clone_object(n[r])}else{t[r]=n[r]}}}}return t},clone_array:function(n){if(!e.isFunction(Array.prototype.map)){throw new Error("Your browser don't support ES5 array map "+"use es5-shim")}return n.slice(0).map(function(e){if(typeof e==="object"){return this.clone_object(e)}else{return e}}.bind(this))}};var i=function(e){return r.clone_object(e)};var o=function(){try{var e="test",n=window.localStorage;n.setItem(e,"1");n.removeItem(e);return true}catch(e){return false}};var a=function(){try{document.cookie.split(";");return true}catch(e){return false}};var s=o();function l(e,n){var t;if(typeof e==="string"&&typeof n==="string"){d[e]=n;return true}else if(typeof e==="object"&&typeof n==="undefined"){for(t in e){if(e.hasOwnProperty(t)){d[t]=e[t]}}return true}return false}function f(e,n){var t,r,i;t=new Date;t.setTime(t.getTime()+31536e6);r="; expires="+t.toGMTString();if(typeof e==="string"&&typeof n==="string"){document.cookie=e+"="+n+r+"; path=/";return true}else if(typeof e==="object"&&typeof n==="undefined"){for(i in e){if(e.hasOwnProperty(i)){document.cookie=i+"="+e[i]+r+"; path=/"}}return true}return false}function u(e){return d[e]}function c(e){var n,t,r,i;n=e+"=";t=document.cookie.split(";");for(r=0;ri&&i!==0||r.call(e,a)===false){h.timer.remove(e,t,r)}s.inProgress=false};s.$timerID=r.$timerID;if(!e.$timers[t][r.$timerID]){e.$timers[t][r.$timerID]=window.setInterval(s,n)}if(!this.global[t]){this.global[t]=[]}this.global[t].push(e)},remove:function(e,n,t){var r=e.$timers,i;if(r){if(!n){for(var o in r){if(r.hasOwnProperty(o)){this.remove(e,o,t)}}}else if(r[n]){if(t){if(t.$timerID){window.clearInterval(r[n][t.$timerID]);delete r[n][t.$timerID]}}else{for(var a in r[n]){if(r[n].hasOwnProperty(a)){window.clearInterval(r[n][a]);delete r[n][a]}}}for(i in r[n]){if(r[n].hasOwnProperty(i)){break}}if(!i){i=null;delete r[n]}}for(i in r){if(r.hasOwnProperty(i)){break}}if(!i){e.$timers=null}}}}});if(/(msie) ([\w.]+)/.exec(navigator.userAgent.toLowerCase())){e(window).one("unload",function(){var e=h.timer.global;for(var n in e){if(e.hasOwnProperty(n)){var t=e[n],r=t.length;while(--r){h.timer.remove(t[r],n)}}}})}(function(e){if(!String.prototype.split.toString().match(/\[native/)){return}var n=String.prototype.split,t=/()??/.exec("")[1]===e,r;r=function(r,i,o){if(Object.prototype.toString.call(i)!=="[object RegExp]"){return n.call(r,i,o)}var a=[],s=(i.ignoreCase?"i":"")+(i.multiline?"m":"")+(i.extended?"x":"")+(i.sticky?"y":""),l=0,f,u,c,p;i=new RegExp(i.source,s+"g");r+="";if(!t){f=new RegExp("^"+i.source+"$(?!\\s)",s)}o=o===e?-1>>>0:o>>>0;while(u=i.exec(r)){c=u.index+u[0].length;if(c>l){a.push(r.slice(l,u.index));if(!t&&u.length>1){u[0].replace(f,function(){for(var n=1;n1&&u.index=o){break}}if(i.lastIndex===u.index){i.lastIndex++}}if(l===r.length){if(p||!i.test("")){a.push("")}}else{a.push(r.slice(l))}return a.length>o?a.slice(0,o):a};String.prototype.split=function(e,n){return r(this,e,n)};return r})();e.fn.caret=function(e){var n=this[0];var t=n.contentEditable==="true";if(arguments.length===0){if(window.getSelection){if(t){n.focus();var r=window.getSelection().getRangeAt(0),i=r.cloneRange();i.selectNodeContents(n);i.setEnd(r.endContainer,r.endOffset);return i.toString().length}return n.selectionStart}if(document.selection){n.focus();if(t){var r=document.selection.createRange(),i=document.body.createTextRange();i.moveToElementText(n);i.setEndPoint("EndToEnd",r);return i.text.length}var e=0,o=n.createTextRange(),i=document.selection.createRange().duplicate(),a=i.getBookmark();o.moveToBookmark(a);while(o.moveStart("character",-1)!==0)e++;return e}return 0}if(e===-1)e=this[t?"text":"val"]().length;if(window.getSelection){if(t){n.focus();window.getSelection().collapse(n.firstChild,e)}else n.setSelectionRange(e,e)}else if(document.body.createTextRange){var o=document.body.createTextRange();o.moveToElementText(n);o.moveStart("character",e);o.collapse(true);o.select()}if(!t&&!this.is(":focus")){n.focus()}return e};var v=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){return setTimeout(e,20)};e.fn.resizer=function(n){var t=arguments[0]==="unbind";if(!t&&!e.isFunction(n)){throw new Error('Invalid argument, it need to a function or string "unbind".')}if(t){n=e.isFunction(arguments[1])?arguments[1]:null}return this.each(function(){var r=e(this);var i;if(t){i=r.data("callbacks");if(n&&i){i.remove(n);if(!i.has()){i=null}}else{i=null}if(!i){r.removeData("callbacks");if(window.ResizeObserver){var o=r.data("observer");if(o){o.unobserve(this);r.removeData("observer")}}else{r.find(".resizer").remove()}}}else if(r.data("callbacks")){e(this).data("callbacks").add(n)}else{i=e.Callbacks();i.add(n);r.data("callbacks",i);var a;var s=true;if(window.ResizeObserver){a=new ResizeObserver(function(){if(!s){var e=r.data("callbacks");e.fire()}s=false});a.observe(this);r.data("observer",a);return}var l=this;a=e("
").addClass("resizer").appendTo(this)[0];var f="position: absolute; left: 0; top: 0; right: 0; bottom: 0; "+"overflow: hidden; z-index: -1; visibility: hidden;";var u="position: absolute; left: 0; top: 0; transition: 0s;";a.style.cssText=f;a.innerHTML='
'+'
'+"
"+'
'+'
'+"
";var c=a.childNodes[0];var p=c.childNodes[0];var m=a.childNodes[1];var d,h,g,y;var b=l.offsetWidth;var w=l.offsetHeight;var _=function(){p.style.width="100000px";p.style.height="100000px";c.scrollLeft=1e5;c.scrollTop=1e5;m.scrollLeft=1e5;m.scrollTop=1e5};_();var x=function(){h=0;if(!d){return}b=g;w=y;i.fire()};var k=function(){g=l.offsetWidth;y=l.offsetHeight;d=g!==b||y!==w;if(d&&!h){h=v(x)}_()};e(c).on("scroll",k);e(m).on("scroll",k)}})};function g(e){e.attr({role:"presentation","aria-hidden":"true"})}var y=[];function b(e,n){var t=(e?e+": ":"")+_(n);if(y.indexOf(t)===-1){y.push(t);alert(t+(n.stack?"\n"+n.stack:""))}}function w(e,n){var t=n.offset().left;return n.outerWidth()<=e.clientX-t}function _(e){if(typeof e==="string"){return e}else if(typeof e.fileName==="string"){return e.fileName+": "+e.message}else{return e.message}}function x(){var n=[].slice.call(arguments);var t=0;e.extend(this,{get:function(){return n},index:function(){return t},rotate:function(e){if(!e){var r=n.filter(function(e){return typeof e!=="undefined"});if(!r.length){return}}if(n.length===1){return n[0]}else{if(t===n.length-1){t=0}else{++t}if(typeof n[t]!=="undefined"){return n[t]}else{return this.rotate(true)}}},length:function(){return n.length},remove:function(e){delete n[e]},set:function(e){for(var r=n.length;r--;){if(n[r]===e){t=r;return}}this.append(e);t=n.length-1},front:function(){if(n.length){var e=t;var r=false;while(!n[e]){e++;if(e>n.length){if(r){break}e=0;r=true}}return n[e]}},map:function(e){return n.filter(Boolean).map(e)},forEach:function(e){n.filter(Boolean).forEach(e)},append:function(e){n.push(e)}})}function k(n){var t=n instanceof Array?n:n?[n]:[];e.extend(this,{data:function(){return t},map:function(n){return e.map(t,n)},size:function(){return t.length},pop:function(){if(t.length===0){return null}else{var e=t[t.length-1];t=t.slice(0,t.length-1);return e}},push:function(e){t=t.concat([e]);return e},top:function(){return t.length>0?t[t.length-1]:null},clone:function(){return new k(t.slice(0))}})}function T(n,t,r){var i=true;var o="";if(typeof n==="string"&&n!==""){o=n+"_"}o+="commands";var a;if(r){a=[]}else{a=e.Storage.get(o);a=a?JSON.parse(a):[]}var s=a.length-1;e.extend(this,{append:function(n){if(i){if(a[a.length-1]!==n){a.push(n);if(t&&a.length>t){a=a.slice(-t)}s=a.length-1;if(!r){e.Storage.set(o,JSON.stringify(a))}}}},set:function(n){if(n instanceof Array){a=n;if(!r){e.Storage.set(o,JSON.stringify(a))}}},data:function(){return a},reset:function(){s=a.length-1},last:function(){return a[a.length-1]},end:function(){return s===a.length-1},position:function(){return s},current:function(){return a[s]},next:function(){var e=s;if(s0){--s}if(e!==s){return a[s]}},clear:function(){a=[];this.purge()},enabled:function(){return i},enable:function(){i=true},purge:function(){if(!r){e.Storage.remove(o)}},disable:function(){i=false}})}var E=0;e.cmd={defaults:{mask:false,caseSensitiveSearch:true,historySize:60,prompt:"> ",enabled:true,history:true,onPositionChange:e.noop}};e.fn.cmd=function(t){var r=e.extend({},e.cmd.defaults,t);var i=this;var o=i.data("cmd");if(o){return o}var a=E++;i.addClass("cmd");i.append('');i.append('
'+""+' '+""+"
");g(i.find(".cursor-line"));var s=e("