1 import { Component, OnInit, ViewChild } from '@angular/core';
3 // import { NgTerminal } from 'NgterminalModule';
5 // import { NgTerminal } from '@angular/material/NgTerminal';
6 import { NgTerminal } from 'ng-terminal';
7 import { Terminal } from 'xterm';
9 selector: 'app-terminal',
10 templateUrl: './terminal.component.html',
11 styleUrls: ['./terminal.component.scss']
13 export class TerminalComponent implements OnInit {
15 @ViewChild('term', { static: true }) child: NgTerminal;
19 this.obj = new Terminal(
31 this.child.keyEventInput.subscribe(e => {
32 console.log('keyboard event:' + e.domEvent.keyCode + ', ' + e.key);
34 const ev = e.domEvent;
35 const printable = !ev.altKey && !ev.ctrlKey && !ev.metaKey;
37 if (ev.keyCode === 13) {
38 this.child.write('\r\neliot@sample$ ');
39 } else if (ev.keyCode === 8) {
40 // Do not delete the prompt
41 if (this.child.underlying.buffer.cursorX > 14) {
42 this.child.write('\b \b');
44 } else if (printable) {
45 this.child.write(e.key);