Skip to content

Commit

Permalink
merge with devel
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jul 5, 2021
2 parents 9a61d8d + 3fda0db commit 3f279b1
Show file tree
Hide file tree
Showing 22 changed files with 1,918 additions and 1,307 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 2.27.0
### Feature
* add CSS and option `ansi` to echo to properly render ANSI art
* add typing animation to set_prompt [#673](https://github.com/jcubic/jquery.terminal/issues/673)
* return promise from `set_prompt` and `echo` when using typing animation
* new emoji
### Bugfix
* fix bug in cache (when echo same string two times in a row) [#672](https://github.com/jcubic/jquery.terminal/issues/672)
* fix exception when calling term::echo with typing animation
* fix regression in width ([chess demo](https://codepen.io/jcubic/pen/NWxOZQE))
* fix usage in NodeJS (regression since 2.22.0)

## 2.26.0
### Feature
* Better API for prompt typing animation with term::read and term::echo
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.26.0
\/ /____/ version DEV
```

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

[![npm](https://img.shields.io/badge/npm-2.26.0-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
![bower](https://img.shields.io/badge/bower-2.26.0-yellow.svg)
[![travis](https://travis-ci.org/jcubic/jquery.terminal.svg?branch=master&ddfb50a4b5ab475fdd209f2c5be832a801344cae)](https://travis-ci.org/jcubic/jquery.terminal)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=master&729bf3f8836eb2ffb6d7b6c8956debc8)](https://coveralls.io/github/jcubic/jquery.terminal?branch=master)
[![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)
[![travis](https://travis-ci.org/jcubic/jquery.terminal.svg?branch=devel&a65b86a47b0f5d73c0e3e122539f9a57d23f80c9)](https://travis-ci.org/jcubic/jquery.terminal)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&729bf3f8836eb2ffb6d7b6c8956debc8)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
![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.26.0.min.js and css/jquery.terminal-2.26.0.min.css
Then include js/jquery.terminal-DEV.min.js and css/jquery.terminal-DEV.min.css

You can grab the files from CDN:

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

or

```html
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal@2.26.0/js/jquery.terminal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.terminal@2.26.0/css/jquery.terminal.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal@DEV/js/jquery.terminal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.terminal@DEV/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
92 changes: 92 additions & 0 deletions bin/convert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env node

const $ = global.$ = global.jQuery = {
fn: {
extend: function(obj) {
Object.assign(global.jQuery.fn, obj);
}
},
extend: Object.assign
};

global.navigator = {
userAgent: 'Node'
};

require('../js/jquery.terminal-src')(global, global.$);
require('../js/unix_formatting')(global, global.$);

const fs = require('fs').promises;
const path = require('path');
const ansi = require('ansidec');
const iconv = require('iconv-lite');
const lily = require('@jcubic/lily');

const options = lily(process.argv.slice(2));

function read_stdin() {
return new Promise((resolve) => {
const buff = [];

process.stdin.on('data', data => {
buff.push(data);
}).on('end', () => {
var len = buff.map(x => x.length).reduce((acc, e) => acc + e);
resolve(Buffer.concat(buff, len));
});
});
}

const input = options.i || options.input;
const output = options.o || options.output;

if (options.h || options.help) {
const bin = path.basename(process.argv[1]);
console.log(`usage:\n\t${bin} [--help] [-h] [--input] [-i] <file> [--output] [-o] <file>
--input -i <file> input ANSI art file
--output -o <file> output jQuery Terminal formatting file
If no input specified it will read from STDIN
If no output specified it will print to STDOUT`);
} else if (input) {
fs.readFile(input).then(process_buffer);
} else {
read_stdin().then(process_buffer);
}

function process_buffer(buff) {
var text = format(buff);
if (output) {
fs.writeFile(output, text);
} else {
console.log(text);
}
}

function format(buff) {
var meta = ansi.meta(buff);
let cols = 80;
if (meta) {
buff = buff.slice(0, meta.fileSize);
cols = meta.tInfo[0];
}
var text = iconv.decode(buff, 'CP437');
return format_lines(text, cols).join('\n');
}

function format_lines(str, len) {
str = $.terminal.apply_formatters(str, {
unixFormatting: {
ansiArt: true
}
});
var lines = $.terminal.split_equal(str, len || 80);
// unix formatting don't handle \r\n at the end
if (lines[lines.length - 1] === '') {
lines.pop();
}
return lines;
}


Loading

0 comments on commit 3f279b1

Please sign in to comment.