Skip to content

Commit

Permalink
Merge 3a80675 into 9e757de
Browse files Browse the repository at this point in the history
  • Loading branch information
ml1nk committed Mar 4, 2018
2 parents 9e757de + 3a80675 commit 6b9b930
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 17 deletions.
31 changes: 26 additions & 5 deletions js/jquery.terminal-1.12.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
* 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:
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-1.12.1.min.js

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)) {
Expand Down
31 changes: 26 additions & 5 deletions js/jquery.terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
* 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:
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions spec/terminalSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2912,6 +2912,16 @@ function tests_on_ready() {
term.clear().echo(line, {keepWords: true});
expect(output()).toEqual(lines);
});
// in cases where no formatter intervenes
it('input minus line breaks should be equal text()', function() {
term.clear().echo('A[[;;]B\nC]D');
expect(term.find('.terminal-output').text()).toEqual('ABCD');
term.clear().echo('A[[;;]\nC]D');
expect(term.find('.terminal-output').text()).toEqual('ACD');
term.clear().echo('A[[;;]\n]D');
expect(term.find('.terminal-output').text()).toEqual('AD');
term.clear();
});
it('should echo both lines if one was not flushed', function() {
term.clear();
term.echo('foo', {flush: false});
Expand Down

0 comments on commit 6b9b930

Please sign in to comment.