").addClass("terminal-output").attr("role","log").appendTo(tn);ge.addClass("terminal");if(Ue.login&&e.isFunction(Ue.onBeforeLogin)){try{if(Ue.onBeforeLogin.call(ge,ge)===false){Xe=false}}catch(n){Ue.onBeforeLogin=e.noop;_(n,"onBeforeLogin")}}var an;if(typeof r==="string"){an=r}else if(r instanceof Array){for(var sn=0,ln=r.length;sn
',{raw:true})}else if(n(t[r],"text/plain")){t[r].getAsString(ge.insert)}}}else if(e.clipboardData.getData){var s=e.clipboardData.getData("text/plain");ge.insert(s)}return false}}}e(document).on("paste.terminal_"+ge.id(),pn);var mn=e.extend({},se,e.omap(Ue.keymap||{},function(e,n){if(!se[e]){return n.bind(ge)}return function(t,r){return n.call(ge,t,function(){return se[e](t,r)})}}));d(r,Ue.login,function(t){if(Ue.completion&&typeof Ue.completion!=="boolean"||!Ue.completion){t.completion="settings"}Ve=new x(e.extend({},Ue.extra,{name:Ue.name,prompt:Ue.prompt,keypress:Ue.keypress,keydown:Ue.keydown,resize:Ue.onResize,greetings:Ue.greetings,mousewheel:Ue.mousewheel,keymap:mn},t));Qe=e("
").appendTo(tn).cmd({prompt:Ue.prompt,history:Ue.memory?"memory":Ue.history,historyFilter:Ue.historyFilter,historySize:Ue.historySize,caseSensitiveSearch:Ue.caseSensitiveSearch,width:"100%",enabled:false,keydown:le,keymap:mn,clickTimeout:Ue.clickTimeout,keypress:function(n){var t=Ve.top();if(Je&&(!Ge||!Ue.pauseEvents)){if(e.isFunction(t.keypress)){return t.keypress.call(ge,n,ge)}else if(e.isFunction(Ue.keypress)){return Ue.keypress.call(ge,n,ge)}}},onCommandChange:function(n){if(e.isFunction(Ue.onCommandChange)){try{Ue.onCommandChange.call(ge,n,ge)}catch(n){Ue.onCommandChange=e.noop;_(n,"onCommandChange")}}k()},commands:W});function r(n){n=n.originalEvent;if(n){var t=document.elementFromPoint(n.clientX,n.clientY);if(!e(t).closest(".terminal").length&&ge.enabled()){ge.disable()}}}ge.oneTime(100,function(){e(document).bind("click.terminal_"+ge.id(),r).bind("contextmenu.terminal_"+ge.id(),r)});var i=e(window);document.addEventListener("resume",function(){ge.disable()});if(Z){ge.click(function(){if(!Ye){if(!ge.enabled()){ge.focus();Qe.enable()}else{ge.disable()}}})}else{i.on("focus.terminal_"+ge.id(),un).on("blur.terminal_"+ge.id(),cn);(function(){var n=0;var t;var r="click_"+ge.id();var i=ge.find("textarea");function o(){if(t.is(".terminal")||t.is(".terminal-wrapper")){var e=ge.get_command().length;ge.set_position(e)}else if(t.closest(".prompt").length){ge.set_position(0)}if(!i.is(":focus")){i.focus()}a()}function a(){n=0;t=null}ge.mousedown(function(n){if(!b(n,on)){t=e(n.target)}}).mouseup(function(){if(ee()===""&&t){if(++n===1){if(!Ye){if(!Je){ge.focus()}else{var e=Ue.clickTimeout;ge.oneTime(e,r,o);return}}}else{ge.stopTime(r)}}a()}).dblclick(function(){a();ge.stopTime(r)})})();(function(){var n=ge.find("textarea");ge.on("contextmenu.terminal",function(t){if(ee()===""){if(!e(t.target).is("img,value,audio,object,canvas,a")){if(!ge.enabled()){ge.enable()}var r=Qe.offset();n.css({left:t.pageX-r.left-20,top:t.pageY-r.top-20,width:"5em",height:"4em"});if(!n.is(":focus")){n.focus()}ge.stopTime("textarea");ge.oneTime(100,"textarea",function(){n.css({left:"",top:"",width:"",height:""})});ge.stopTime("selection");ge.everyTime(20,"selection",function(){if(n[0].selection!==n[0].value){if(te(n[0])){re(n[0]);ie(ge.find(".terminal-output")[0],ge.find(".cmd div:last-of-type")[0]);ge.stopTime("selection")}}})}}})})()}ge.delegate("a","mouseup",function(n){var t=e(this);if(t.closest(".exception").length){var r=t.attr("href");if(r.match(/:[0-9]+$/)){n.preventDefault();f(r)}}ge.find("textarea").focus()});if(ge.is(":visible")){je=ge.cols();Qe.resize(je);if(!Ne){Ne=ue(ge)}Le=pe(ge,Ne)}function o(){if(ge.is(":visible")){var e=on.width();var n=on.height();if(Me!==n||We!==e){ge.resize()}Me=n;We=e}}function a(){ge.resizer("unbind").resizer(o);rn.resizer("unbind").resizer(function(){Ne=ue(ge);ge.resize()})}if(ge.is(":visible")){a()}function s(){if(en){en.unobserve(ge[0])}var n=ge.enabled();var t=ge.is(":visible");if(t){a()}en=new IntersectionObserver(function(){if(ge.is(":visible")&&!t){t=true;a();Ne=ue(ge);o();if(n){ge.enable()}}else if(t&&!ge.is(":visible")){t=false;n=e.terminal.active()===ge&&ge.enabled();ge.disable()}},{root:document.body});en.observe(ge[0])}var l=!!ge.closest("body").length;var u=window.MutationObserver||window.WebKitMutationObserver;if(window.IntersectionObserver){if(u){nn=new u(function(){if(ge.closest("body").length){if(!l){ge.scroll_to_bottom();s()}l=true}else if(l){l=false}});nn.observe(document.body,{childList:true})}if(l){s()}}Ie.resolve();if(Je&&ge.is(":visible")&&!Z){ge.focus(n,true)}else{ge.disable()}if(e.isFunction(fn)){ge.login(fn,true,X)}else{X()}function c(n){var t=ke.get()[n[0]];if(t&&Fe===t.id()){if(n[2]){try{if(Ge){var r=e.Deferred();B.push(function(){return t.exec(n[2]).done(function(){t.save_state(n[2],true,n[1]);r.resolve()})});return r.promise()}else{return t.exec(n[2]).done(function(){t.save_state(n[2],true,n[1])})}}catch(n){var i=t.settings();if(e.isFunction(i.exceptionHandler)){i.exceptionHandler.call(ge,n,"EXEC HASH")}else{var o=e.terminal.escape_brackets(Oe);var a="Error while exec with command "+o;t.error(a).exception(n)}}}}}if(Ue.execHash){if(location.hash){setTimeout(function(){try{var e=location.hash.replace(/^#/,"");Te=JSON.parse(decodeURIComponent(e));var n=0;(function e(){var t=Te[n++];if(t){c(t).done(e)}else{Ce=true}})()}catch(e){}})}else{Ce=true}}else{Ce=true}var p=false;e(document).bind("keydown.terminal_"+ge.id(),function(e){if(e.shiftKey){p=true}}).bind("keyup.terminal_"+ge.id(),function(e){if(e.shiftKey||e.which===16){p=false}});function m(n,t){if(!p){var r=Ve.top();var i;if(e.isFunction(r.mousewheel)){i=r.mousewheel(n,t,ge)}else if(e.isFunction(Ue.mousewheel)){i=Ue.mousewheel(n,t,ge)}if(P()||i===false){n.stopPropagation();n.preventDefault()}if(i===false){return}if(t>0){ge.scroll(-40)}else{ge.scroll(40)}}}if(e.event.special.mousewheel){ge.on("mousewheel",m)}else{var h;var d=document.createElement("div");if("onwheel"in d){h="wheel"}else if(document.onmousewheel!==n){h="mousewheel"}else{h="DOMMouseScroll"}d=null;ge.on(h,function(e){var n;if(h==="mousewheel"){n=-1/40*e.originalEvent.wheelDelta}else{n=e.originalEvent.deltaY||e.originalEvent.detail}m(e,-n)})}});ge.data("terminal",ge);return ge}});
\ No newline at end of file
diff --git a/js/unix_formatting.js b/js/unix_formatting.js
index da0ead3d5..b835037ff 100644
--- a/js/unix_formatting.js
+++ b/js/unix_formatting.js
@@ -18,6 +18,9 @@
if (!$.terminal) {
throw new Error('$.terminal is not defined');
}
+
+ $.terminal.defaults.unixFormattingEscapeBrackets = false;
+
// ---------------------------------------------------------------------
// :: Replace overtyping (from man) formatting with terminal formatting
// ---------------------------------------------------------------------
@@ -243,13 +246,21 @@
}
return [styles.join(''), color, background];
}
- return function from_ansi(input) {
+ return function from_ansi(input, options) {
+
+ var settings = $.extend({
+ unixFormattingEscapeBrackets: false
+ }, options);
+
//merge multiple codes
/*input = input.replace(/((?:\x1B\[[0-9;]*[A-Za-z])*)/g, function(group) {
return group.replace(/m\x1B\[/g, ';');
});*/
var splitted = input.split(/(\x1B\[[0-9;]*[A-Za-z])/g);
if (splitted.length === 1) {
+ if (settings.unixFormattingEscapeBrackets) {
+ return $.terminal.escape_brackets(input);
+ }
return input;
}
var output = [];
@@ -304,6 +315,8 @@
}
break;
}
+ } else if (settings.unixFormattingEscapeBrackets) {
+ output.push($.terminal.escape_brackets(splitted[i]));
} else {
output.push(splitted[i]);
}
@@ -314,6 +327,7 @@
return output.join(''); //.replace(/\[\[[^\]]+\]\]/g, '');
};
})();
+
$.terminal.defaults.formatters.unshift($.terminal.overtyping);
$.terminal.defaults.formatters.unshift($.terminal.from_ansi);
})(jQuery);
diff --git a/spec/terminalSpec.js b/spec/terminalSpec.js
index 5d51ce6b9..5cbfa30b3 100644
--- a/spec/terminalSpec.js
+++ b/spec/terminalSpec.js
@@ -240,12 +240,21 @@ function tests_on_ready() {
});
});
});
- var ansi_string = '\x1b[2;31;46mFoo\x1b[1;3;4;32;45mBar\x1b[0m\x1b[7mBaz';
+ var ansi_string = '\x1b[2;31;46mFoo\x1b[1;3;4;32;45mB[[sb;;]a]r\x1b[0m\x1b[7mBaz';
describe('$.terminal.from_ansi', function() {
it('should convert ansi to terminal formatting', function() {
var string = $.terminal.from_ansi(ansi_string);
expect(string).toEqual('[[;#640000;#008787]Foo][[biu;#44D544;#F5F]'+
- 'Bar][[;#000;#AAA]Baz]');
+ 'B[[sb;;]a]r][[;#000;#AAA]Baz]');
+ });
+ });
+ describe('$.terminal.from_ansi', function() {
+ it('should convert ansi to terminal formatting and escape the remaining brackets', function() {
+ var string = $.terminal.from_ansi(ansi_string, {
+ unixFormattingEscapeBrackets: true
+ });
+ expect(string).toEqual('[[;#640000;#008787]Foo][[biu;#44D544;#F5F]'+
+ 'B[[sb;;]a]r][[;#000;#AAA]Baz]');
});
});
describe('$.terminal.overtyping', function() {
@@ -265,10 +274,20 @@ function tests_on_ready() {
});
});
describe('$.terminal.nested_formatting', function() {
- var string = '[[;#fff;] lorem [[b;;]ipsum [[s;;]dolor] sit] amet]';
- var result = '[[;#fff;] lorem ][[b;;]ipsum ][[s;;]dolor][[b;;] sit][[;#fff;] amet]';
+ var specs = [
+ [
+ '[[;red;]foo[[;blue;]bar]baz]',
+ '[[;red;]foo][[;blue;]bar][[;red;]baz]'
+ ],
+ [
+ '[[;#fff;] lorem [[b;;]ipsum [[s;;]dolor] sit] amet]',
+ '[[;#fff;] lorem ][[b;;]ipsum ][[s;;]dolor][[b;;] sit][[;#fff;] amet]'
+ ]
+ ];
it('should create list of formatting', function() {
- expect($.terminal.nested_formatting(string)).toEqual(result);
+ specs.forEach(function(spec) {
+ expect($.terminal.nested_formatting(spec[0])).toEqual(spec[1]);
+ });
});
});
describe('$.terminal.encode', function() {
@@ -312,6 +331,22 @@ function tests_on_ready() {
expect($.terminal.substring(input, 0, spec[0])).toEqual(spec[1]);
});
});
+ it('should create formatting for each character', function() {
+ var formatting = '[[b;;;token number]10][[b;;;token operator]+][[b;;;token number]10]';
+
+ var len = $.terminal.strip(formatting).length;
+ var result = [];
+ for (var i = 0; i < len; ++i) {
+ result.push($.terminal.substring(formatting, i,i+1));
+ }
+ expect(result).toEqual([
+ '[[b;;;token number]1]',
+ '[[b;;;token number]0]',
+ '[[b;;;token operator]+]',
+ '[[b;;;token number]1]',
+ '[[b;;;token number]0]'
+ ]);
+ });
it('should return substring when ending at length or larger', function() {
var tests = [
[0, '[[;;]Lorem ipsum dolor sit amet], [[;;]consectetur adipiscing elit]. [[;;]Maecenas ac massa tellus. Sed ac feugiat leo].'],
@@ -453,6 +488,43 @@ function tests_on_ready() {
expect($.terminal.strip(formatting)).toEqual(result);
});
});
+ describe('$.terminal.apply_formatters', function() {
+ var formatters;
+ beforeEach(function() {
+ formatters = $.terminal.defaults.formatters;
+ });
+ afterEach(function() {
+ $.terminal.defaults.formatters = formatters;
+ });
+ it('should apply function formatters', function() {
+ $.terminal.defaults.formatters = [
+ function(str) {
+ return str.replace(/a/g, '[[;;;A]a]');
+ },
+ function(str) {
+ return str.replace(/b/g, '[[;;;B]b]');
+ }
+ ];
+ var input = 'aaa bbb';
+ var output = '[[;;;A]a][[;;;A]a][[;;;A]a] [[;;;B]b][[;;;B]b][[;;;B]b]';
+ expect($.terminal.apply_formatters(input)).toEqual(output);
+ });
+ it('should apply __meta__ and array formatter', function() {
+ var input = 'lorem ipsum';
+ var output = '[[;;]lorem] ipsum';
+ var test = {
+ formatter: function(string) {
+ expect(string).toEqual(output);
+ return string.replace(/ipsum/g, '[[;;]ipsum]');
+ }
+ };
+ spy(test, 'formatter');
+ test.formatter.__meta__ = true;
+ $.terminal.defaults.formatters = [[/lorem/, '[[;;]lorem]'], test.formatter];
+ expect($.terminal.apply_formatters(input)).toEqual('[[;;]lorem] [[;;]ipsum]');
+ expect(test.formatter).toHaveBeenCalled();
+ });
+ });
describe('$.terminal.split_equal', function() {
var text = ['[[bui;#fff;]Lorem ipsum dolor sit amet, consectetur adipi',
'scing elit. Nulla sed dolor nisl, in suscipit justo. Donec a enim',
@@ -649,6 +721,15 @@ function tests_on_ready() {
expect(array).toEqual(test.output);
});
});
+ it('should handle new line as first character of formatting #375', function() {
+ var specs = [
+ ['A[[;;]\n]B', ['A', 'B']],
+ ['A[[;;]\nB]C', ['A', '[[;;;;\\nB]B]C']]
+ ];
+ specs.forEach(function(spec) {
+ expect($.terminal.split_equal(spec[0])).toEqual(spec[1]);
+ });
+ });
});
describe('Cycle', function() {
describe('create', function() {
@@ -994,34 +1075,12 @@ function tests_on_ready() {
describe('resizer', function() {
it('should create html', function() {
var div = $('
').resizer($.noop);
- expect(div.find('.resize-sensor-expand').length).toEqual(1);
- expect(div.find('.resize-sensor-shrink').length).toEqual(1);
- expect(div.find('.resizer').length).toEqual(1);
+ expect(div.find('iframe').length).toEqual(1);
});
it('should remove html', function() {
var div = $('
').resizer($.noop);
div.resizer('unbind');
- expect(div.find('.resize-sensor-expand').length).toEqual(0);
- expect(div.find('.resize-sensor-shrink').length).toEqual(0);
- expect(div.find('.resizer').length).toEqual(0);
- });
- it('should fire event on scroll event', function(done) {
- var test = {
- test: function() {}
- };
- spy(test, 'test');
- var div = $('
').css({
- width: 100,
- height: 100
- }).appendTo('body').resizer(test.test);
- div.css({
- width: 200
- });
- div.find('.resize-sensor-shrink').trigger('scroll');
- setTimeout(function() {
- expect(test.test).toHaveBeenCalled();
- done();
- }, 100);
+ expect(div.find('iframe').length).toEqual(0);
});
});
describe('text_length', function() {
@@ -2140,6 +2199,22 @@ function tests_on_ready() {
term.clear();
expect(term.find('.terminal-output').html()).toEqual('');
});
+ it('should save commands in hash', function() {
+ location.hash = '';
+ term.save_state(); // initial state
+ term.save_state('foo');
+ term.save_state('bar');
+ var id = term.id();
+ var hash = '#' + JSON.stringify([[id,1,"foo"],[id,2,"bar"]]);
+ expect(decodeURIComponent(location.hash)).toEqual(hash);
+ term.destroy().remove();
+ });
+ describe('import/export view', function() {
+ var term = $('
').appendTo('body').terminal($.noop, {
+ name: terminal_name,
+ greetings: greetings,
+ completion: completion
+ });
it('should export view', function() {
enter(term, 'foo');
enter(term, 'bar');
@@ -2149,18 +2224,18 @@ function tests_on_ready() {
position = term.cmd().position();
exported_view = term.export_view();
expect(exported_view.prompt).toEqual(prompt);
- expect(exported_view.position).toEqual(command.length);
+ expect(exported_view.position).toEqual(position);
expect(exported_view.focus).toEqual(true);
expect(exported_view.mask).toEqual(mask);
expect(exported_view.command).toEqual(command);
- expect(exported_view.lines[0][0]).toEqual('> foo');
- expect(exported_view.lines[1][0]).toEqual('> bar');
+ expect(exported_view.lines[0][0]).toEqual('Hello World!');
+ expect(exported_view.lines[1][0]).toEqual('> foo');
+ expect(exported_view.lines[2][0]).toEqual('> bar');
expect(exported_view.interpreters.size()).toEqual(1);
var top = exported_view.interpreters.top();
expect(top.interpreter).toEqual($.noop);
expect(top.name).toEqual(terminal_name);
expect(top.prompt).toEqual(prompt);
- expect(top.prompt).toEqual(prompt);
expect(top.greetings).toEqual(greetings);
expect(top.completion).toEqual('settings');
});
@@ -2175,23 +2250,15 @@ function tests_on_ready() {
expect(term.get_command()).toEqual(command);
expect(term.get_prompt()).toEqual(prompt);
expect(cmd.position()).toEqual(position);
- var html = '
'+
- '
';
+ var html = '
'+
+ '
'+
+ '
';
expect(term.find('.terminal-output').html()).toEqual(html);
});
- it('should save commands in hash', function() {
- location.hash = '';
- term.save_state(); // initial state
- term.save_state('foo');
- term.save_state('bar');
- var id = term.id();
- var hash = '#' + JSON.stringify([[id,1,"foo"],[id,2,"bar"]]);
- expect(decodeURIComponent(location.hash)).toEqual(hash);
- term.destroy().remove();
});
describe('exec', function() {
var counter = 0;
@@ -3565,6 +3632,176 @@ function tests_on_ready() {
expect(term.before_cursor()).toEqual('foo bar b');
});
});
+ describe('set_command/get_command', function() {
+ var term = $('
').terminal($.noop, {
+ prompt: 'foo> '
+ });
+ it('should return init prompt', function() {
+ expect(term.get_prompt()).toEqual('foo> ');
+ });
+ it('should return new prompt', function() {
+ var prompt = 'bar> ';
+ term.set_prompt(prompt);
+ expect(term.get_prompt()).toEqual(prompt);
+ });
+ });
+ describe('complete', function() {
+ var term = $('
').terminal();
+ function test(specs, options) {
+ specs.forEach(function(spec) {
+ term.focus();
+ // complete method resets tab count when you press non-tab
+ shortcut(false, false, false, 37, 'arrowleft');
+ term.set_command(spec[0]);
+ expect(term.complete(spec[1], options)).toBe(spec[2]);
+ expect(term.get_command()).toEqual(spec[3]);
+ });
+ }
+ it('should complete whole word', function() {
+ test([
+ ['f', ['foo', 'bar'], true, 'foo'],
+ ['b', ['foo', 'bar'], true, 'bar'],
+ ['F', ['FOO', 'BAR'], true, 'FOO'],
+ ['f', ['FOO', 'BAR'], undefined, 'f']
+ ]);
+ });
+ it('should complete common string', function() {
+ test([
+ ['f', ['foo-bar', 'foo-baz'], true, 'foo-ba'],
+ ['f', ['fooBar', 'fooBaz'], true, 'fooBa']
+ ]);
+ });
+ it("should complete word that don't match case", function() {
+ test([
+ ['f', ['FOO-BAZ', 'FOO-BAR'], true, 'foo-ba'],
+ ['f', ['FooBar', 'FooBaz'], true, 'fooBa'],
+ ['Foo', ['FOO-BAZ', 'FOO-BAR'], true, 'Foo-BA'],
+ ['FOO', ['FOO-BAZ', 'FOO-BAR'], true, 'FOO-BA'],
+ ], {
+ caseSensitive: false
+ });
+ });
+ it('should complete whole line', function() {
+ var completion = ['lorem ipsum dolor sit amet', 'foo bar baz'];
+ test([
+ ['"lorem ipsum', completion, true, '"lorem ipsum dolor sit amet"'],
+ ['lorem\\ ipsum', completion, true, 'lorem\\ ipsum\\ dolor\\ sit\\ amet'],
+ ]);
+ test([
+ ['lorem', completion, true, completion[0]],
+ ['lorem ipsum', completion, true, completion[0]]
+ ], {
+ word: false,
+ escape: false
+ });
+ });
+ it('should echo all matched strings', function() {
+ var completion = ['foo-bar', 'foo-baz', 'foo-quux'];
+ term.clear().focus();
+ term.set_command('f');
+ term.complete(completion, {echo: true});
+ term.complete(completion, {echo: true});
+ var re = new RegExp('^>\\sfoo-\\n' + completion.join('\\s+') + '$');
+ var output = term.find('.terminal-output > div').map(function() {
+ return $(this).text();
+ }).get().join('\n');
+ expect(output.match(re)).toBeTruthy();
+ });
+ });
+ describe('get_output', function() {
+ var term = $('
').terminal($.noop, {greetings: false});
+ it('should return string out of all lines', function() {
+ term.echo('foo');
+ term.echo('bar');
+ term.focus().set_command('quux');
+ enter_key();
+ expect(term.get_output()).toEqual('foo\nbar\n> quux');
+ });
+ });
+ describe('update', function() {
+ var term = $('
').terminal();
+ function last_line() {
+ return last_div().find('div');
+ }
+ function last_div() {
+ return term.find('.terminal-output > div:last-child');
+ }
+ it('should update last line', function() {
+ term.echo('foo');
+ expect(last_line().text()).toEqual('foo');
+ term.update(-1, 'bar');
+ expect(last_line().text()).toEqual('bar');
+ });
+ it('should remove last line', function() {
+ var index = term.last_index();
+ term.echo('quux');
+ expect(term.last_index()).toEqual(index + 1);
+ term.update(index + 1, null);
+ expect(term.last_index()).toEqual(index);
+ });
+ it('should call finalize', function() {
+ var options = {
+ finalize: function() {}
+ };
+ spy(options, 'finalize');
+ term.update(-1, 'baz', options);
+ expect(options.finalize).toHaveBeenCalled();
+ });
+ });
+ describe('keymap', function() {
+ var term;
+ var test;
+ beforeEach(function() {
+ term = $('
').terminal();
+ test = {
+ empty: function() {},
+ original: function(e, original) {
+ original();
+ }
+ };
+ spy(test, 'empty');
+ spy(test, 'original');
+ });
+ it('should set and call keymap shortcut', function() {
+ term.keymap('CTRL+T', test.empty);
+ shortcut(true, false, false, 84, 't');
+ expect(test.empty).toHaveBeenCalled();
+ });
+ it('should create keymap from object', function() {
+ term.keymap({
+ 'CTRL+T': test.empty
+ });
+ shortcut(true, false, false, 84, 't');
+ expect(test.empty).toHaveBeenCalled();
+ });
+ it('should overwrite terminal keymap', function() {
+ term.echo('foo');
+ shortcut(true, false, false, 76, 'l');
+ expect(term.get_output()).toEqual('');
+ term.echo('bar');
+ term.keymap('CTRL+L', test.empty);
+ shortcut(true, false, false, 76, 'l');
+ expect(term.get_output()).not.toEqual('');
+ });
+ it('should call default terminal keymap', function() {
+ term.echo('foo');
+ term.keymap('CTRL+L', test.original);
+ shortcut(true, false, false, 76, 'l');
+ expect(term.get_output()).toEqual('');
+ });
+ it('should overwrite cmd keymap', function() {
+ term.set_command('foo');
+ term.keymap('ENTER', test.empty);
+ enter_key();
+ expect(term.get_command()).toEqual('foo');
+ });
+ it('should call default cmd keymap', function() {
+ term.set_command('foo');
+ term.keymap('ENTER', test.original);
+ enter_key();
+ expect(term.get_command()).toEqual('');
+ });
+ });
});
});
}
diff --git a/Makefile.in b/templates/Makefile.in
similarity index 86%
rename from Makefile.in
rename to templates/Makefile.in
index 8095c5141..3ed18dd7b 100644
--- a/Makefile.in
+++ b/templates/Makefile.in
@@ -18,13 +18,15 @@ SPEC_CHECKSUM=`md5sum spec/terminalSpec.js | cut -d' ' -f 1`
COMMIT=`git log -n 1 | grep commit | sed 's/commit //'`
URL=`git config --get remote.origin.url`
+.PHONY: coverage
+
ALL: Makefile .$(VERSION) terminal.jquery.json bower.json package.json js/jquery.terminal-$(VERSION).js js/jquery.terminal.js js/jquery.terminal-$(VERSION).min.js js/jquery.terminal.min.js css/jquery.terminal-$(VERSION).css css/jquery.terminal-$(VERSION).min.css css/jquery.terminal.min.css css/jquery.terminal.css README.md import.html js/terminal.widget.js www/Makefile
-bower.json: bower.in .$(VERSION)
- $(SED) -e "s/{{VER}}/$(VERSION)/g" bower.in > bower.json
+bower.json: templates/bower.in .$(VERSION)
+ $(SED) -e "s/{{VER}}/$(VERSION)/g" templates/bower.in > bower.json
-package.json: package.in .$(VERSION)
- $(SED) -e "s/{{VER}}/$(VERSION)/g" package.in > package.json
+package.json: templates/package.in .$(VERSION)
+ $(SED) -e "s/{{VER}}/$(VERSION)/g" templates/package.in > package.json
js/jquery.terminal-$(VERSION).js: js/jquery.terminal-src.js .$(VERSION)
$(GIT) branch | grep '* devel' > /dev/null && $(SED) -e "s/{{VER}}/DEV/g" -e "s/{{DATE}}/$(DATE)/g" js/jquery.terminal-src.js > js/jquery.terminal-$(VERSION).js || $(SED) -e "s/{{VER}}/$(VERSION)/g" -e "s/{{DATE}}/$(DATE)/g" js/jquery.terminal-src.js > js/jquery.terminal-$(VERSION).js
@@ -50,21 +52,21 @@ css/jquery.terminal.min.css: css/jquery.terminal-$(VERSION).min.css
css/jquery.terminal-$(VERSION).min.css: css/jquery.terminal-$(VERSION).css
$(CSSNANO) css/jquery.terminal-$(VERSION).css css/jquery.terminal-$(VERSION).min.css --no-discardUnused --safe
-README.md: README.in .$(VERSION)
+README.md: templates/README.in .$(VERSION)
$(GIT) branch | grep '* devel' > /dev/null && $(SED) -e "s/{{VER}}/DEV/g" -e \
"s/{{BRANCH}}/$(BRANCH)/g" -e "s/{{CHECKSUM}}/$(SPEC_CHECKSUM)/" \
- -e "s/{{COMMIT}}/$(COMMIT)/g" < README.in > README.md || $(SED) -e \
+ -e "s/{{COMMIT}}/$(COMMIT)/g" < templates/README.in > README.md || $(SED) -e \
"s/{{VER}}/$(VERSION)/g" -e "s/{{BRANCH}}/$(BRANCH)/g" -e \
- "s/{{CHECKSUM}}/$(SPEC_CHECKSUM)/" -e "s/{{COMMIT}}/$(COMMIT)/g" < README.in > README.md
+ "s/{{CHECKSUM}}/$(SPEC_CHECKSUM)/" -e "s/{{COMMIT}}/$(COMMIT)/g" < templates/README.in > README.md
.$(VERSION): Makefile
touch .$(VERSION)
-Makefile: Makefile.in
- $(SED) -e "s/{{VER""SION}}/"$(VERSION)"/" Makefile.in > Makefile
+Makefile: templates/Makefile.in
+ $(SED) -e "s/{{VER""SION}}/"$(VERSION)"/" templates/Makefile.in > Makefile
-import.html: import.in
- $(SED) -e "s/{{BRANCH}}/$(BRANCH)/g" import.in > import.html
+import.html: templates/import.in
+ $(SED) -e "s/{{BRANCH}}/$(BRANCH)/g" templates/import.in > import.html
js/terminal.widget.js: js/terminal.widget.in
$(GIT) branch | grep '* devel' > /dev/null || $(SED) -e "s/{{VER}}/$(VERSION)/g" js/terminal.widget.in > js/terminal.widget.js
@@ -78,7 +80,7 @@ www/Makefile: $(wildcard www/Makefile.in) Makefile .$(VERSION)
test:
$(JASMINE) --captureExceptions --verbose --junitreport --color --forceexit spec
-cover:
+coverage:
$(ISTANBUL) cover node_modules/jasmine/bin/jasmine.js
coveralls:
diff --git a/README.in b/templates/README.in
similarity index 98%
rename from README.in
rename to templates/README.in
index a2136a875..ca544c1b2 100644
--- a/README.in
+++ b/templates/README.in
@@ -15,6 +15,7 @@ http://terminal.jcubic.pl
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch={{BRANCH}}&{{CHECKSUM}})](https://coveralls.io/github/jcubic/jquery.terminal?branch={{BRANCH}})
![downloads](https://img.shields.io/npm/dm/jquery.terminal.svg?style=flat)
[![package quality](http://npm.packagequality.com/shield/jquery.terminal.svg)](http://packagequality.com/#?package=jquery.terminal)
+[![](https://data.jsdelivr.com/v1/package/npm/jquery.terminal/badge?style=rounded)](https://www.jsdelivr.com/package/npm/jquery.terminal)
### Summary
diff --git a/bower.in b/templates/bower.in
similarity index 100%
rename from bower.in
rename to templates/bower.in
diff --git a/import.in b/templates/import.in
similarity index 100%
rename from import.in
rename to templates/import.in
diff --git a/package.in b/templates/package.in
similarity index 100%
rename from package.in
rename to templates/package.in