You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

vt

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vt

terminal emulation library for javascript.

0.1.1
latest
npmnpm
Version published
Weekly downloads
30
-91.64%
Maintainers
1
Weekly downloads
 
Created
Source

terminal.js

Terminal.js is a rendering engine for vt100-like terminals. It is written from scratch and supports most commonly used escape sequences.

Build Status

Benefits

  • it can be used both in nodejs and as a javascript library in the browser
  • it avoids any dependencies like pty, html outputting etc so you can provide your own
  • it does not use an html dom to store it's state, this makes it server state compatible
  • clean separation of different escape codes
  • has a test framework

Usage

TermWriter Usage

var TermWriter = require('terminal').TermWriter;
var TermBuffer = require('terminal').TermBuffer;

var buffer = new TermBuffer(80,24);
var terminal = new TermWriter(termBuffer);
terminal.write("first test\n");
// termWriter.buffer is accessible

TermBuffer Usage

var TermBuffer = require('terminal').TermBuffer;
var buffer = new TermBuffer(80,24);
buffer.inject("first test\n");

TermDiff Usage

var TermDiff = require('terminal').TermDiff;
var TermBuffer = require('terminal').TermBuffer;

var buffer1 = new TermBuffer(80,24);
var buffer2 = new TermBuffer(80,24);

var terminal1 = new TermWriter(buffer1);
var terminal2 = new TermWriter(buffer2);

terminal1.write("test me");
var diff = new TermDiff(terminal1.buffer,terminal2.buffer);

diff.apply(terminal1);

TermBuffer Functions

  • createChar

  • createLine

  • getLine

  • write

  • escapeWrite

  • inject

  • lineFeed

  • mvCur : moves to relative coordinates

  • setCur : move to absolute coordinates

  • mvTab

  • tabSet

  • tabClear

  • saveCursor

  • restoreCursor

  • deleteCharacters

  • eraseCharacters

  • setScrollRegion

  • eraseInDisplay

  • eraseInLine

  • deleteLines

  • resetAttr

  • chAttr

  • insertBlanks

  • resize

  • insertLines

  • toString

  • setLed

  • scroll

  • eventToKey

TermBuffer Object structure

TermDiff structure

diff = {
  changes: [
    { l: 0, '.': { // On line0 replace the line
      str: 'test', // With string test
      attr{
      '0': { fg: null, bg:null, bold:false , underline: false, blink: false, inverse: false }, // Change Attributes on Pos0
      '2': { fg: null, bg:null, bold:false , underline: false, blink: false, inverse: true  }  // Change Attributes on Pos2
      }
    },
    { l: 1, '+': { // Online 1 add a line
      str: 'test', // With String test
      attr{
      '0': { fg: null, bg:null, bold:false , underline: false, blink: false, inverse: false }, // Change Attributes on Pos0
      '2': { fg: null, bg:null, bold:false , underline: false, blink: false, inverse: true  }  // Change Attributes on Pos2
      }
    },
    { l: 2, '-': 3 }, // On line2 remove 3 lines
  ],
  cursor: [ { from: { 'x': 0, 'y':10 }, to: { 'x': 0, 'y':12 } } ],
  savedcursor: [ { from: { 'x': 0, 'y':10 }, to: { 'x': 0, 'y':12 } } ],
  size: [ { from: { 'height': 80, 'width':24 }, to: { 'height': 30, 'width':12 } } ],
  scrollregion: [ {from: [ 0, 10 ], to: [ 0, 12 ] } ],
  modes: [ { 'graphic': true }, { 'insert': false } ],
  tabs: [ { from: [] , to: [ 1 ] }]
}

Jquery/Server side:

Expose local shell in a browser:

Simulate a pseudo shell in browser:

Reference docs for vt100, csi , ... codes

Remarks

  • we should clone the defaultBuffer instead of equalling it (see reset function)
  • attrCommited? always after changr of attr?
  • this.attr = this.defaultAttr (again it should copy it not equal the object)
  • Termdiff.diff() - should it not be an array instead of a hash?

Keywords

vt100

FAQs

Package last updated on 06 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.