ansi art viewer.
This commit is contained in:
parent
02f5287b56
commit
72dcf7b18f
|
@ -0,0 +1,20 @@
|
|||
Copyright (c) 2015, Christopher Jeffrey
|
||||
https://github.com/chjj/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
|
@ -0,0 +1,17 @@
|
|||
# ansi-viewer
|
||||
|
||||
A terminal app to view ANSI art from http://artscene.textfiles.com/ansi/.
|
||||
|
||||
![ansi-viewer](https://raw.githubusercontent.com/chjj/blessed/master/img/ansi-viewer.png)
|
||||
|
||||
## Contribution and License Agreement
|
||||
|
||||
If you contribute code to this project, you are implicitly allowing your code
|
||||
to be distributed under the MIT license. You are also implicitly verifying that
|
||||
all code is your original work. `</legalese>`
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2015, Christopher Jeffrey. (MIT License)
|
||||
|
||||
See LICENSE for more info.
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
* ansi-art-viewer
|
||||
* ANSI art viewer for node.
|
||||
* Copyright (c) 2015, Christopher Jeffrey and contributors (MIT License).
|
||||
* https://github.com/chjj/blessed
|
||||
*/
|
||||
|
||||
var blessed = require('../../')
|
||||
, request = require('request')
|
||||
, fs = require('fs')
|
||||
, screen;
|
||||
|
||||
// $ wget -r -o log --tries=10 'http://artscene.textfiles.com/ansi/'
|
||||
// $ grep 'http.*\.ans$' log | awk '{ print $3 }' > blessed/ansi-art.list
|
||||
|
||||
var urls = fs.readFileSync(__dirname + '/ansi-art.list', 'utf8').trim().split('\n');
|
||||
|
||||
var map = urls.reduce(function(map, url) {
|
||||
map[/([^.\/]+\/[^.\/]+)\.ans$/.exec(url)[1]] = url;
|
||||
return map;
|
||||
}, {});
|
||||
|
||||
screen = blessed.screen({
|
||||
smartCSR: true,
|
||||
dockBorders: true
|
||||
});
|
||||
|
||||
var art = blessed.terminal({
|
||||
parent: screen,
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
handler: function() {}
|
||||
});
|
||||
|
||||
var list = blessed.list({
|
||||
parent: screen,
|
||||
label: ' {bold}{cyan-fg}ANSI Art{/cyan-fg}{/bold} (Drag Me) ',
|
||||
tags: true,
|
||||
draggable: true,
|
||||
top: 0,
|
||||
right: 0,
|
||||
width: '40%',
|
||||
height: '40%',
|
||||
keys: true,
|
||||
vi: true,
|
||||
mouse: true,
|
||||
border: 'line',
|
||||
scrollbar: {
|
||||
ch: ' ',
|
||||
track: {
|
||||
bg: 'cyan'
|
||||
},
|
||||
style: {
|
||||
inverse: true
|
||||
}
|
||||
},
|
||||
style: {
|
||||
//transparent: true,
|
||||
item: {
|
||||
hover: {
|
||||
bg: 'blue'
|
||||
}
|
||||
},
|
||||
selected: {
|
||||
bg: 'blue',
|
||||
bold: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var status = blessed.box({
|
||||
parent: screen,
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
height: 1,
|
||||
width: 'shrink',
|
||||
style: {
|
||||
bg: 'blue'
|
||||
}
|
||||
});
|
||||
|
||||
list.setItems(Object.keys(map));
|
||||
|
||||
list.on('select', function(url, selected) {
|
||||
url = map[url.getText()];
|
||||
status.setContent(url);
|
||||
request(url, function(err, res, body) {
|
||||
if (err || !body) return;
|
||||
art.term.reset();
|
||||
art.term.write(body);
|
||||
art.term.cursorHidden = true;
|
||||
screen.render();
|
||||
});
|
||||
});
|
||||
|
||||
list.select(0);
|
||||
list.focus();
|
||||
|
||||
screen.key('q', function() {
|
||||
return process.exit(0);
|
||||
});
|
||||
|
||||
screen.key('h', function() {
|
||||
list.toggle();
|
||||
if (list.visible) list.focus();
|
||||
});
|
||||
|
||||
screen.render();
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "ansi-viewer",
|
||||
"description": "ANSI art viewer for node",
|
||||
"author": "Christopher Jeffrey",
|
||||
"version": "0.0.1",
|
||||
"main": "./index.js",
|
||||
"bin": "./index.js",
|
||||
"preferGlobal": false,
|
||||
"repository": "git://github.com/chjj/blessed.git",
|
||||
"homepage": "https://github.com/chjj/blessed",
|
||||
"bugs": { "url": "http://github.com/chjj/blessed/issues" },
|
||||
"keywords": ["ansi", "art"],
|
||||
"tags": ["ansi", "art"]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
Loading…
Reference in New Issue