Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                /*
 * fix for buggy Windows 7
 * handling of small font size
 */
.terminal {
    --size: 1.5;
    --color: rgba(255,255,255,0.99);
}
/*
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;
}
*/
              
            
!

JS

              
                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);
        //console.log(meta);
        var cols = 80;
        if (meta) {
            buff = buff.slice(0, meta.fileSize);
            cols = meta.tInfo1;
        }
        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, '');
        str = $.terminal.apply_formatters(str, {});
        var lines = $.terminal.split_equal(str, cols);
        // unix formatting don't handle \r\n at the end
        if (lines[lines.length - 1] === '') {
            lines.pop();
        }
        // one flush to output whole image to the screen
        lines.map(line => term.echo(line, {flush: false}));
        term.flush().resume();
    }

    var term = $('body').terminal({
        help: function() {
            this.echo([
                'use [[;#888;]ls] to display list of files and [[;#888;]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 [[;#888;]credits] to show credits for ANSI',
                ' Art works. Use tab so you don\'t need to type whole filename.',
                '\nType [[;#888;]clear] to clear terminal.'
            ].join(''), {keepWords: true});
        },
        cat: function(name) {
            this.pause();
            get_ansi(name).then(echo_ansi);
        },
        size: function(size) {
            if (typeof size === 'number') {
                term.css('--size', size);
            }
        },
        ls: function() {
            console.log(files);
            this.echo(files);
        },
        credits: function() {
            this.echo('ANSI artworks taken from [[!;;;;https://16colo.rs/]16colors]')
        }
    }, {
        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 [[;rgba(125,125,125,0.9);]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

Console