0.3.5 • Published 4 years ago

xterm-browser v0.3.5

Weekly downloads
1
License
Unlicense
Repository
github
Last release
4 years ago

A Browser Terminal framework for Xterm js

I built this so I could build terminals in the browser extensibly. It's a light wrapper around xterm js.

Installation

npm i xterm-browser

Usage

Wherever you would normally set up your xterm js terminal:

const BrowserTerminal = require('xterm-browser').Terminal

let term = new BrowserTerminal({})
terminal.open(document.getElementById('#terminal'))
terminal.setup() // sets up the parser and event listeners.

Writing to the terminal

xterm-browser extends xterm js, so you can call methods directly:

terminal.write('I am writing to the terminal')

You can also use the Terminal.format utility to change colors and text backgrounds:

terminal.writeln(`${terminal.format.text('blue')}Text color test${terminal.format.reset('all')}`)
terminal.writeln(`${terminal.format.background('red')}Background color test${terminal.format.reset('all')}`)
terminal.writeln(`${terminal.format.brightBackground('cyan')}Background color test${terminal.format.reset('all')}`)
terminal.writeln(`${terminal.format.style('reverse')}Reverse test (switches background and foreground color)${terminal.format.reset('all')}`)
terminal.writeln(`${terminal.format.brightText('green')}Bright text test${terminal.format.reset('all')}`)

NOTE: styles and colors will overlap or override each other without a call to Terminal.format.reset('all').

Commands

You listen for command events from the dispatcher. The dispatcher will emit events using the first word (separated by a space) of the line submitted.

terminal.dispatcher.on("hello", (data) => {
  console.log("hello!", data)
})

The data object is from yargs-parser.

TODO

A whole heck of a lot. See the Issues tab.

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago