All Projects → qwefgh90 → ng-terminal

qwefgh90 / ng-terminal

Licence: other
NgTerminal is a terminal component on Angular 12. the Ivy distribution's released from v5.0.0.

Programming Languages

typescript
32286 projects
CSS
56736 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
SCSS
7915 projects

Projects that are alternatives of or similar to ng-terminal

angular-routing
Angular 13 Example Routing
Stars: ✭ 21 (-75.86%)
Mutual labels:  angular12, angular13
Wetty
Terminal in browser over http/https. (Ajaxterm/Anyterm alternative, but much better)
Stars: ✭ 3,076 (+3435.63%)
Mutual labels:  xterm, xtermjs
Angular-Movies
Angular Movies | TV Shows is a simple web app that consumes The Movie DB API - Angular 13 + Material Angular
Stars: ✭ 35 (-59.77%)
Mutual labels:  angular12, angular13
angular-pwa
Angular 13 Example Progressive Web App (PWA)
Stars: ✭ 45 (-48.28%)
Mutual labels:  angular12, angular13
angular-seo
Angular 13 Example SEO Search engine optimization + PWA + SSR + Lazyloading
Stars: ✭ 58 (-33.33%)
Mutual labels:  angular12, angular13
angular-ssr
Angular 14 Example SSR (Server side rendering)
Stars: ✭ 92 (+5.75%)
Mutual labels:  angular12, angular13
dystopia
Low to medium multithreaded Ubuntu Core honeypot coded in Python.
Stars: ✭ 59 (-32.18%)
Mutual labels:  telnet
blessed-xterm
XTerm Widget for Blessed Curses Environment
Stars: ✭ 37 (-57.47%)
Mutual labels:  xterm
docker-pudb
Debug Python code within a Docker container remotely from your terminal using pudb
Stars: ✭ 18 (-79.31%)
Mutual labels:  telnet
JwtAuthDemo
ASP.NET Core + Angular JWT auth demo; integration tests; login, logout, refresh token, impersonation, authentication, authorization; run on Docker Compose.
Stars: ✭ 278 (+219.54%)
Mutual labels:  angular13
Termination
Integrated terminal for Atom. Looks like terminal-plus, acts like your native terminal (except every other Friday). Looking for collaborators! :-)
Stars: ✭ 83 (-4.6%)
Mutual labels:  xterm
darktile
🌘 Darktile is a GPU rendered terminal emulator designed for tiling window managers.
Stars: ✭ 2,694 (+2996.55%)
Mutual labels:  xterm
w3c-keys
keyboardEvent.key compatible key codes with Typescript Definitions.
Stars: ✭ 55 (-36.78%)
Mutual labels:  keyboard-events
twilight-commander
A simple console file manager.
Stars: ✭ 16 (-81.61%)
Mutual labels:  xterm
webterm
web terminal based on xterm.js in rust
Stars: ✭ 20 (-77.01%)
Mutual labels:  xterm
noc
Official read only mirror for
Stars: ✭ 84 (-3.45%)
Mutual labels:  telnet
wcwidth-icons
Support fonts with double-width icons in xterm/rxvt-unicode/zsh/vim/…
Stars: ✭ 36 (-58.62%)
Mutual labels:  xterm
Offensive-Reverse-Shell-Cheat-Sheet
Offensive Reverse Shell (Cheat Sheet)
Stars: ✭ 138 (+58.62%)
Mutual labels:  xterm
contour
Modern C++ Terminal Emulator
Stars: ✭ 761 (+774.71%)
Mutual labels:  xterm
termpair
View and control terminals from your browser with end-to-end encryption 🔒
Stars: ✭ 1,390 (+1497.7%)
Mutual labels:  xtermjs

Build Status version GitHub license

NgTerminal is a web terminal that leverages xterm.js on Angular 11+. You can easily add it into your application by adding <ng-terminal></ng-terminal> into your component.

NgTerminal provides some features including xtermjs. You can adjust dimensions of a terminal by dragging and to fix the number of rows and cols. New usuful features should be added continuously.

Install

npm install ng-terminal --save

Run an example locally

You can run an example in your local environment.

  1. git clone https://github.com/qwefgh90/ng-terminal.git
  2. npm install
  3. npm run start

Getting started

Import NgTerminalModule in your AppModule.

import { NgTerminalModule } from 'ng-terminal';
//...
@NgModule({
    imports: [
        NgTerminalModule
    //...

And put <ng-terminal> into a source code of Component. Now a web terminal appears where you code it. The terminal will do nothing first. So, you should define how to operate.

  <ng-terminal #term></ng-terminal>

You can print or do something on the terminal with NgTerminal object which has some APIs for developers. You can get it by using @ViewChild in your component. It is important that an object of NgTerminalComponent is populated after ngAfterViewInit() is called.

You can print something in a terminal by passing them to the NgTerminal.write() function as an argument as follows, as soon as it receives user inputs from the terminal.

//...
export class YourComponent implements AfterViewInit{
  @ViewChild('term', { static: true }) child: NgTerminal;
  
  ngAfterViewInit(){
    //...
    this.child.keyEventInput.subscribe(e => {
      console.log('keyboard event:' + e.domEvent.keyCode + ', ' + e.key);

      const ev = e.domEvent;
      const printable = !ev.altKey && !ev.ctrlKey && !ev.metaKey;

      if (ev.keyCode === 13) {
        this.child.write('\n' + FunctionsUsingCSI.cursorColumn(1) + '$ '); // \r\n
      } else if (ev.keyCode === 8) {
        if (this.child.underlying.buffer.active.cursorX > 2) {
          this.child.write('\b \b');
        }
      } else if (printable) {
        this.child.write(e.key);
      }
    })
    //...
  }

  //...

NgTerminal

There are two ways to control the terminal. A first way is passing the arguments to input/output properties. API in NgTerminal is also a way to control the terminal. You can get a instance of NgTerminal by using @ViewChild.

Input/Output properties

Four properties (dataSource, rows, cols and draggable) are helpful to construct your temrinal. Check here.

<ng-terminal #term [dataSource]="writeSubject" (keyEvent)="onKeyEvent($event)" 
[rows]="10" 
[cols]="20" 
[draggable]="false"></ng-terminal>

API

NgTerminal is a interface to provide public APIs you can call directly. You can get a object by using @ViewChild with a type of NgTerminal.

  import { NgTerminal } from 'ng-terminal';
  ...
  @ViewChild('term', { static: true }) child: NgTerminal;

Underlying object (Xtermjs)

You can control a instance of the xtermjs directly by getting a property of underlying. Check out API of the Terminal from the API document.

Addons

ng-terminal uses only one addon which is fit to support the resize feature. If you want to use other addons, you can apply them to a underlying object. Maybe you can do that without any problem.

Control sequences

Control sequences is a programing interface to control terminal emulators. There are functions to return control sequences in a class of FunctionUsingCSI.

    import { FunctionsUsingCSI } from 'ng-terminal';
    ...
    const sequences = "data..1" + FunctionsUsingCSI.cursorBackward(1) + '2';
    component.write(sequences);

You can find official supported terminal sequences in https://xtermjs.org/docs/api/vtfeatures/. And you can also read helpful article here. For example, you can move a cursor down by passing \x1b[1E to write(). Try in the sample page

Contribution

NgTerminal is developed with Angular CLI. You can always write issue and contribute through PR to master branch.

Available commands

  • Running an example app in your environment: npm start
  • Testing ng-terminal: npm test
  • Creating a tarball for testing with external angular apps: npm run local
  • (Travis) Creating a static page for this project: npm run page
  • (Maintainer) Deploying a library to the npm registry: npm run publish
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].