cc-terminal
Version:
AngularJs Web based terminal module
127 lines (126 loc) • 4.54 kB
TypeScript
import { OnInit, OnDestroy, DoCheck, ElementRef, Renderer2 } from '@angular/core';
import { CcTerminalService } from './cc-terminal.service';
import { CommandStore } from './cc-terminal-command-store';
import * as i0 from "@angular/core";
export declare class CcTerminalComponent implements OnInit, OnDestroy, DoCheck {
private renderer;
private store;
title: string;
private ngUnsubscribe;
_command: String;
_cursor: String;
_prompt: any;
_results: any;
_showPrompt: Boolean;
_tService: CcTerminalService;
private _cmdHistory;
private _cmdIndex;
private _initial;
private _nonPrintRE;
private _config;
private _outputDelay;
private _allowTypingWriteDisplaying;
private _hasFocus;
private _mOver;
private _aContext;
private _aBuffer;
private _prevLength;
private _disposableOutputObserver;
private _disposableCommandObserver;
terminal: ElementRef;
terminalViewport: ElementRef;
terminalResults: ElementRef;
terminalTarget: ElementRef;
ccStyle: any;
ccPrompt: {
end: string;
user: string;
separator: string;
path: string;
};
/**
* @description - adds \n to all strings that need formatting at index of string
* - function is not able to break line twice in case the remaining string is still longer than
* - screen -> but it would be best this does not happen -> maybe require min width of terminal div
* @param width - width
* @param text - text
* @param chr - character
*/
static _insertLineBreakToString(width: number, text: string, chr: string): string;
/**
* @description - This static function will clear the all output of the terminal commands
*/
static _clearTerminalResultsChildElements(): void;
constructor(_tService: CcTerminalService, renderer: Renderer2, store: CommandStore);
_initializeConfig(): void;
_handlePaste(e: any): boolean;
ngOnInit(): void;
ngOnDestroy(): void;
ngDoCheck(): void;
/**
* @description - This will add the output on the terminal
* TODO: We need to simulate the commands which is not added on terminal output
*
* TODO: @example -
*
* this.store.addCommand({
* name: 'example',
* details: {
* breakLine: true,
* output: true, // Output false have error
* readonly: false,
* result: [{
* text: () => {
* return 10 + 10;
* }
* }],
* },
* callback: () => {
* this._tService.broadcast('terminal-command', { command: 'help' });
* this._tService.broadcast('terminal-output', {
* details: {
* output: true,
* breakLine: true,
* result: [
* { text: 'yum yum' }
* ]
* }
* });
* alert('done');
* }
* });
*/
private _addToTerminalResults;
/**
* @description - This will will create a command typed to command prompt and do print on output
*/
private _createTypedOutputElement;
private _createOutputElement;
private _createOutputLineElement;
_type(input: any, line: any, i: any, endCallback: any): void;
_doSound(uri: string): void;
_loadAudio(source: string): Promise<AudioBuffer>;
_playAudio(): void;
_mouseover(): void;
_mouseleave(): void;
_clickHandler(): void;
_blur(): void;
/**
* @description - This will called when user will focus on input
*/
_focus(): void;
_key(e: any): void;
_keypress(keyCode: number): void;
_keydown(e: any): void;
_nextCommand(): void;
_previousCommand(): void;
_cleanNonPrintableCharacters(input: String): string;
_execute(): void;
_backspace(): void;
/**
* @description - This function will help you to register the commands
*/
_registerCommand: () => void;
static ɵfac: i0.ɵɵFactoryDeclaration<CcTerminalComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<CcTerminalComponent, "cc-terminal", never, { "ccStyle": "ccStyle"; "ccPrompt": "ccPrompt"; }, {}, never, never>;
}