Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <!doctype html>
<html>

<head>
	<title>Mohamed Elgharbawy</title>
	<link rel="stylesheet" href="css/xterm.css"/>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/xterm/3.14.5/xterm.min.js"></script>

	<!-- Favicons -->
	<link href="img/m.png" rel="icon">
	<link href="img/m.png" rel="apple-touch-icon">
</head>

<body>
	<div id="terminal"></div>
	<script>
		var term = new Terminal({
			cursorBlink: "block"
		});

		var curr_line = '';
		var entries = [];
		var currPos = 0;
		var pos = 0;

		term.open(document.getElementById('terminal'));
		term.prompt = () => {
			term.write('\n\r' + curr_line + '\r\n\u001b[32mscm> \u001b[37m');
		};
		term.write('Welcome to my Scheme web intepreter!');
		term.prompt();

		term.on('key', function(key, ev) {
			const printable = !ev.altKey && !ev.altGraphKey && !ev.ctrlKey && !ev.metaKey &&
				!(ev.keyCode === 37 && term.buffer.cursorX < 6);

			if (ev.keyCode === 13) { // Enter key
				if (curr_line.replace(/^\s+|\s+$/g, '').length != 0) { // Check if string is all whitespace
					entries.push(curr_line);
					currPos = entries.length - 1;
					term.prompt();
				} else {
					term.write('\n\33[2K\r\u001b[32mscm> \u001b[37m');
				}
				curr_line = '';
			} else if (ev.keyCode === 8) { // Backspace
				if (term.buffer.cursorX > 5) {
					curr_line = curr_line.slice(0, term.buffer.cursorX - 6) + curr_line.slice(term.buffer.cursorX - 5);
					pos = curr_line.length - term.buffer.cursorX + 6;
					term.write('\33[2K\r\u001b[32mscm> \u001b[37m' + curr_line);
					term.write('\033['.concat(pos.toString()).concat('D')); //term.write('\033[<N>D');
					if (term.buffer.cursorX == 5 || term.buffer.cursorX == curr_line.length + 6) {
						term.write('\033[1C')
					}
				}
			} else if (ev.keyCode === 38) { // Up arrow
				if (entries.length > 0) {
					if (currPos > 0) {
						currPos -= 1;
					}
					curr_line = entries[currPos];
					term.write('\33[2K\r\u001b[32mscm> \u001b[37m' + curr_line);
				}
			} else if (ev.keyCode === 40) { // Down arrow
				currPos += 1;
				if (currPos === entries.length || entries.length === 0) {
					currPos -= 1;
					curr_line = '';
					term.write('\33[2K\r\u001b[32mscm> \u001b[37m');
				} else {
					curr_line = entries[currPos];
					term.write('\33[2K\r\u001b[32mscm> \u001b[37m' + curr_line);

				}
			} else if (printable && !(ev.keyCode === 39 && term.buffer.cursorX > curr_line.length + 4)) {
				if (ev.keyCode != 37 && ev.keyCode != 39) {
					var input = ev.key;
					if (ev.keyCode == 9) { // Tab
						input = "    ";
					}
					pos = curr_line.length - term.buffer.cursorX + 4;
					curr_line = [curr_line.slice(0, term.buffer.cursorX - 5), input, curr_line.slice(term.buffer.cursorX - 5)].join('');
					term.write('\33[2K\r\u001b[32mscm> \u001b[37m' + curr_line);
					term.write('\033['.concat(pos.toString()).concat('D')); //term.write('\033[<N>D');
				} else {
					term.write(key);
				}
			}
		});

		term.on('paste', function(data) {
			curr_line += data;
			term.write(curr_line);
		});
	</script>
</body></html>
              
            
!

CSS

              
                /**
 * Copyright (c) 2014 The xterm.js authors. All rights reserved.
 * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
 * https://github.com/chjj/term.js
 * @license MIT
 *
 * 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.
 *
 * Originally forked from (with the author's permission):
 *   Fabrice Bellard's javascript vt100 for jslinux:
 *   http://bellard.org/jslinux/
 *   Copyright (c) 2011 Fabrice Bellard
 *   The original design remains. The terminal itself
 *   has been extended to include xterm CSI codes, among
 *   other features.
 */

/**
 *  Default styles for xterm.js
 */

body {
  background-color: #000000;
}

.xterm {
    font-feature-settings: "liga" 0;
    position: relative;
    user-select: none;
    -ms-user-select: none;
    -webkit-user-select: none;
}

.xterm.focus,
.xterm:focus {
    outline: none;
}

.xterm .xterm-helpers {
    position: absolute;
    top: 0;
    /**
     * The z-index of the helpers must be higher than the canvases in order for
     * IMEs to appear on top.
     */
    z-index: 5;
}

.xterm .xterm-helper-textarea {
    /*
     * HACK: to fix IE's blinking cursor
     * Move textarea out of the screen to the far left, so that the cursor is not visible.
     */
    position: absolute;
    opacity: 0;
    left: -9999em;
    top: 0;
    width: 0;
    height: 0;
    z-index: -5;
    /** Prevent wrapping so the IME appears against the textarea at the correct position */
    white-space: nowrap;
    overflow: hidden;
    resize: none;
}

.xterm .composition-view {
    /* TODO: Composition position got messed up somewhere */
    background: #000;
    color: #FFF;
    display: none;
    position: absolute;
    white-space: nowrap;
    z-index: 1;
}

.xterm .composition-view.active {
    display: block;
}

.xterm .xterm-viewport {
    /* On OS X this is required in order for the scroll bar to appear fully opaque */
    background-color: #000;
    overflow-y: scroll;
    cursor: default;
    position: absolute;
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
}

.xterm .xterm-screen {
    position: relative;
}

.xterm .xterm-screen canvas {
    position: absolute;
    left: 0;
    top: 0;
}

.xterm .xterm-scroll-area {
    visibility: hidden;
}

.xterm-char-measure-element {
    display: inline-block;
    visibility: hidden;
    position: absolute;
    top: 0;
    left: -9999em;
    line-height: normal;
}

.xterm {
    cursor: text;
}

.xterm.enable-mouse-events {
    /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
    cursor: default;
}

.xterm.xterm-cursor-pointer {
    cursor: pointer;
}

.xterm.column-select.focus {
    /* Column selection mode */
    cursor: crosshair;
}

.xterm .xterm-accessibility,
.xterm .xterm-message {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 10;
    color: transparent;
}

.xterm .live-region {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.xterm-dim {
    opacity: 0.5;
}

.xterm-underline {
    text-decoration: underline;
}

              
            
!

JS

              
                
              
            
!
999px

Console