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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                .terminal-output>:not(.raw) .terminal-form-control {
    overflow: hidden;
    display: inline;
}
.terminal-output>:not(.raw) .terminal-form-control,
.terminal-output>:not(.raw) .terminal-form-control span {
    font-size: calc(var(--size, 1) * 1.5 * 14px);
}
.terminal-form-control {
    text-align: center;
}
/* FIX BUG IN UNICODE CHARACTERS FOR RADIO ON WINDOWS */
.terminal-output>:not(.raw) .terminal-form-control.terminal-big-radio span {
    font-size: calc(var(--size, 1) * 1.1 * 14px);
}
.terminal-output>:not(.raw) .terminal-form-control.terminal-radio:not(.terminal-big-radio) {
    padding-top: 3px;
}
.terminal-output>:not(.raw) .terminal-form-control.terminal-radio:not(.terminal-big-radio) span {
    position: relative;
    top: 3px;
}
              
            
!

JS

              
                // disable loop projection for async while loop in form command
if (window.CP && window.CP.PenTimer) {
    window.CP.PenTimer.MAX_TIME_IN_LOOP_WO_EXIT = Number.POSITIVE_INFINITY;
}

// better formatting
$.terminal.defaults.allowedAttributes.push('style');

$.terminal.new_formatter([
    /<big>(.*?)<\/big>/g, '[[;;;;;{"style": "--size: 1.5;letter-spacing: 2px"}]$1]'
]);

$.terminal.new_formatter([
    /<img src="([^"]+)"(?: alt="([^"]+)")?\/?>/g, '[[@;;;;$1]$2]'
]);
$.terminal.new_formatter([
    /<a href="([^"]+)">([^>]+)<\/a>/g, '[[!;;;;$1]$2]'
]);


function is_object(val) {
    return Object.prototype.toString.call(val) === "[object Object]";
}

// ------------------------------------------------------------------
var term = $('body').terminal({
    demo: function() {
        var data = {foo: 10, bar: 20, baz: 30};
        this.echo('\nPick any');
        $.terminal.forms.checkboxes(this, {items: data}).then(x => {
            this.echo(`<bold>Result</bold>: [${x.join(', ')}]`);
        }).then(() => {
            this.echo('\nPick one');
            return $.terminal.forms.radio(this, {items: data });
        }).then(x => {
            this.echo(`<bold>Result</bold>: ${x}`);
        });
    },
    form: function() {
        const { input, password, radio, boolean, checkboxes } = $.terminal.forms.types;

        var spec = [
            {
                type: input,
                message: '\nWhat is your name?',
                prompt: 'name: ',
                name: 'name'
            },
            {
                type: password,
                message: '\nWhat is your password?',
                prompt: 'password: ',
                name: 'passwd'
            },
            {
                type: boolean,
                message: '\nAre you a student?',
                prompt: '(y)es (n)o: ',
                items: [/y|yes/i, /n|no/i],
                name: 'student'
            },
            {
                type: checkboxes,
                message: '\nwhat are your hobbies?',
                items: {
                    swimming: 1,
                    socker: 2,
                    fotography: 3,
                    painitng: 4
                },
                name: 'hobby'
            },
            {
                type: radio,
                message: '\nWhat type of user you are',
                items: { editor: 1, admin: 2, user: 3 },
                name: 'type'
            }
        ];
        $.terminal.forms.form(this, spec).then(form => {
            this.echo('\nForm result:');
            this.echo(form);  
        });
    },
    select: function(...args) {
        if (args.length) {
            $.terminal.forms.radio(this, { items: args }).then(result => {
                this.echo(`<bold>Selection</bold>: ${result}`);
            });
        } else {
            this.error('You need to use options');
        }
    },
    checkbox: function(...args) {
        if (args.length) {
            $.terminal.forms.checkboxes(this, { items: args }).then(result => {
                this.echo(`<bold>Selection</bold>: ${result}`);
            });
        } else {
            this.error('You need to use options');
        }
    }
}, {
    name: 'forms',
    greetings: '<big>jQuery Terminal v. DEV</big>\n',
    completion: true,
    onInit: function() {
        this.echo('type <bold>select arg1 ...</bold>\n<bold>' +
                  'checkbox arg1 ...</bold>\n<bold>demo</bold>' +
                  '\nor <bold>form</bold>\n')
    },
    renderHandler: function(val) {
        if (is_object(val) || Array.isArray(val)) {
            return JSON.stringify(val, true, 4);
        }
        return val;
    },
    onResize: function() {
        console.log(this.geometry());
    },
    checkArity: false
});
              
            
!
999px

Console