Skip to content

Commit

Permalink
merge with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Apr 18, 2021
2 parents 86c9c09 + 04bd453 commit ee371da
Show file tree
Hide file tree
Showing 29 changed files with 10,222 additions and 1,638 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 2.23.0
### Features
* include echo without newline into the core of the library
### Bugfix
* remove unsafe eval (function constructor) that breaks CSP [#647](https://github.com/jcubic/jquery.terminal/issues/647)
* fix up/down arrow when prompt is empty string [651](https://github.com/jcubic/jquery.terminal/issues/651)
* fix ANSI Art (add saving and restoring cursor using ANSI escape code)
* fix mouse wheel and touch scroll in less when content is smaller than height of the terminal
* fix regression in copy/paste with right click

## 2.22.0
### Features
* make unix formatting and basic tools work in web worker
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=2.22.0
VERSION=2.23.0
SED=sed
CD=cd
NPM=npm
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
__ / / // / // / _ / _/ // / / / _ / _/ / / \/ / _ \/ /
/ / / // / // / ___/ // // / / / ___/ // / / / / /\ / // / /__
\___/____ \\__/____/_/ \__ / /_/____/_//_/_/_/_/_/ \/\__\_\___/
\/ /____/ version 2.22.0
\/ /____/ version 2.23.0
```

[JavaScript Library for Web Based Terminal Emulators](https://terminal.jcubic.pl)

[![npm](https://img.shields.io/badge/npm-2.22.0-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
![bower](https://img.shields.io/badge/bower-2.22.0-yellow.svg)
[![travis](https://travis-ci.org/jcubic/jquery.terminal.svg?branch=master&c6ebc691901da774fa782311da7fab9479f376a0)](https://travis-ci.org/jcubic/jquery.terminal)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=master&634dd6bdb563cac4da5f3e6ae04ce222)](https://coveralls.io/github/jcubic/jquery.terminal?branch=master)
[![npm](https://img.shields.io/badge/npm-2.23.0-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
![bower](https://img.shields.io/badge/bower-2.23.0-yellow.svg)
[![travis](https://travis-ci.org/jcubic/jquery.terminal.svg?branch=master&86c9c090ed1ab72d05d080ad0c795c8b3fbc7937)](https://travis-ci.org/jcubic/jquery.terminal)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=master&bdd9c7c5fd60e327a20845deda3b25d6)](https://coveralls.io/github/jcubic/jquery.terminal?branch=master)
![downloads](https://img.shields.io/npm/dm/jquery.terminal.svg?style=flat)
[![](https://data.jsdelivr.com/v1/package/npm/jquery.terminal/badge?style=rounded)](https://www.jsdelivr.com/package/npm/jquery.terminal)
[![LICENSE MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jcubic/jquery.terminal/blob/master/LICENSE)
Expand Down Expand Up @@ -80,20 +80,20 @@ Include jQuery library, you can use cdn from https://jquery.com/download/

```

Then include js/jquery.terminal-2.22.0.min.js and css/jquery.terminal-2.22.0.min.css
Then include js/jquery.terminal-2.23.0.min.js and css/jquery.terminal-2.23.0.min.css

You can grab the files from CDN:

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.22.0/js/jquery.terminal.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.22.0/css/jquery.terminal.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.23.0/js/jquery.terminal.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.23.0/css/jquery.terminal.min.css" rel="stylesheet"/>
```

or

```html
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal@2.22.0/js/jquery.terminal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.terminal@2.22.0/css/jquery.terminal.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal@2.23.0/js/jquery.terminal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.terminal@2.23.0/css/jquery.terminal.min.css">
```

If you always want latest version, you can get it from [unpkg](https://unpkg.com/) without specifying version,
Expand Down
95 changes: 94 additions & 1 deletion __tests__/terminal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2651,12 +2651,36 @@ describe('extensions', function() {
var command = 'hello';
term.set_prompt(prompt);
term.echo('.', {newline: false});
expect(term.get_output()).toEqual('.');
term.echo('.', {newline: false});
expect(term.get_output()).toEqual('..');
term.echo('.', {newline: false});
expect(term.get_output()).toEqual('...');
enter(term, command);
expect(term.get_output()).toEqual('...' + prompt + command);
expect(term.get_prompt()).toEqual(prompt);
});
it('get_prompt and set_prompt work as expected', function() {
var prompt1 = '>>> ';
var prompt2 = '~~~ ';
var command = 'hello';
term.set_prompt(prompt1);
term.echo('.', {newline: false});
expect(term.get_prompt()).toEqual(prompt1);
term.echo('.', {newline: false});
expect(term.get_prompt()).toEqual(prompt1);
term.set_prompt(prompt2);
term.echo('.', {newline: false});
expect(term.get_prompt()).toEqual(prompt2);
enter(term, command);
expect(term.get_output()).toEqual('...' + prompt2 + command);
expect(term.get_prompt()).toEqual(prompt2);
});
it('finalize with newline : false', function() {
term.echo('foo', {finalize: (a) => a.children().children().css("color", "red"), newline : false});
var color = term[0].querySelector(`[data-index='${term.last_index()}`).firstChild.firstChild.style.color;
expect(color).toEqual("red");
});
});
describe('autocomplete_menu', function() {
function completion(term) {
Expand Down Expand Up @@ -5482,14 +5506,83 @@ describe('Terminal plugin', function() {
});
// missing methods after version
describe('flush', function() {
var term = $('<div/>').terminal($.noop, {greetings: false});
it('should echo stuff that was called with flush false', function() {
var term = $('<div/>').terminal($.noop, {greetings: false});
term.echo('foo', {flush: false});
term.echo('bar', {flush: false});
term.echo('baz', {flush: false});
term.flush();
expect(term.find('.terminal-output').text()).toEqual('foobarbaz');
});
it('should flush correctly with newline : false', function(){
var term = $('<div/>').terminal($.noop, {
greetings : "greet"
});
var cmd = term.find(".cmd");

expect(term.find(".partial")[0]).toEqual(undefined);
expect(term.find("[data-index='0']").text()).toEqual("greet");

function getLastLineRect(partial){
let child = partial[0].lastElementChild;
child.style.width = "";
let rect = child.getBoundingClientRect();
child.style.width = "100%";
return rect;
}

term.echo("###", {newline : false});

var prompt = term.find(".cmd-prompt");
var partial = term.find(".partial");
var partial_children = partial.children();
var last_line_rect = getLastLineRect(partial);
expect(partial.attr("data-index")).toEqual("1");
expect(partial_children.length).toEqual(1);
expect(cmd.css("top")).toEqual(`${-last_line_rect.height}px`)
expect(prompt[0].style.marginLeft).toEqual(`${last_line_rect.width}px`);
expect(partial_children.first().text()).toEqual("###");

term.echo("aaa\nbbb\nccc", {newline : false});

var prompt = term.find(".cmd-prompt");
var partial = term.find(".partial");
var partial_children = partial.children();
var last_line_rect = getLastLineRect(partial);
expect(partial.attr("data-index")).toEqual("1");
expect(partial_children.length).toEqual(3);
expect(cmd.css("top")).toEqual(`${-last_line_rect.height}px`)
expect(prompt[0].style.marginLeft).toEqual(`${last_line_rect.width}px`);
expect(partial_children.eq(0).text()).toEqual("###aaa");
expect(partial_children.eq(1).text()).toEqual("bbb");
expect(partial_children.eq(2).text()).toEqual("ccc");
term.refresh();

var prompt = term.find(".cmd-prompt");
var partial = term.find(".partial");
var partial_children = partial.children();
var last_line_rect = getLastLineRect(partial);
expect(partial.attr("data-index")).toEqual("1");
expect(partial_children.length).toEqual(3);
expect(cmd.css("top")).toEqual(`${-last_line_rect.height}px`)
expect(prompt[0].style.marginLeft).toEqual(`${last_line_rect.width}px`);
expect(partial_children.eq(0).text()).toEqual("###aaa");
expect(partial_children.eq(1).text()).toEqual("bbb");
expect(partial_children.eq(2).text()).toEqual("ccc");

enter(term, "!!!");

var prompt = term.find(".cmd-prompt");
expect(cmd.css("top")).toEqual(`0px`)
expect(prompt[0].style.marginLeft).toEqual(`0px`);
expect(term.find("[data-index='1']").length).toEqual(1);
expect(term.find("[data-index='1']").children().last().text()).toEqual(nbsp("ccc> !!!"));
expect(term.find(".partial")[0]).toEqual(undefined);

term.refresh();
expect(term.find("[data-index='1']").length).toEqual(1);
expect(term.find("[data-index='1']").children().last().text()).toEqual(nbsp("ccc> !!!"));
});
});
describe('last_index', function() {
var term = $('<div/>').terminal($.noop, {greetings: false});
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery.terminal",
"version": "2.22.0",
"version": "2.23.0",
"main": [
"js/jquery.terminal.min.js",
"js/jquery.mousewheel-min.js",
Expand Down
4 changes: 2 additions & 2 deletions css/emoji.css

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

17 changes: 0 additions & 17 deletions css/jquery.terminal-2.22.0.min.css

This file was deleted.

15 changes: 13 additions & 2 deletions css/jquery.terminal-2.22.0.css → css/jquery.terminal-2.23.0.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ /
* / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__
* \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
* \/ /____/ version 2.22.0
* \/ /____/ version 2.23.0
* http://terminal.jcubic.pl
*
* This file is part of jQuery Terminal.
*
* Copyright (c) 2011-2021 Jakub Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Sun, 14 Feb 2021 11:03:09 +0000
* Date: Sun, 18 Apr 2021 11:24:37 +0000
*/

.terminal .terminal-output .format, .cmd .format,
Expand Down Expand Up @@ -108,6 +108,9 @@ body.full-screen-terminal .terminal {
width: 100%;
z-index: 300;
}
.terminal .cmd {
--background: transparent;
}
.terminal a[tabindex="1000"],
.terminal a[tabindex="1000"]:active,
.terminal a[tabindex="1000"]:focus {
Expand Down Expand Up @@ -186,6 +189,7 @@ body.full-screen-terminal .terminal {
.terminal .terminal-output > div:not(.raw) div {
white-space: nowrap;
}

.cmd .cmd-prompt > span {
float: left;
}
Expand Down Expand Up @@ -315,6 +319,10 @@ terminal .terminal-output > div {
.cmd .cmd-prompt {
position: relative;
z-index: 200;
/* Make sure prompt margin takes up space so that echo with newline : false
* works when prompt is empty
*/
float: left;
}
.cmd [role="presentation"]:not(.cmd-cursor-line) {
overflow: hidden;
Expand Down Expand Up @@ -684,6 +692,9 @@ terminal .terminal-output > div {
margin-bottom: 10px;
position: relative;
}
.terminal .partial, .terminal .partial > div {
display: inline-block;
}
@supports (--css: variables) {
.terminal,
.terminal-output > :not(.raw) span[data-text]:not(.token):not(.inverted):not(.terminal-inverted):not(.cmd-inverted):not(.terminal-error):not(.emoji),
Expand Down
17 changes: 17 additions & 0 deletions css/jquery.terminal-2.23.0.min.css

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions css/jquery.terminal-src.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ body.full-screen-terminal .terminal {
width: 100%;
z-index: 300;
}
.terminal .cmd {
--background: transparent;
}
.terminal a[tabindex="1000"],
.terminal a[tabindex="1000"]:active,
.terminal a[tabindex="1000"]:focus {
Expand Down Expand Up @@ -186,6 +189,7 @@ body.full-screen-terminal .terminal {
.terminal .terminal-output > div:not(.raw) div {
white-space: nowrap;
}

.cmd .cmd-prompt > span {
float: left;
}
Expand Down Expand Up @@ -315,6 +319,10 @@ terminal .terminal-output > div {
.cmd .cmd-prompt {
position: relative;
z-index: 200;
/* Make sure prompt margin takes up space so that echo with newline : false
* works when prompt is empty
*/
float: left;
}
.cmd [role="presentation"]:not(.cmd-cursor-line) {
overflow: hidden;
Expand Down Expand Up @@ -684,6 +692,9 @@ terminal .terminal-output > div {
margin-bottom: 10px;
position: relative;
}
.terminal .partial, .terminal .partial > div {
display: inline-block;
}
@supports (--css: variables) {
.terminal,
.terminal-output > :not(.raw) span[data-text]:not(.token):not(.inverted):not(.terminal-inverted):not(.cmd-inverted):not(.terminal-error):not(.emoji),
Expand Down
15 changes: 13 additions & 2 deletions css/jquery.terminal.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ /
* / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__
* \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
* \/ /____/ version 2.22.0
* \/ /____/ version 2.23.0
* http://terminal.jcubic.pl
*
* This file is part of jQuery Terminal.
*
* Copyright (c) 2011-2021 Jakub Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Sun, 14 Feb 2021 11:03:09 +0000
* Date: Sun, 18 Apr 2021 11:24:37 +0000
*/

.terminal .terminal-output .format, .cmd .format,
Expand Down Expand Up @@ -108,6 +108,9 @@ body.full-screen-terminal .terminal {
width: 100%;
z-index: 300;
}
.terminal .cmd {
--background: transparent;
}
.terminal a[tabindex="1000"],
.terminal a[tabindex="1000"]:active,
.terminal a[tabindex="1000"]:focus {
Expand Down Expand Up @@ -186,6 +189,7 @@ body.full-screen-terminal .terminal {
.terminal .terminal-output > div:not(.raw) div {
white-space: nowrap;
}

.cmd .cmd-prompt > span {
float: left;
}
Expand Down Expand Up @@ -315,6 +319,10 @@ terminal .terminal-output > div {
.cmd .cmd-prompt {
position: relative;
z-index: 200;
/* Make sure prompt margin takes up space so that echo with newline : false
* works when prompt is empty
*/
float: left;
}
.cmd [role="presentation"]:not(.cmd-cursor-line) {
overflow: hidden;
Expand Down Expand Up @@ -684,6 +692,9 @@ terminal .terminal-output > div {
margin-bottom: 10px;
position: relative;
}
.terminal .partial, .terminal .partial > div {
display: inline-block;
}
@supports (--css: variables) {
.terminal,
.terminal-output > :not(.raw) span[data-text]:not(.token):not(.inverted):not(.terminal-inverted):not(.cmd-inverted):not(.terminal-error):not(.emoji),
Expand Down
6 changes: 3 additions & 3 deletions 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.

Loading

0 comments on commit ee371da

Please sign in to comment.