XTerm
Namespace: Wisej.Web.Ext.XTerm
Assembly: Wisej.Web.Ext.XTerm (4.1.0.0)
Represents a terminal control based on xterm.js, a lightweight, free, and open source terminal for the web. See https://xtermjs.org/.
- C#
- VB.NET
public class XTerm : Widget
Public Class XTerm
Inherits Widget
The control only renders the terminal in the browser: it echoes the printable characters typed by the user and fires OnLineFeed with the collected line when the user presses Enter. It is up to the application to process the command and to write the output back using Write.
Example:
A minimal command prompt:
private void Page1_Load(object sender, EventArgs e)
{
this.xTerm1.OnInit += (s, args) => this.xTerm1.Write("$ ");
this.xTerm1.OnLineFeed += (s, command) =>
{
this.xTerm1.Write("\r\nYou typed: " + command + "\r\n$ ");
};
}
Constructors
XTerm()
Initializes a new instance of XTerm.
Properties
DebugScript
Boolean: Returns or sets a value indicating whether the xterm.js debug option is enabled.
The value is passed to the terminal through InitScript when the widget is initialized. When enabled, xterm.js logs diagnostic information to the browser console.
InitScript
String: Overridden to create our initialization script.
The script is generated from the embedded startup.js resource and the value of DebugScript. Assigning a value to this property has no effect.
Packages
List<Package>: Overridden to return our list of script resources.
The list is populated on first access with xterm.js, xterm.css and the attach, fit, winptyCompat, search, fullscreen and webLinks add-ons, all loaded from the embedded resources of this assembly.
Methods
OnWidgetEvent(e)
| Parameter | Type | Description |
|---|---|---|
| e | WidgetEventArgs |
Write(message)
Writes the text to the terminal.
| Parameter | Type | Description |
|---|---|---|
| message | String | The text to write. It may contain ANSI/VT100 escape sequences. |
The text is sent to the browser asynchronously and written as-is: to start a new line use "\r\n", since "\n" alone only moves the cursor down. The written text becomes part of the prompt and cannot be deleted by the user with the Backspace key.
Example:
Writing colored output followed by a new prompt:
this.xTerm1.Write("\u001b[32mBuild succeeded\u001b[0m\r\n");
this.xTerm1.Write("$ ");