Home / Javascript ConsoleWindow
Name Modified Size InfoDownloads / Week
Parent folder
ConsoleWindow.js 2015-06-07 4.7 kB
README.txt 2015-06-07 1.8 kB
console_v1.html 2015-06-07 5.7 kB
Totals: 3 Items   12.2 kB 0
For the "101 Basic Computer Games" porting project, this ConsoleWindow will be used
as the output device in each ported game. The ConsoleWindow is posted in two formats:

ConsoleWindow.js - Javascript source file with just the ConsoleWindow code for inclusion
                   into an HTML page

console_v1.html  - All-in-one demo file illustrating use of the ConsoleWindow.


console_v1.html
---------------
This is an all-in-one file containing V1 of the Javascript ConsoleWindow with some supporting
test capability. This demonstration file creates an 80x24 ConsoleWindow, and exposes methods
to write text with or without a trailing line feed, clearing the screen, and accepting user
input.

Constructor: ConsoleWindow(columns, rows, size)
- columns: Integer - Number of columns for console
- rows: Integer - Number of rows for console
- size: Optional - one of five enumerations
        Tiny, Small, Normal, Big, Large. 
        If omitted, "Normal" is used (14px font)

The methods of each ConsoleWindow instance:

write(text)

Display a line of text at the current cursor position without returning the cursor
to the left side of the display (no "carriage return/linefeed"). 

writeLine(text)

Display a line of text at the current cursor position, returning the cursor
to the left side of the display (includes trailing "carriage return/linefeed"). 

clear()

Clears the console display and moves the cursor to the upper left-hand corner.

readLine(callback)

Displays a "_" prompt at the current cursor location and expects user input, terminated
by the [ENTER] key. Sends the entered text string back to caller via the provided callback
function, eg callback expected to be of form expecting one parameter.

Source: README.txt, updated 2015-06-07