Skip to content

Commit

Permalink
new API methods buffer_clean() and get_output_buffer() #717
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Dec 13, 2021
1 parent 0299e25 commit 84e2d43
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@
### Features
* add `span` to xml formatting
* allow to use class attribute in XML formatting (`span`, `link`, and `img`)
* new API methods `buffer_clean()` and `get_output_buffer()` [#717](https://github.com/jcubic/jquery.terminal/issues/717)
### Bugfix
* fix bug on Android with GBoard keyboard [#693](https://github.com/jcubic/jquery.terminal/issues/693)
* fix refresh when scrollbar appear (using `scrollbar-gutter`)
Expand Down
2 changes: 1 addition & 1 deletion css/emoji.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion css/jquery.terminal-2.29.5.css
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2011-2021 Jakub Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Wed, 01 Dec 2021 09:19:10 +0000
* Date: Mon, 13 Dec 2021 21:53:28 +0000
*/

.terminal .terminal-output .format, .cmd .format,
Expand Down
2 changes: 1 addition & 1 deletion css/jquery.terminal-2.29.5.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/jquery.terminal.css
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2011-2021 Jakub Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Wed, 01 Dec 2021 09:19:10 +0000
* Date: Mon, 13 Dec 2021 21:53:28 +0000
*/

.terminal .terminal-output .format, .cmd .format,
Expand Down
2 changes: 1 addition & 1 deletion css/jquery.terminal.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/jquery.terminal.min.css.map

Large diffs are not rendered by default.

53 changes: 46 additions & 7 deletions js/jquery.terminal-2.29.5.js
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Mon, 13 Dec 2021 21:50:23 +0000
* Date: Mon, 13 Dec 2021 22:47:44 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -1884,17 +1884,23 @@
this._output_buffer = [];
};
// -------------------------------------------------------------------------
FormatBuffer.prototype.flush = function(render) {
while (this._output_buffer.length) {
var data = this._output_buffer.shift();
FormatBuffer.prototype.forEach = function(fn) {
var i = 0;
while (i < this._output_buffer.length) {
var data = this._output_buffer[i++];
if (data === FormatBuffer.NEW_LINE) {
render();
fn();
} else {
render(data);
fn(data);
}
}
};
// -------------------------------------------------------------------------
FormatBuffer.prototype.flush = function(render) {
this.forEach(render);
this.clear();
};
// -------------------------------------------------------------------------
// :: COMMAND LINE PLUGIN
// -------------------------------------------------------------------------
var cmd_index = 0;
Expand Down Expand Up @@ -5110,7 +5116,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Mon, 13 Dec 2021 21:50:23 +0000',
date: 'Mon, 13 Dec 2021 22:47:44 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -8007,6 +8013,8 @@
array = string.split(/\n/);
}
}
} else {
raw_string = '';
}
var arg = array || string;
if (line_cache && key && use_cache) {
Expand Down Expand Up @@ -10893,6 +10901,37 @@
duplicate: function() {
var copy = $(self);
return $.extend(copy, public_api);
},
// -------------------------------------------------------------
// :: return output flush buffer
// -------------------------------------------------------------
get_output_buffer: function(options) {
var settings = $.extend({
render: true
}, options);
var output = [];
var append = false;
buffer.forEach(function(data) {
if (data) {
if (is_function(data.finalize)) {
append = !data.newline;
} else {
console.log(data);
if (append) {
var last = output.length - 1;
output[last] += data.raw;
} else {
output.push(data.raw);
}
}
}
});
return output;
},
// -------------------------------------------------------------
buffer_clean: function() {
buffer.clear();
return self;
}
}, function(name, fun) {
// wrap all functions and display execptions
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.29.5.min.js

Large diffs are not rendered by default.

49 changes: 44 additions & 5 deletions js/jquery.terminal-src.js
Expand Up @@ -1884,17 +1884,23 @@
this._output_buffer = [];
};
// -------------------------------------------------------------------------
FormatBuffer.prototype.flush = function(render) {
while (this._output_buffer.length) {
var data = this._output_buffer.shift();
FormatBuffer.prototype.forEach = function(fn) {
var i = 0;
while (i < this._output_buffer.length) {
var data = this._output_buffer[i++];
if (data === FormatBuffer.NEW_LINE) {
render();
fn();
} else {
render(data);
fn(data);
}
}
};
// -------------------------------------------------------------------------
FormatBuffer.prototype.flush = function(render) {
this.forEach(render);
this.clear();
};
// -------------------------------------------------------------------------
// :: COMMAND LINE PLUGIN
// -------------------------------------------------------------------------
var cmd_index = 0;
Expand Down Expand Up @@ -8007,6 +8013,8 @@
array = string.split(/\n/);
}
}
} else {
raw_string = '';
}
var arg = array || string;
if (line_cache && key && use_cache) {
Expand Down Expand Up @@ -10893,6 +10901,37 @@
duplicate: function() {
var copy = $(self);
return $.extend(copy, public_api);
},
// -------------------------------------------------------------
// :: return output flush buffer
// -------------------------------------------------------------
get_output_buffer: function(options) {
var settings = $.extend({
render: true
}, options);
var output = [];
var append = false;
buffer.forEach(function(data) {
if (data) {
if (is_function(data.finalize)) {
append = !data.newline;
} else {
console.log(data);
if (append) {
var last = output.length - 1;
output[last] += data.raw;
} else {
output.push(data.raw);
}
}
}
});
return output;
},
// -------------------------------------------------------------
buffer_clean: function() {
buffer.clear();
return self;
}
}, function(name, fun) {
// wrap all functions and display execptions
Expand Down
53 changes: 46 additions & 7 deletions js/jquery.terminal.js
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Mon, 13 Dec 2021 21:50:23 +0000
* Date: Mon, 13 Dec 2021 22:47:44 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -1884,17 +1884,23 @@
this._output_buffer = [];
};
// -------------------------------------------------------------------------
FormatBuffer.prototype.flush = function(render) {
while (this._output_buffer.length) {
var data = this._output_buffer.shift();
FormatBuffer.prototype.forEach = function(fn) {
var i = 0;
while (i < this._output_buffer.length) {
var data = this._output_buffer[i++];
if (data === FormatBuffer.NEW_LINE) {
render();
fn();
} else {
render(data);
fn(data);
}
}
};
// -------------------------------------------------------------------------
FormatBuffer.prototype.flush = function(render) {
this.forEach(render);
this.clear();
};
// -------------------------------------------------------------------------
// :: COMMAND LINE PLUGIN
// -------------------------------------------------------------------------
var cmd_index = 0;
Expand Down Expand Up @@ -5110,7 +5116,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Mon, 13 Dec 2021 21:50:23 +0000',
date: 'Mon, 13 Dec 2021 22:47:44 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -8007,6 +8013,8 @@
array = string.split(/\n/);
}
}
} else {
raw_string = '';
}
var arg = array || string;
if (line_cache && key && use_cache) {
Expand Down Expand Up @@ -10893,6 +10901,37 @@
duplicate: function() {
var copy = $(self);
return $.extend(copy, public_api);
},
// -------------------------------------------------------------
// :: return output flush buffer
// -------------------------------------------------------------
get_output_buffer: function(options) {
var settings = $.extend({
render: true
}, options);
var output = [];
var append = false;
buffer.forEach(function(data) {
if (data) {
if (is_function(data.finalize)) {
append = !data.newline;
} else {
console.log(data);
if (append) {
var last = output.length - 1;
output[last] += data.raw;
} else {
output.push(data.raw);
}
}
}
});
return output;
},
// -------------------------------------------------------------
buffer_clean: function() {
buffer.clear();
return self;
}
}, function(name, fun) {
// wrap all functions and display execptions
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/jquery.terminal.min.js.map

Large diffs are not rendered by default.

0 comments on commit 84e2d43

Please sign in to comment.