[][src]Module xterm_js_sys::xterm

Bindings for the xterm.js public API.

Unfortunately we can't (yet) generate the below from the TypeScript type definitions for xterm.js, so we do it by hand.

This isn't a pure mechanical translation of the xterm.js bindings; docs have been adjusted in places (mainly just to link to the right things on the Rust side) but most importantly interfaces have been converted to either concrete Rust types (that are accessible from JavaScript), imported types (duck types that won't correspond exactly to any concrete type on the JavaScript side and thus can't be constructed from Rust), or imported types + a concrete type that satisfies the interface with a Rust trait with methods that can construct the concrete type for anything satisfying the trait.

Generic interfaces are also problematic; these have been "manually monomorphized" (i.e. IEvent<Object, Void>FnMut(KeyEventData) on the Rust side).

In general, the rule used for interfaces has been:

See: this and this.

Mirroring Interfaces

As mentioned, when it's desirable to construct types that satisfy an interface within Rust, we create a Rust trait that's mirror of the interface in question. XtermAddon (behind the ext feature) is probably the best example of this; we want to be able to make it so that addons can be written in Rust.

So, to make this possible we do these things:

Okay! So at this point, we've got a Rust trait that mirrors a JS interface and all things that implement the interface impl the Rust trait automagically. Presumably, when we want to write an impl of the interface on the Rust side of things, we just impl the trait.

And this works, but there's one catch: if we're just using the impls of the interface that we made in Rust, this will work just fine. Implementations that are actually written in JavaScript will internally go call their JS methods and the thing in Rust that's using the trait implementation won't be any the wiser.

But, if we want to pass along implementations written in Rust to a JavaScript user of the interface, this isn't enough.

Addons are a good example, again. It isn't enough to just be able to write something in Rust that has the shape of an addon; the point here is that we're able to pass it to xterm.js and actually use it! So, to do this, there are some more things we have to understand and do.

First some background:

A couple of other considerations, though:

The final piece required is an extension method that takes the Rust trait impl instead of the concrete type and then converts it to concrete type using the trait impl and passes the concrete type instance along to the wasm-bindgen method that expects it.

Structs

Buffer

Represents a terminal buffer.

BufferCell

Represents a single cell in the terminal’s buffer.

BufferLine

Represents a line in the terminal’s buffer.

BufferNamespace

Represents the terminal's set of buffers.

Disposable

An object that can be disposed via a dispose function.

FunctionIdentifier

Data type to register a CSI, DCS, or ESC callback in the parser in the form:

KeyEventData

Corresponds to { key: string, domEvent: KeyboardEvent }.

LinkMatcherOptions

An object containing options for a link matcher.

LocalizableStrings

The set of localizable strings.

Marker

Represents a specific line in the terminal that is tracked when scrollback is trimmed and lines are added or removed. This is a single line that may be part of a larger wrapped line.

Parser

Allows hooking into the parser for custom handling of escape sequences.

RenderEventData

Corresponds to { start: number, end: number }.

ResizeEventData

Corresponds to { cols: number, rows: number }.

SelectionPosition

An object representing a selection within the terminal.

Terminal

The class that represents an xterm.js terminal.

TerminalAddon

An addon that can provide additional functionality to the terminal.

TerminalOptions

An object containing start up options for the terminal.

Theme

Contains colors to theme the terminal with.

UnicodeHandling

[EXPERIMENTAL] Unicode handling interface.

UnicodeVersionProvider

[EXPERIMENTAL] Unicode version provider.

ViewportRange

An object representing a range within the viewport of the terminal.

ViewportRangePosition

An object representing a cell position within the viewport of the terminal.

WindowOptions

Enable various window manipulation and report features (CSI Ps ; Ps ; Ps t).

Enums

BellStyle

The type of the bell notification the terminal will use.

BufferType

A string representing the type of a buffer.

CursorStyle

The style of the cursor.

FastScrollModifier

The modifier key hold to multiply scroll speed.

FontWeight

A string representing text font weight.

LogLevel

A string representing log level.

RendererType

A string representing a renderer type.

WideCharacterWidth

Width of a Wide Character.

Constants

__wbg_generated_const_Buffer
__wbg_generated_const_BufferCell
__wbg_generated_const_BufferLine
__wbg_generated_const_BufferNamespace
__wbg_generated_const_Disposable
__wbg_generated_const_KeyEventData
__wbg_generated_const_LocalizableStrings
__wbg_generated_const_Marker
__wbg_generated_const_Parser
__wbg_generated_const_RenderEventData
__wbg_generated_const_ResizeEventData
__wbg_generated_const_SelectionPosition
__wbg_generated_const_Terminal
__wbg_generated_const_TerminalAddon
__wbg_generated_const_UnicodeHandling
__wbg_generated_const_UnicodeVersionProvider

Type Definitions

Color

A Color for use with xterm.js.

Str

An alias for String.