Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              /*
 * fix for buggy Windows 7
 * handling of small font size
 */
.terminal {
    --size: 1.4;
    --color: white;
}
/*
for IE:
.terminal, .terminal-output > :not(.raw) span, .terminal-output > :not(.raw) a, .terminal-output > :not(.raw) div, .cmd, .cmd span, .cmd div {
    font-size: 14px;
    line-height: 16px;
}
*/
            
          
!
            
              var url = 'https://terminal.jcubic.pl/ansi/read.php'; // CORS enabled

(async function() {
    function get(url) {
        return fetch(url).then(res => res.text()).then(text=>text.trim());
    }
    var files = (await get(url + '?action=ls')).split('\n');
    function get_ansi(name) {
        return fetch(url + '?raw=1&file=' + name).
            then(res => res.arrayBuffer()).then(a => new Uint8Array(a));
    }
    function echo_ansi(buff) {
        var meta = AnsiLove.sauceBytes(buff);
        var cols = 80;
        var str = iconv.decode(buff, 'CP437');
        // remove code that move cursor after new line - hope this works
        str = str.replace(/\r?\n?\x1b\[A\x1b\[[0-9]+C/g, '');
        // main code - this will use unix_formatting file to format ANSI artwork
        str = $.terminal.apply_formatters(str, {});
        if (meta) {
            if (str.match(/\x1a/)) { // 26 - end of file in DOS
                str = str.replace(/\x1a.*/, '');
            }
            console.log(meta);
            cols = meta.tInfo1;
            var lines = $.terminal.split_equal(str, cols);
            // one flush to output whole image to the screen
            lines.map(line => term.echo(line, {flush: false}));
            term.flush();
        } else {
            // should we wrap to 80 cols if there is no meta SAUCE data?
            term.echo(str);
        }
        term.resume();
    }

    var term = $('body').terminal({
        help: function() {
            this.echo([
                'use [[;#444;]ls] to display list of files and [[;#444;]cat]',
                ' to display the artwork, you can also [[u;;]drag and drop] the file.',
                '\nOnly Code Page 437 encoding files will work (classic demo s',
                'cene files).\nType [[;#444;]credits] to show credits for ANSI',
                ' Art works. Use tab so you don\'t need to type whole filename.',
                '\nType [[;#444;]clear] to clear terminal.'
            ].join(''), {keepWords: true});
        },
        cat: function(name) {
            this.pause();
            get_ansi(name).then(echo_ansi);
        },
        ls: function() {
            console.log(files);
            this.echo(files);
        },
        credits: function() {
            this.echo('ANSI artworks taken from [[!;;;;https://fuel.wtf/packs/fuel27/]fuel magazine]')
        }
    }, {
        completion: function(string, callback) {
            if (this.get_command().match(/^cat /)) {
                callback(files);
            } else {
                callback(['ls', 'file', 'credits', 'help']);
            }
        },
        outputLimit: 250,
        greetings: 'ANSI ART Terminal viewer\nType [[;#444;]help] for more info\n',
        name: 'ansi'
    }).drop(function(array_buff) { // drop plugin
        echo_ansi(new Uint8Array(array_buff));
        return term.read('press enter to continue ');
    }, {
        type: 'arraybuffer',
        error: function(e) {
            term.exception(e);
        },
        complete: function() {
            term.echo('all files rendered');
        }
    });
})();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console