Terminal

by Tgwizman

HTML

<canvas id="c" width=300 height=200></canvas>

JavaScript

var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

var terminal = {
  'display': {
    'style': {
      'fontSize': 14,
      'fontFamily': 'Courier',
      'height': 24,
      'width': 80,
      'foreground': '#00FF00',
      'background': '#000000'
    },
    'cache': {
      'commands': [],
      'commandCursor': 0,
    },
    'cursor': {
      'position': {
        'x': 0,
        'y': 0
      }
    }
  },
  'system': {
    'motd': 'Faildoze 2000 - Macrohard\nPress any key to continue...';
  }
}

terminal.display.clear = function() {
  canvas.width = canvas.width;
  ctx.fillStyle = terminal.display.style.background;
  ctx.fillRect(0, 0, canvas.width, canvas.height);
  ctx.fillStyle = terminal.display.style.foreground;
  ctx.font = terminal.display.style.fontSize + 'pt ' + terminal.display.style.fontFamily;
};

terminal.system.out.print = function(msg) {
  
}

(terminal.system.boot = function() {
  terminal.display.clear();
  terminal.system.print(terminal.system.motd);
})();