GithubHelp home page GithubHelp logo

dostoy's Introduction

dostoy

A silly interactive retro terminal library for the HTML5 canvas
Make a fake DOS prompt or draw some ASCII/ANSI art.

Live: http://www.toolsley.com/dos.html

Prerequisites

A font

Google "fntcol16.zip"
One-by-one these fonts are in the public-domain.
Or you can use the one supplied with the demos

A canvas

Make an HTML page with a canvas

Usage

Shell Mode

Prompt, cursor, input, command interpreter

	dostoy.init({
		font: window.atob("your font in base64"), // or Uint8Array with font data
		fontHeight: 14, // or appropriate for font
		canvas: document.getElementById("your-canvas-id"),
		shell:true,
		beforeShell: function() {
			dostoy.println("Some welcome message");
		},
		prompt: "C:\\>",
		commandHandler : function(command) {
			switch(command) {
				case "ver":
					dostoy.println("Fake Dos 1.0");
				break;
				default:
					dostoy.println("Bad command or filename");
			}
		}
	});

Manual Mode

Manual output with manual input

	dostoy.init({
		font: window.atob("your font in base64"), // or Uint8Array with font data
		fontHeight: 14, // or appropriate for font
		canvas: document.getElementById("your-canvas-id"),
		shell:false
	});
	dostoy.println("Hello World");
	dostoy.input("Your name?", function(name) {
		dostoy.println("Hello to you too, "+name);
	});

Reference

print(text)
println(text)
input(prompt,function(input))
inkey(function(keyCode))
locate(col,row)
chr(charcodes) - this also prints. charcodes can be a single ascii code or a comma separated list
cls()
setCursor(true/false)
setPrompt(text)
setShell(true,false)
color(bg,fg) - see color code table at http://en.wikibooks.org/wiki/QBasic/Text_Output#Color_by_Number)
getCols()
getRows()

Etc

License: MIT

Known issues: Grossly incomplete input handler among other things

There's a tremendous amount of room for improvement but as a toy and simple demo it provides enough mild entertainment as-is. Might be useful for April Fools pages or similar.

Pull requests are welcome if you make something more involved with it and improve on it in the process.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.