This is an old revision of the document!
Table of Contents
JavaScript Terminal v2
- For the basic terminal please see JavaScript Terminal
About
This is the Season 2, version 2 of JavaScript Terminal. It is more advanced than the v1 and is intended as a platform for larger and more advanced projects than simple one-scene games.
Main Differences
The primary difference is the creation of terminal mode and command mode.
By setting gameState = 'terminal', the program solely acts as a terminal emulator. In this mode, when enter is pressed on a line, the entirely of that line is trim()'d and sent to the console (i.e. the command queue). Then when in command mode, the program does not allow the user to control or modify the terminal directly but instead begins processing events from the queue.
Secondly, a framework for mouse (i.e. touch, on a phone or tablet) has been added. In command mode, you can move the cursor around by clicking or tapping on the canvas.
Commands can be processed in terminal mode (ex. HELP) or in command mode (try typing something like 10 PRINT “HELLO”. open the console and press escape – the command processor will take the command and process it).
This separation of terminal mode and command move is central to the idea of a proper terminal simulator, because terminal mode and entering commands with ENTER will later probve fundamental to the illusion of simulating string input.
Code Commentary