Code Monkey home page Code Monkey logo

terminal.js's Introduction

terminal.js: terminal emulator library for browsers and node.js

Build Status

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

Example

a simple demo using the colors module:

var colors = require('colors'),
	Terminal = require('./index');

var terminal = new Terminal({columns: 20, rows: 2});

terminal.write("Terminal.js in rainbows".rainbow);

console.log(terminal.toString('ansi'));

There's also a webterminal using terminal.js: node-webterm

Documentation

The documentation is generated using JSDoc and can be found here

Source

Source is developed at Github

terminal.js's People

Contributors

gottox avatar jedi4ever avatar dependabot[bot] avatar kevinptt0323 avatar mildsunrise avatar alexdavid avatar ignasd avatar valette avatar

Stargazers

 avatar  avatar Ming avatar sontaku avatar Roc avatar 麦草 avatar Roy Thia avatar Simon Collins avatar  avatar Magda Kordo avatar  avatar Josh Klein avatar  avatar 于斯人也 avatar Johnny Shankman avatar  avatar Yuki Nagato avatar 3λiȯ+ avatar Andy avatar  avatar  avatar  avatar 0xDamian avatar Pete Garcin avatar elburg avatar  avatar  avatar Kazuki avatar treesong avatar  avatar mekb avatar Logan King (DarkComet) avatar Aarmn the limitless avatar abc avatar LGD.HuaFEEng avatar Gui Prá avatar Lucas avatar Pablo Pazos Gutiérrez avatar Starsign68 avatar  avatar emtee40 avatar Gábor Csárdi avatar Artur avatar Simone Sanfratello avatar Nicolas Dusart avatar Alexis Cheron avatar Christian Alfoni avatar Yifan Gu avatar  avatar ax4 avatar Chen Lijun avatar Ashin Woo avatar Duncan Marsh avatar  avatar  avatar Jack avatar Piotr Błażejewicz (Peter Blazejewicz) avatar Johnny Tseng avatar 5l1v3r1 avatar Vinicius Diogo de Melo avatar Pat avatar Ruy Adorno avatar Nicholas Ochoa avatar  avatar  avatar Noah avatar default avatar  avatar Tsiry Sandratraina avatar  avatar Weng Wang avatar Johnny Squardo avatar C H avatar damon lin avatar Sadi Qevani avatar _nirae avatar Khash  avatar ZCDC_Ren avatar Germán Lugo avatar HKJeon avatar JamesLinus avatar Mani Penguin avatar shizonic avatar  avatar  avatar Steven avatar bevin avatar Anh Le avatar ciolt avatar 疯狂十六进制 avatar Nikolay Kost avatar  avatar Kenneth Browder avatar Eva Garzón Beltrán avatar Your Friend avatar Jannis R avatar Chris Thaw avatar Aki Mimoto avatar Alexey avatar Kyle B avatar

Watchers

rryu avatar tom zhou avatar roadlabs avatar Nick Johnstone avatar Vasiliy Tolstov avatar timelyportfolio avatar James Cloos avatar  avatar Amin Shali avatar  avatar Christian QH ✔  avatar Michael Anthony avatar Carlis Liu avatar Yuki Urata avatar Damiano Zanardi avatar Rick Blundell avatar Walther Maciel avatar niwaka avatar  avatar  avatar  avatar Tang Xuanzhao avatar 王国伟 avatar  avatar  avatar

terminal.js's Issues

implement TermInput

support different types of inputs, e.g.:

  • DomInput: Use a Dom-Element for catching KeyPresses and them to the pty
  • NodeInput: Use a node.js process to catch stdin, stdout and signals

TermBuffer.apply and TermBuffer.diff should move to another class

applying and diffing is nothing a Buffer should care about.

TermDiff is old and its functionality overlap with .apply() and .diff(). It should be replaced by a new implementation based on functions described above. API proposal:

  • new TermDiff(term1, term2) should diff two terminals and create a diff-class of both.
  • TermDiff.apply(term1) will apply itself to a given terminal.

This will change the API and therefore it will be targeted to 0.2

introduce browserify & turn Terminal into EventEmitter

This commit removes the BrowserBuild and introduces Browserify as discussed.
Terminal now inherits from EventEmitter and can emit events.
A simple inject event is emitted and an in browser test for testing event emitted is added.

jedi4ever@02a347d

Please merge #14 first then I can submit a pull request for this.

Backport changes

In Pullrequest #30 were changes made to csi and modes. Backport these to the TermWriter branch

trigger more events

TermBuffer now supports simple 'inject' events.

The eventsystem should be more advanced and trigger the following events:

  • linechange: as soon as a line finished a change, this event should be triggered. terminal.js has some potential to not trigger this event after any character inserted, but for that, some code changes are needed, i.e. inject() can insert more than one character.
  • lineinsert: after a line is inserted
  • lineremove: after a line is removed
  • cursormove: whenever the cursor changes its position, trigger this event. As above, terminal.js can decide if it is useful to trigger or not.
  • ledchange: when the state of an LED has changed
  • bell: when a bell is triggered
  • request: requests attributes from terminal
  • resize: when the terminal changed its size (this will be triggered after corresponding linechange, lineinserted and lineremoved events)
  • ...

TermWriter should emit the following events:

  • finish: a junk of data is finished. Now it is the right time to re-render the view or create a diff.

These commands should be enough to satisfy rendering.

Initial Terminal Display Size

I think it would be useful to have a full square(cols,rows) border around the terminal webelement instead of only the lines that got renderer. It should take terminal(rows,cols) for initial display of a background or something similar

Implement greedy redraw on LiveBaseOutput

greedy redraw causes outputs to redraw itself only on completed junks or after a timeout. This should improve the performance of DomOutput dramatically.

This should be implemented in it's own class, so we could use that to improve network performance on slow connections too.

A pty/socket is not always what you want

A new change has been made :
var terminal = new Terminal(target,socket,80, 24);

I think for people using the lib, it will be confusing to specify the socket as a param.
Or at least as the second param

var terminal = new Terminal(target,80,24);
then they may use terminal.writer.write
(which is counterintuitive again , terminal.write should alias this)

if they want to use the live update, they can add it as the 4th param.
var terminal = new Terminal(target,80,24, socket);

And then you may want to link a different output and input there as well.

food for thought.

Edge case: when you move beyond the scrollbuffer rows

On an terminal with 80,24, when I do a write of

\x1b24;1Hline1\nline2

it should hold max 24 lines and it contains 25.

I guess it start with an error in the ScrolLRegion being defined as [0,Height] where this should be [0,height-1] , from there I guess it propogates further into asssumptions of the code with error. Most likely in the scroll function.

I'll await the new TermBufffer2 API to further investigate.

Include TerminalRenderer in terminal.js

At the moment, terminal.js only cares about the backend of a terminal. For the 0.2 milestone, it should support basic render tasks which are currently done in external libraries (e.g. webterminal.js)

This class(es) should support html, ascii, and DOM manipulation targets.

An class hierarchie proposal:

  • Renderer: Base class for rendering
    • HtmlRenderer: renders HTML
    • PlainRenderer: like the toString() method in Terminal
    • LiveRenderer: Base class for live-rendering
      • DomRenderer: inherits HtmlRenderer, changes content of a dom element when terminal is changed
      • TtyRenderer: renders to a tty. Can be used for screen-like applications
      • CanvasRenderer: renders to a HTML5 canvas. Not sure, if there's an advantage over DomRenderer other than speed.

A class member proposal:

  • Renderer(terminal, options)
    • toString(): returns string representation of current terminal.
  • LiveRenderer(terminal, target, options)
    • __insertLine(nbr)_: insert new line before line at index nbr. should return an object containing the view representation of the line.
    • __removeLine(nbr, view)_: remove line at index nbr.
    • __changeLine(nbr, view, startOffset, line)_: change line, starting at startOffset.
    • __changeLed(led1, led2, led3, led4)_: Change LED-Status
    • __clear()_: Clear screen.

Renderer should not rely on external libraries like jQuery or ansi.js.

a simple top, htop garbles the output screen

I've tested the terminal.js through running node-webterminal.

Simple things like editing a file , etc.. all work fine.
If I try to execute a top or htop then the output is garbled.

Maybe worth checking if you can confirm this behaviour?

moving webterminal.js code to this repo

If we want to make this library easily integration into a web client, I think it would make sense to move the webterminal code into this repo. This is to be as close as possible to the term.js as possible. Maybe create a directory webdist? or jquery?

The other option is to create a separate jquery module repo. but that will only be a hassle to sync with the code.

Make a proper README.md

At the moment, README.md is a little messy. Clean it up and give the developer a simple starting point to work with the library.

htop scrolling is buggy

when the scroll area of htop is scrolled upwards, it only scrolls the two top lines.

Can be reproduced with TERM={screen,vt100,xterm}

Refactor Terminal

Terminal isn't a fully terminal, and therefor should be named TermBuffer.

The new TermBuffer should trigger Events, when a line has been changed instead of this non-standard model terminal.js is currently using. This also will fix #4.

cat vt100test.txt breaks the terminal flow

when I executed a cat vt100test.txt is break my terminal in a way that my cursor will be on the firstline only and I can't even see new characters appear.

P.S. Maybe if you would explain your debugging workflow a bit? I'm happy to start adding sequences etc.. if they are missing?

Screen Shot 2013-04-21 at 14 56 51

rename terminal.js?

There are a bunch of projects called terminal.js. So, it makes sense to find a new unique name.

suggestions:

  • vt.js
  • term.js
  • jvt
  • jsterm
  • termlib.js

terminalDiff between 2 terminals or full screen data

Hi I'm trying the following scenario.

On the server side I have a terminal that receives the write changes. I figured from the node-terminal that I can use the Termdiff to calculate the difference since the last writes.

The downside of the current terminalDiff is that you could only use it once and then the internal oldBuffer gets reset.

The problem I'm facing is that when new clients connect they need a 'full' resync of the terminal state. I could opt to add a Termdiff.fullDiff to create a kind of 'total'screen state patch.

Another approach could be to keep 2 terminals and make Termdiff a function between (term1,term2).

To get the full state you could:

var backendTerm = new Terminal();
backendTerm.write('some stuff');

var freshTerm = new Terminal() ; 
var diff = freshTerm.diff(backendTerm);

be curious what approach you'd suggest.

clear does not work for TERM of then vt100

I don't know if it has to do with recent commits, but when I now do

$ TERM=vt220 (or screen-256-color ...)
$ clear

the screen will not clear, only the cursor will go to the top.
with TERM=vt100 is works.

TermBuffer2 internal format

To iterate over the format and see what modes a certain cell has is pretty inconvenient with the new internal format:

as we currently store the mode changes in the buffer , you'll have to re-execute the full stream every time to understand the current attrs of a cell. Unless I'm not getting it.

The old format had instant, cell , attr access make it easier to iterate over.

support line attributes

lines can be halfsize , double size etc...

The current internal buffer format does not have a way to store it.
This might have an impact on renderers, diff when the internal format needs to change.

So we'd better do it now :)

Can I fork it?

I will like to add a support for big5 encoding support, so can I fork it?

Seem like there is no mention of license in this project.

Clean up test output

Since barf testing was introduced, there were several error messages printed out. get rid of them (old IEs aren't supporting console.log, so these tests will fail on them anyway)

missing function eraseChar

I'm exploring the use of your library. Thanks for sharing!

In parts of the code eraseChar is called, but it is never defined?
Just wondering if I'm missing something ?

Occasionally this gets called when I run f.i. htop

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.