Search code examples
javascriptangularjsnode.jscursesvt100

Node.js/angular wrapper for a vt100 application


I've been searching for a while and I cannot find an answer. I have found node.js terminal emulators but not the other way around.

My client uses a vt100 application on a linux box. He does not have source code but he needs the application. I think the app uses curses or some c library for moving around the screen.

He wants an html based wrapper that hides the terminal application.

Is there a way to have node.js communicate with the application sending a receiving commands from node with an angular web interface?

Thanks for your help.


Solution

  • Short version: Technically possible, practically infeasible.

    Recall that VT100 is a set of commands for controlling output on a terminal. (Originally a physical device; nowadays usually a terminal emulator application like XTerm.) These commands are all relatively low-level; generally speaking, they can change the way characters are output (e.g, bold and colors), move the cursor, or scroll or erase parts of the display. It also includes some "box-drawing" characters that can be output to draw some very simple graphics.

    Converting an application that builds a user interface using VT100 to a HTML user interface will be difficult on multiple levels:

    1. You will need to launch an instance of the "back-end" VT100 application (e.g, using pty.js) and keep it active in the background for as long as any user has an active session on your web site. If your web site has many users, this may translate to many instances of the application open at a time!

    2. You will need to interpret the raw characters that the VT100 application outputs as VT100 control sequences to reassemble it into a "snapshot" of what the application is trying to display at any given moment.

    3. Your application will need to interpret the contents of those snapshots into data that is ready to be displayed on a web site. Depending on how data is structured in the VT100 application, this may require your application to automatically perform certain actions (e.g, scrolling the display around) to collect all the information that is needed to display a single page on the web site.

    4. Your application will need to accept the user's input to your web site and translate it appropriately into input to the VT100 application. Depending on how the application and web site are organized, this might end up requiring it to perform many actions (e.g, opening and navigating multiple windows and menus, performing searches, switching modes, etc) to satisfy a single user request.

    Unless the existing application performs an extremely unusual task, it is very likely that adapting the existing VT100 application to a web interface will be vastly more work than developing a completely new web application to replace it. I would strongly recommend that you raise this possibility with your client.


    (A "cheating" solution might be to use a library like terminal.js to simply wrap the existing terminal application in a web page, without adapting or interpreting any of its content whatsoever. But I suspect this is not what you want.)