Skip to content

Commit

Permalink
Fix resizing and wrapping on update
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Dec 28, 2017
1 parent 3369273 commit 039ac01
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 92 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
## Next
## 1.11.2
* fix issue with --char-width == 0 if terminal have display:none
* fix DELETE numpad key on IE
* ignore invalid procedures description in system.describe
* fix font resizer and init resizers when terminal hidden initialy
* fix broken wrapping in new feature of updating divs on resize


## 1.11.1
* fix IE inconsistency in key property for numpad calc keys (reported by @ovk [#362](https://github.com/jcubic/jquery.terminal/issues/362)
Expand Down
6 changes: 3 additions & 3 deletions css/jquery.terminal-1.11.1.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2011-2017 Jakub Jankiewicz <http://jcubic.pl>
* Released under the MIT license
*
* Date: Wed, 27 Dec 2017 14:27:58 +0000
* Date: Thu, 28 Dec 2017 08:36:02 +0000
*/
.terminal .terminal-output .format, .cmd .format,
.cmd .prompt, .cmd .prompt div, .terminal .terminal-output div div{
Expand Down Expand Up @@ -462,8 +462,8 @@ terminal .terminal-output > div {
background-color: var(--background, #000);
}
.terminal .font {
width: calc(var(--size) * 1em);
height: calc(var(--size) * 1em);
width: calc(var(--size, 1) * 1em);
height: calc(var(--size, 1) * 1em);
}
.terminal span[style*="--length"] {
width: calc(var(--length, 1) * var(--char-width) * 1px);
Expand Down
4 changes: 2 additions & 2 deletions css/jquery.terminal-1.11.1.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions css/jquery.terminal-src.css
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,8 @@ terminal .terminal-output > div {
background-color: var(--background, #000);
}
.terminal .font {
width: calc(var(--size) * 1em);
height: calc(var(--size) * 1em);
width: calc(var(--size, 1) * 1em);
height: calc(var(--size, 1) * 1em);
}
.terminal span[style*="--length"] {
width: calc(var(--length, 1) * var(--char-width) * 1px);
Expand Down
6 changes: 3 additions & 3 deletions css/jquery.terminal.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2011-2017 Jakub Jankiewicz <http://jcubic.pl>
* Released under the MIT license
*
* Date: Wed, 27 Dec 2017 14:27:58 +0000
* Date: Thu, 28 Dec 2017 08:36:02 +0000
*/
.terminal .terminal-output .format, .cmd .format,
.cmd .prompt, .cmd .prompt div, .terminal .terminal-output div div{
Expand Down Expand Up @@ -462,8 +462,8 @@ terminal .terminal-output > div {
background-color: var(--background, #000);
}
.terminal .font {
width: calc(var(--size) * 1em);
height: calc(var(--size) * 1em);
width: calc(var(--size, 1) * 1em);
height: calc(var(--size, 1) * 1em);
}
.terminal span[style*="--length"] {
width: calc(var(--length, 1) * var(--char-width) * 1px);
Expand Down
4 changes: 2 additions & 2 deletions css/jquery.terminal.min.css

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions js/dterm.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
$.fn.dterm = function(interpreter, options) {
var op = $.extend_if_has({}, options, defaults);
op.enabled = false;
var terminal = $('<div/>').appendTo(this)
.terminal(interpreter, op);
var terminal = this.terminal(interpreter, op);
if (!options.title) {
options.title = 'JQuery Terminal Emulator';
}
Expand Down
38 changes: 13 additions & 25 deletions js/jquery.terminal-1.11.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: Wed, 27 Dec 2017 20:33:43 +0000
* Date: Thu, 28 Dec 2017 08:36:01 +0000
*/

/* TODO:
Expand Down Expand Up @@ -2797,7 +2797,7 @@
}
$.terminal = {
version: 'DEV',
date: 'Wed, 27 Dec 2017 20:33:43 +0000',
date: 'Thu, 28 Dec 2017 08:36:01 +0000',
// colors from http://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -4518,8 +4518,6 @@
for (i = 0, len = array.length; i < len; ++i) {
if (array[i] === '' || array[i] === '\r') {
output_buffer.push('<span></span>');
} else if (options.raw) {
output_buffer.push(array[i]);
} else {
output_buffer.push($.terminal.format(array[i], {
linksNoReferrer: settings.linksNoReferrer
Expand Down Expand Up @@ -4589,6 +4587,7 @@
return string;
}
}).join('');
// string can be empty after removing extended commands
if (string !== '') {
if (!line_settings.raw) {
if (settings.convertLinks) {
Expand All @@ -4604,7 +4603,6 @@
}
string = $.terminal.encode(string);
}
// string can be empty after removing extended commands
buffer_line(string, line.index, line_settings);
}
}
Expand All @@ -4623,7 +4621,9 @@
// ---------------------------------------------------------------------
function redraw(options) {
options = $.extend({}, {
// should be used when single line is updated
update: false,
// should be used if you want to scroll to bottom after redraw
scroll: true
}, options || {});
if (!options.update) {
Expand Down Expand Up @@ -4652,26 +4652,11 @@
if ($.type(string) !== 'string') {
string = String(string);
}
if (strlen(string) > num_chars) {
var splitted = $.terminal.split_equal(
string,
num_chars,
options.keepWords
).map(function(string) {
return {
string: string,
index: index,
options: options
};
});
lines_to_show = lines_to_show.concat(splitted);
} else {
lines_to_show.push({
string: string,
index: index,
options: options
});
}
lines_to_show.push({
string: string,
index: index,
options: options
});
});
lines_to_show = lines_to_show.slice(lines_to_show.length - limit - 1);
} else {
Expand Down Expand Up @@ -7213,6 +7198,9 @@
}
var was_enabled = self.enabled();
var visible = self.is(':visible');
if (visible) {
create_resizers();
}
visibility_observer = new IntersectionObserver(function() {
if (self.is(':visible') && !visible) {
visible = true;
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-1.11.1.min.js

Large diffs are not rendered by default.

34 changes: 11 additions & 23 deletions js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -4518,8 +4518,6 @@
for (i = 0, len = array.length; i < len; ++i) {
if (array[i] === '' || array[i] === '\r') {
output_buffer.push('<span></span>');
} else if (options.raw) {
output_buffer.push(array[i]);
} else {
output_buffer.push($.terminal.format(array[i], {
linksNoReferrer: settings.linksNoReferrer
Expand Down Expand Up @@ -4589,6 +4587,7 @@
return string;
}
}).join('');
// string can be empty after removing extended commands
if (string !== '') {
if (!line_settings.raw) {
if (settings.convertLinks) {
Expand All @@ -4604,7 +4603,6 @@
}
string = $.terminal.encode(string);
}
// string can be empty after removing extended commands
buffer_line(string, line.index, line_settings);
}
}
Expand All @@ -4623,7 +4621,9 @@
// ---------------------------------------------------------------------
function redraw(options) {
options = $.extend({}, {
// should be used when single line is updated
update: false,
// should be used if you want to scroll to bottom after redraw
scroll: true
}, options || {});
if (!options.update) {
Expand Down Expand Up @@ -4652,26 +4652,11 @@
if ($.type(string) !== 'string') {
string = String(string);
}
if (strlen(string) > num_chars) {
var splitted = $.terminal.split_equal(
string,
num_chars,
options.keepWords
).map(function(string) {
return {
string: string,
index: index,
options: options
};
});
lines_to_show = lines_to_show.concat(splitted);
} else {
lines_to_show.push({
string: string,
index: index,
options: options
});
}
lines_to_show.push({
string: string,
index: index,
options: options
});
});
lines_to_show = lines_to_show.slice(lines_to_show.length - limit - 1);
} else {
Expand Down Expand Up @@ -7213,6 +7198,9 @@
}
var was_enabled = self.enabled();
var visible = self.is(':visible');
if (visible) {
create_resizers();
}
visibility_observer = new IntersectionObserver(function() {
if (self.is(':visible') && !visible) {
visible = true;
Expand Down
38 changes: 13 additions & 25 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: Wed, 27 Dec 2017 20:33:43 +0000
* Date: Thu, 28 Dec 2017 08:36:01 +0000
*/

/* TODO:
Expand Down Expand Up @@ -2797,7 +2797,7 @@
}
$.terminal = {
version: 'DEV',
date: 'Wed, 27 Dec 2017 20:33:43 +0000',
date: 'Thu, 28 Dec 2017 08:36:01 +0000',
// colors from http://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -4518,8 +4518,6 @@
for (i = 0, len = array.length; i < len; ++i) {
if (array[i] === '' || array[i] === '\r') {
output_buffer.push('<span></span>');
} else if (options.raw) {
output_buffer.push(array[i]);
} else {
output_buffer.push($.terminal.format(array[i], {
linksNoReferrer: settings.linksNoReferrer
Expand Down Expand Up @@ -4589,6 +4587,7 @@
return string;
}
}).join('');
// string can be empty after removing extended commands
if (string !== '') {
if (!line_settings.raw) {
if (settings.convertLinks) {
Expand All @@ -4604,7 +4603,6 @@
}
string = $.terminal.encode(string);
}
// string can be empty after removing extended commands
buffer_line(string, line.index, line_settings);
}
}
Expand All @@ -4623,7 +4621,9 @@
// ---------------------------------------------------------------------
function redraw(options) {
options = $.extend({}, {
// should be used when single line is updated
update: false,
// should be used if you want to scroll to bottom after redraw
scroll: true
}, options || {});
if (!options.update) {
Expand Down Expand Up @@ -4652,26 +4652,11 @@
if ($.type(string) !== 'string') {
string = String(string);
}
if (strlen(string) > num_chars) {
var splitted = $.terminal.split_equal(
string,
num_chars,
options.keepWords
).map(function(string) {
return {
string: string,
index: index,
options: options
};
});
lines_to_show = lines_to_show.concat(splitted);
} else {
lines_to_show.push({
string: string,
index: index,
options: options
});
}
lines_to_show.push({
string: string,
index: index,
options: options
});
});
lines_to_show = lines_to_show.slice(lines_to_show.length - limit - 1);
} else {
Expand Down Expand Up @@ -7213,6 +7198,9 @@
}
var was_enabled = self.enabled();
var visible = self.is(':visible');
if (visible) {
create_resizers();
}
visibility_observer = new IntersectionObserver(function() {
if (self.is(':visible') && !visible) {
visible = true;
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

0 comments on commit 039ac01

Please sign in to comment.