Skip to content

Commit

Permalink
add revese style to formatting #943
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed May 14, 2024
1 parent 6c9f0b9 commit 718e9f9
Show file tree
Hide file tree
Showing 17 changed files with 112 additions and 63 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## 2.41.3
## 2.42.0
### Features
* add reverse style to formatting and XML [#943](https://github.com/jcubic/jquery.terminal/issues/943)
### Bugfix
* fix typing animation on emtpy lines [#946](https://github.com/jcubic/jquery.terminal/issues/946)
* fix skip typing animation [#945](https://github.com/jcubic/jquery.terminal/issues/945)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
![bower](https://img.shields.io/badge/bower-DEV-yellow.svg)
[![Build and test](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml/badge.svg?branch=devel&event=push)](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&8f2e58e2cbb0889679fb75085e7c7a4b)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&55fa1beff371fcfe8bf972eccb9b2346)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
![NPM Downloads](https://img.shields.io/npm/dm/jquery.terminal.svg?style=flat)
[![jsDelivr Downloads](https://data.jsdelivr.com/v1/package/npm/jquery.terminal/badge?style=rounded&n=1)](https://www.jsdelivr.com/package/npm/jquery.terminal)
[![Paid Support](https://img.shields.io/badge/paid-support-354465.svg)](https://support.jcubic.pl/)
Expand Down
2 changes: 1 addition & 1 deletion __tests__/__snapshots__/terminal.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ exports[`Terminal plugin prompt should set prompt 2`] = `"<span data-text=\\">>>
exports[`Terminal plugin terminal create / terminal destroy should have default prompt 1`] = `"<span data-text=\\">&nbsp;\\"><span style=\\"width: 2ch;\\">&gt;&nbsp;</span></span>"`;
exports[`Terminal utils $.terminal.format should create html span tags with style and classes 1`] = `"<span style=\\"font-weight:bold;text-decoration:underline line-through;font-style:italic;color:#fff;--color:#fff;--original-color:#fff;text-shadow:0 0 5px #fff;background-color:#000;--background:#000\\" data-text=\\"Foo\\"><span>Foo</span></span><span style=\\"font-style:italic\\" class=\\"foo\\" data-text=\\"Bar\\"><span>Bar</span></span><span style=\\"text-decoration:underline line-through overline\\" data-text=\\"Baz\\"><span>Baz</span></span>"`;
exports[`Terminal utils $.terminal.format should create html span tags with style and classes 1`] = `"<span style=\\"font-weight:bold;text-decoration:underline line-through;font-style:italic;color:#fff;--color:#fff;--original-color:#fff;text-shadow:0 0 5px #fff;background-color:#000;--background:#000\\" data-text=\\"Foo\\"><span>Foo</span></span><span style=\\"font-style:italic\\" class=\\"foo\\" data-text=\\"Bar\\"><span>Bar</span></span><span style=\\"text-decoration:underline line-through overline\\" data-text=\\"Baz\\"><span>Baz</span></span><span class=\\"terminal-inverted\\" data-text=\\"Quux\\"><span>Quux</span></span>"`;
exports[`Terminal utils $.terminal.format should filter out attribute in JSON 1`] = `"<span title=\\"foo\\" data-text=\\"foo\\"><span>foo</span></span>"`;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/terminal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,8 @@ describe('Terminal utils', function() {
});
});
describe('$.terminal.format', function() {
var format = '[[biugs;#fff;#000]Foo][[i;;;foo]Bar][[ous;;]Baz]';
it('should create html span tags with style and classes', function() {
var format = '[[biugs;#fff;#000]Foo][[i;;;foo]Bar][[ous;;]Baz][[r;;]Quux]';
var string = $.terminal.format(format);
expect(string).toMatchSnapshot();
});
Expand Down
18 changes: 13 additions & 5 deletions css/jquery.terminal-2.41.2.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ /
* / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__
* \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
* \/ /____/ version 2.41.2
* \/ /____/ version DEV
* http://terminal.jcubic.pl
*
* This file is part of jQuery Terminal.
*
* Copyright (c) 2011-2023 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Wed, 08 May 2024 16:59:34 +0000
* Date: Tue, 14 May 2024 21:44:50 +0000
*/
.terminal .terminal-output .format, .cmd .format,
.cmd-prompt, .cmd-prompt div {
Expand Down Expand Up @@ -739,6 +739,7 @@ terminal .terminal-output > div {
.terminal .terminal-output span[data-text]::selection,
.terminal .terminal-output span[data-text]:not(.far):not(.fa):not(.fas) span::selection,
.terminal .terminal-output .raw div::selection,
.terminal-revese,
.cmd span[data-text]:not(.far):not(.fa):not(.fas) span::selection {
/*
* use rgba to fix transparent selection in chrome
Expand All @@ -747,6 +748,7 @@ terminal .terminal-output > div {
background-color: rgba(170, 170, 170, 0.99);
color: #000;
}

.terminal-output .emoji::-moz-selection,
.terminal-output .emoji span::-moz-selection,
.cmd .emoji::-moz-selection,
Expand Down Expand Up @@ -864,10 +866,16 @@ terminal .terminal-output > div {
.cmd .clipboard {
top: calc(var(--size, 1) * (14 / var(--pixel-density, 1)) * var(--cursor-line, 0) * 1px);
}
.terminal .inverted, .cmd.cmd.cmd .inverted, .cmd.cmd.cmd .cmd-inverted {
--background: #000;
.terminal span[style*="--background"],
.cmd span[style*="--background"] {
--base-background: var(--background);
}
.terminal .inverted > span,
.terminal .terminal-inverted > span,
.cmd.cmd.cmd .inverted,
.cmd.cmd.cmd .cmd-inverted {
background-color: var(--color, #aaa) !important;
color: var(--background, #000) !important;
color: var(--base-background, #000) !important;
}
.cmd .cmd-cursor.cmd-blink {
color: var(--color, #aaa);
Expand Down
6 changes: 3 additions & 3 deletions css/jquery.terminal-2.41.2.min.css

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions css/jquery.terminal-src.css
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ terminal .terminal-output > div {
.terminal .terminal-output span[data-text]::selection,
.terminal .terminal-output span[data-text]:not(.far):not(.fa):not(.fas) span::selection,
.terminal .terminal-output .raw div::selection,
.terminal-revese,
.cmd span[data-text]:not(.far):not(.fa):not(.fas) span::selection {
/*
* use rgba to fix transparent selection in chrome
Expand All @@ -747,6 +748,7 @@ terminal .terminal-output > div {
background-color: rgba(170, 170, 170, 0.99);
color: #000;
}

.terminal-output .emoji::-moz-selection,
.terminal-output .emoji span::-moz-selection,
.cmd .emoji::-moz-selection,
Expand Down Expand Up @@ -864,10 +866,16 @@ terminal .terminal-output > div {
.cmd .clipboard {
top: calc(var(--size, 1) * (14 / var(--pixel-density, 1)) * var(--cursor-line, 0) * 1px);
}
.terminal .inverted, .cmd.cmd.cmd .inverted, .cmd.cmd.cmd .cmd-inverted {
--background: #000;
.terminal span[style*="--background"],
.cmd span[style*="--background"] {
--base-background: var(--background);
}
.terminal .inverted > span,
.terminal .terminal-inverted > span,
.cmd.cmd.cmd .inverted,
.cmd.cmd.cmd .cmd-inverted {
background-color: var(--color, #aaa) !important;
color: var(--background, #000) !important;
color: var(--base-background, #000) !important;
}
.cmd .cmd-cursor.cmd-blink {
color: var(--color, #aaa);
Expand Down
18 changes: 13 additions & 5 deletions css/jquery.terminal.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ /
* / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__
* \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
* \/ /____/ version 2.41.2
* \/ /____/ version DEV
* http://terminal.jcubic.pl
*
* This file is part of jQuery Terminal.
*
* Copyright (c) 2011-2023 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Wed, 08 May 2024 16:59:34 +0000
* Date: Tue, 14 May 2024 21:44:50 +0000
*/
.terminal .terminal-output .format, .cmd .format,
.cmd-prompt, .cmd-prompt div {
Expand Down Expand Up @@ -739,6 +739,7 @@ terminal .terminal-output > div {
.terminal .terminal-output span[data-text]::selection,
.terminal .terminal-output span[data-text]:not(.far):not(.fa):not(.fas) span::selection,
.terminal .terminal-output .raw div::selection,
.terminal-revese,
.cmd span[data-text]:not(.far):not(.fa):not(.fas) span::selection {
/*
* use rgba to fix transparent selection in chrome
Expand All @@ -747,6 +748,7 @@ terminal .terminal-output > div {
background-color: rgba(170, 170, 170, 0.99);
color: #000;
}

.terminal-output .emoji::-moz-selection,
.terminal-output .emoji span::-moz-selection,
.cmd .emoji::-moz-selection,
Expand Down Expand Up @@ -864,10 +866,16 @@ terminal .terminal-output > div {
.cmd .clipboard {
top: calc(var(--size, 1) * (14 / var(--pixel-density, 1)) * var(--cursor-line, 0) * 1px);
}
.terminal .inverted, .cmd.cmd.cmd .inverted, .cmd.cmd.cmd .cmd-inverted {
--background: #000;
.terminal span[style*="--background"],
.cmd span[style*="--background"] {
--base-background: var(--background);
}
.terminal .inverted > span,
.terminal .terminal-inverted > span,
.cmd.cmd.cmd .inverted,
.cmd.cmd.cmd .cmd-inverted {
background-color: var(--color, #aaa) !important;
color: var(--background, #000) !important;
color: var(--base-background, #000) !important;
}
.cmd .cmd-cursor.cmd-blink {
color: var(--color, #aaa);
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.

31 changes: 19 additions & 12 deletions js/jquery.terminal-2.41.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Mon, 13 May 2024 10:03:02 +0000
* Date: Tue, 14 May 2024 21:44:49 +0000
*/
/* global define, Map, BigInt */
/* eslint-disable */
Expand Down Expand Up @@ -1189,14 +1189,14 @@
// https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser
var mobile_re = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i;
var tablet_re = /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i;
var format_split_re = /(\[\[(?:-?[@!gbiuso])*;[^;]*;[^\]]*\](?:[^\]\\]*(?:\\\\)*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]*)\]?)/i;
var format_parts_re = /\[\[((?:-?[@!gbiuso])*);([^;]*);([^;\]]*);?([^;\]]*);?([^\]]*)\]([^\]\\]*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]+)\]?/gi;
var format_re = /\[\[((?:-?[@!gbiuso])*;[^;\]]*;[^;\]]*(?:;|[^\]()]*);?[^\]]*)\]([^\]]*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]*)\]?/gi;
var format_exist_re = /\[\[((?:-?[@!gbiuso])*;[^;\]]*;[^;\]]*(?:;|[^\]()]*);?[^\]]*)\]([^\]]*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]*)\]/gi;
var format_full_re = /^(\[\[(?:(?:-?[@!gbiuso])*;[^;\]]*;[^;\]]*(?:;|[^\]()]*);?[^\]]*)\])([^\]]*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]*)(\])$/i;
var format_begin_re = /(\[\[(?:-?[@!gbiuso])*;[^;]*;[^\]]*\])/i;
var format_start_re = /^(\[\[(?:-?[@!gbiuso])*;[^;]*;[^\]]*\])/i;
var format_end_re = /\[\[(?:-?[@!gbiuso])*;[^;]*;[^\]]*\]?$/i;
var format_split_re = /(\[\[(?:-?[@!gbiusor])*;[^;]*;[^\]]*\](?:[^\]\\]*(?:\\\\)*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]*)\]?)/i;
var format_parts_re = /\[\[((?:-?[@!gbiusor])*);([^;]*);([^;\]]*);?([^;\]]*);?([^\]]*)\]([^\]\\]*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]+)\]?/gi;
var format_re = /\[\[((?:-?[@!gbiusor])*;[^;\]]*;[^;\]]*(?:;|[^\]()]*);?[^\]]*)\]([^\]]*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]*)\]?/gi;
var format_exist_re = /\[\[((?:-?[@!gbiusor])*;[^;\]]*;[^;\]]*(?:;|[^\]()]*);?[^\]]*)\]([^\]]*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]*)\]/gi;
var format_full_re = /^(\[\[(?:(?:-?[@!gbiusor])*;[^;\]]*;[^;\]]*(?:;|[^\]()]*);?[^\]]*)\])([^\]]*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]*)(\])$/i;
var format_begin_re = /(\[\[(?:-?[@!gbiusor])*;[^;]*;[^\]]*\])/i;
var format_start_re = /^(\[\[(?:-?[@!gbiusor])*;[^;]*;[^\]]*\])/i;
var format_end_re = /\[\[(?:-?[@!gbiusor])*;[^;]*;[^\]]*\]?$/i;
var self_closing_re = /^(?:\[\[)?[^;]*@[^;]*;/;
var color_re = /^(?:#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([^)]+\)|hsla?\([^)]+\))$/i;
var url_re = /(\b(?:file|ftp|https?):\/\/(?:(?:(?!&[^;]+;)|(?=&amp;))[^\s"'\\<>\][)])+)/gi;
Expand All @@ -1206,7 +1206,7 @@
var email_full_re = /^((([^<>('")[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,})))$/g;
var command_re = /((?:"[^"\\]*(?:\\[\S\s][^"\\]*)*"|'[^'\\]*(?:\\[\S\s][^'\\]*)*'|`[^`\\]*(?:\\[\S\s][^`\\]*)*`|\/[^\/\\]*(?:\\[\S\s][^\/\\]*)*\/[gimsuy]*(?=\s|$)|(?:\\\s|\S))+)(?=\s|$)/gi;
var extended_command_re = /^\s*((terminal|cmd)::([a-z_]+)\(([\s\S]*)\))\s*$/;
var format_exec_split_re = /(\[\[(?:-?[@!gbiuso])*;[^\]]+\](?:\\[[\]]|[^\]])*\]|\[\[[\s\S]+?\]\])/;
var format_exec_split_re = /(\[\[(?:-?[@!gbiusor])*;[^\]]+\](?:\\[[\]]|[^\]])*\]|\[\[[\s\S]+?\]\])/;
var format_exec_re = /(\[\[[\s\S]+?\]\])/;
var float_re = /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/;
var re_re = /^\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimsuy]*)$/;
Expand Down Expand Up @@ -5312,7 +5312,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Mon, 13 May 2024 10:03:02 +0000',
date: 'Tue, 14 May 2024 21:44:49 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -6091,7 +6091,7 @@
var last = formatting.slice(5).join(';');
formatting = formatting.slice(0, 5).concat(last);
}
var style = formatting[0].split(/(-?[@!gbiuso])/g).filter(Boolean);
var style = formatting[0].split(/(-?[@!gbiusor])/g).filter(Boolean);
style.forEach(function(s) {
if (output[0].indexOf(s) === -1) {
output[0].push(s);
Expand Down Expand Up @@ -6999,6 +6999,13 @@
if (style.indexOf('i') !== -1) {
styles['font-style'] = 'italic';
}
if (style.indexOf('r') !== -1) {
if (_class.trim()) {
_class += ' ' + 'terminal-inverted';
} else {
_class = 'terminal-inverted';
}
}
if ($.terminal.valid_color(color)) {
$.extend(styles, {
'color': color,
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.41.2.min.js

Large diffs are not rendered by default.

0 comments on commit 718e9f9

Please sign in to comment.