[][src]Struct xterm_js_sys::xterm::Terminal

#[repr(transparent)]pub struct Terminal {
    obj: Disposable,
}

The class that represents an xterm.js terminal.

Fields

obj: Disposable

Implementations

impl Terminal[src]

pub fn new(options: Option<TerminalOptions>) -> Terminal[src]

Creates a new Terminal object.

Takes options: an object containing a set of options.

impl Terminal[src]

pub fn buffer(&self) -> BufferNamespace[src]

[EXPERIMENTAL] The terminal’s current buffer, this might be either the normal buffer or the alt buffer depending on what’s running in the terminal.

impl Terminal[src]

pub fn cols(&self) -> u16[src]

The number of columns in the terminal’s viewport. Use TerminalOptions::cols to set this in the constructor and Terminal::resize for when the terminal exists.

impl Terminal[src]

pub fn element(&self) -> Option<Element>[src]

The element containing the terminal.

impl Terminal[src]

pub fn markers(&self) -> ReadOnlyArray<Marker>[src]

[EXPERIMENTAL] Get all markers registered against the buffer.

If the alt buffer is active this will always return [] (an empty array).

impl Terminal[src]

pub fn on_binary(&self, listener: &Closure<dyn FnMut(Str)>) -> Disposable[src]

Adds an event listener for when a binary event fires.

This is used to enable non UTF-8 conformant binary messages to be sent to the backend. Currently this is only used for a certain type of mouse reports that happen to be not UTF-8 compatible. The event value is a String, pass it to the underlying pty as binary data, e.g. pty.write(Buffer.from(data, 'binary')).

Returns a Disposable to stop listening.

See attach_binary_event_listener (if the ext feature is enabled) for a friendlier version of this function.

impl Terminal[src]

pub fn on_cursor_move(&self, listener: &Closure<dyn FnMut()>) -> Disposable[src]

Adds an event listener for the cursor moves.

Returns a Disposable to stop listening.

See attach_cursor_move_event_listener (if the ext feature is enabled) for a friendlier version of this function.

impl Terminal[src]

pub fn on_data(&self, listener: &Closure<dyn FnMut(Str)>) -> Disposable[src]

Adds an event listener for when a data event fires.

This happens, for example, when the user types or pastes into the terminal. The event value is whatever String results; in a typical setup, this should be passed on to the backing pty.

Returns a Disposable to stop listening.

See attach_data_event_listener (if the ext feature is enabled) for a friendlier version of this function.

impl Terminal[src]

pub fn on_key(&self, listener: &Closure<dyn FnMut(KeyEventData)>) -> Disposable[src]

Adds an event listener for when a key is pressed.

The event value (KeyEventData) contains the string that will be sent in the data event as well as the DOM event that triggered it.

Returns a Disposable to stop listening.

See attach_key_event_listener (if the ext feature is enabled) for a friendlier version of this function.

impl Terminal[src]

pub fn on_line_feed(&self, listener: &Closure<dyn FnMut()>) -> Disposable[src]

Adds an event listener for when a line feed is added.

Returns a Disposable to stop listening.

See attach_line_feed_event_listener (if the ext feature is enabled) for a friendlier version of this function.

impl Terminal[src]

pub fn on_render(
    &self,
    listener: &Closure<dyn FnMut(RenderEventData)>
) -> Disposable
[src]

Adds an event listener for when rows are rendered.

The event value (RenderEventData) contains the start row and end row of the rendered area (ranges from 0 to [Terminal::rows] - 1).

Returns a Disposable to stop listening.

See attach_render_event_listener (if the ext feature is enabled) for a friendlier version of this function.

impl Terminal[src]

pub fn on_resize(
    &self,
    listener: &Closure<dyn FnMut(ResizeEventData)>
) -> Disposable
[src]

Adds an event listener for when the terminal is resized.

The event value (ResizeEventData) contains the new size.

Returns a Disposable to stop listening.

See attach_resize_event_listener (if the ext feature is enabled) for a friendlier version of this function.

impl Terminal[src]

pub fn on_scroll(&self, listener: &Closure<dyn FnMut(u32)>) -> Disposable[src]

Adds an event listener for when a event listener for when a scroll occurs.

The event value is the new position of the viewport.

Returns a Disposable to stop listening.

See attach_scroll_event_listener (if the ext feature is enabled) for a friendlier version of this function.

impl Terminal[src]

pub fn on_selection_change(&self, listener: &Closure<dyn FnMut()>) -> Disposable[src]

Adds an event listener for when a selection change occurs.

Returns a Disposable to stop listening.

See attach_selection_change_event_listener (if the ext feature is enabled) for a friendlier version of this function.

impl Terminal[src]

pub fn on_title_change(&self, listener: &Closure<dyn FnMut(Str)>) -> Disposable[src]

Adds an event listener for when an OSC 0 or OSC 2 title change occurs.

The event value is the new title.

Returns a Disposable to stop listening.

See attach_title_change_event_listener (if the ext feature is enabled) for a friendlier version of this function.

impl Terminal[src]

pub fn parser(&self) -> Parser[src]

[EXPERIMENTAL] Get the parser interface to register custom escape sequence handlers.

impl Terminal[src]

pub fn rows(&self) -> u16[src]

The number of rows in the terminal’s viewport. Use TerminalOptions.rows to set this in the constructor and Terminal::resize for when the terminal exists.

impl Terminal[src]

pub fn textarea(&self) -> Option<HtmlTextAreaElement>[src]

The textarea that accepts input for the terminal.

impl Terminal[src]

pub fn unicode(&self) -> UnicodeHandling[src]

[EXPERIMENTAL] Get the Unicode handling interface.

This can be used to register Unicode versions and switch the active Unicode version.

impl Terminal[src]

pub fn strings(&self) -> LocalizableStrings[src]

Natural language strings that can be localized.

impl Terminal[src]

pub fn blur(&self)[src]

Unfocus the terminal.

impl Terminal[src]

pub fn clear(&self)[src]

Clear the entire buffer, making the prompt line the new first line.

impl Terminal[src]

pub fn clear_selection(&self)[src]

Clears the current terminal selection.

impl Terminal[src]

pub fn focus(&self)[src]

Focus the terminal.

impl Terminal[src]

pub fn get_selection(&self) -> Str[src]

Gets the terminal’s current selection; this is useful for implementing copy behavior outside of xterm.js.

impl Terminal[src]

pub fn get_selection_position(&self) -> Option<SelectionPosition>[src]

Gets the selection position or None if there is no selection.

impl Terminal[src]

pub fn has_selection(&self) -> bool[src]

Gets whether the terminal has an active selection.

impl Terminal[src]

pub fn load_addon(&self, addon: TerminalAddon)[src]

Loads an addon into this instance of the xterm.js Terminal.

Takes:

  • addon: The addon to load.

See load_xterm_addon (if the ext feature is enabled) for a friendlier version of this function.

impl Terminal[src]

pub fn open(&self, parent: Element)[src]

Opens the terminal within an element.

Takes:

  • parent: The element to create the terminal within. This element must be visible (have dimensions) when open is called as several DOM-based measurements need to be performed when this function is called.

impl Terminal[src]

pub fn paste(&self, data: Str)[src]

Writes text to the terminal, performing the necessary transformations for pasted text.

Takes:

  • data: The text to write to the terminal.

impl Terminal[src]

pub fn refresh(&self, start: u16, end: u16)[src]

Tells the renderer to refresh terminal content between two rows (inclusive) at the next opportunity.

Takes:

  • start: The row to start from (between 0 and [Terminal::rows] - 1).
  • end: The row to end at (between start and [Terminal::rows] - 1).

impl Terminal[src]

pub fn reset(&self)[src]

Perform a full reset (RIS, aka ‘\x1bc’).

impl Terminal[src]

pub fn resize(&self, columns: u16, rows: u16)[src]

Resizes the terminal.

It’s best practice to debounce calls to resize, this will help ensure that the pty can respond to the resize event before another one occurs.

impl Terminal[src]

pub fn scroll_lines(&self, amount: i32)[src]

Scroll the display of the terminal.

Takes:

  • amount: The number of lines to scroll down (negative scrolls up).

impl Terminal[src]

pub fn scroll_pages(&self, page_count: i32)[src]

Scroll the display of the terminal by a number of pages.

Takes:

  • page_count: The number of pages to scroll (negative scrolls up).

impl Terminal[src]

pub fn scroll_to_bottom(&self)[src]

Scrolls the display of the terminal to the bottom.

impl Terminal[src]

pub fn scroll_to_line(&self, line: u32)[src]

Scrolls to a line within the buffer.

Takes:

  • line: The 0-based line index to scroll to.

impl Terminal[src]

pub fn scroll_to_top(&self)[src]

Scrolls the display of the terminal to the top.

impl Terminal[src]

pub fn select(&self, column: u16, row: u32, length: u32)[src]

Selects text within the terminal.

Takes:

  • column: The column the selection starts at.
  • row: The row the selection starts at.
  • length: The length of the selection.

impl Terminal[src]

pub fn select_all(&self)[src]

Selects all text within the terminal.

impl Terminal[src]

pub fn select_lines(&self, start: u32, end: u32)[src]

Selects text in the buffer between 2 lines.

Takes:

  • start: The 0-based line index to select from (inclusive).
  • end: The 0-based line index to select to (inclusive).

impl Terminal[src]

pub fn write(&self, data: Str)[src]

Writes data to the terminal.

Takes:

  • data: The data to write to the terminal. The actual API allows for this to be either raw bytes given as Uint8Array from the pty or a string (raw bytes will always be treated as UTF-8 encoded, string data as UTF-16). For simplicity, we just take a String; this shouldn't cause problems (going from UTF-8 encoded Rust Strings to UTF-16 JS strings) and just makes things simpler.

impl Terminal[src]

pub fn write_with_callback(&self, data: Str, callback: &Closure<dyn FnMut()>)[src]

Writes data to the terminal and takes a callback.

This identical to write except it also takes a callback.

Takes:

  • data: The data to write to the terminal. The actual API allows for this to be either raw bytes given as Uint8Array from the pty or a string (raw bytes will always be treated as UTF-8 encoded, string data as UTF-16). For simplicity, we just take a String; this shouldn't cause problems (going from UTF-8 encoded Rust Strings to UTF-16 JS strings) and just makes things simpler.
  • callback: Callback that fires when the data was processed by the parser.

impl Terminal[src]

pub fn load_xterm_addon<A: IntoJsInterface<TerminalAddon>>(&self, addon: &A)[src]

This is supported on feature="ext" only.

Loads an addon into this instance of the xterm.js Terminal.

This supports Rust defined addons as well as JS defined addons and is otherwise identical to Terminal::load_addon.

impl Terminal[src]

#[must_use]pub fn new_with_wrapper(
    options: Option<TerminalOptions>
) -> DisposableWrapper<Terminal>
[src]

This is supported on feature="ext" only.

Terminal constructor that encloses the resulting Terminal in a DisposableWrapper.

This is otherwise identical to Terminal::new.

impl Terminal[src]

pub fn attach_binary_event_listener<F>(
    &self,
    listener: F
) -> DisposableWrapper<Disposable> where
    F: FnMut(Str),
    F: 'static, 
[src]

This is supported on feature="ext" only.

Attaches a binary event listener and returns a DisposableWrapper that can be dropped to make xterm.js stop sending the event listener events. This is sugar for Terminal::on_binary.

We assume event listener closures are going to be long-lived, so we leak the closure that is produced here!

pub fn attach_cursor_move_event_listener<F>(
    &self,
    listener: F
) -> DisposableWrapper<Disposable> where
    F: FnMut(),
    F: 'static, 
[src]

This is supported on feature="ext" only.

Attaches a cursor move event listener and returns a DisposableWrapper that can be dropped to make xterm.js stop sending the event listener events. This is sugar for Terminal::on_cursor_move.

We assume event listener closures are going to be long-lived, so we leak the closure that is produced here!

pub fn attach_data_event_listener<F>(
    &self,
    listener: F
) -> DisposableWrapper<Disposable> where
    F: FnMut(Str),
    F: 'static, 
[src]

This is supported on feature="ext" only.

Attaches a data event listener and returns a DisposableWrapper that can be dropped to make xterm.js stop sending the event listener events. This is sugar for Terminal::on_data.

We assume event listener closures are going to be long-lived, so we leak the closure that is produced here!

pub fn attach_key_event_listener<F>(
    &self,
    listener: F
) -> DisposableWrapper<Disposable> where
    F: FnMut(KeyEventData),
    F: 'static, 
[src]

This is supported on feature="ext" only.

Attaches a key event event listener and returns a DisposableWrapper that can be dropped to make xterm.js stop sending the event listener events. This is sugar for Terminal::on_key.

We assume event listener closures are going to be long-lived, so we leak the closure that is produced here!

pub fn attach_line_feed_event_listener<F>(
    &self,
    listener: F
) -> DisposableWrapper<Disposable> where
    F: FnMut(),
    F: 'static, 
[src]

This is supported on feature="ext" only.

Attaches a line feed event listener and returns a DisposableWrapper that can be dropped to make xterm.js stop sending the event listener events. This is sugar for Terminal::on_line_feed.

We assume event listener closures are going to be long-lived, so we leak the closure that is produced here!

pub fn attach_render_event_listener<F>(
    &self,
    listener: F
) -> DisposableWrapper<Disposable> where
    F: FnMut(RenderEventData),
    F: 'static, 
[src]

This is supported on feature="ext" only.

Attaches a render event listener and returns a DisposableWrapper that can be dropped to make xterm.js stop sending the event listener events. This is sugar for Terminal::on_render.

We assume event listener closures are going to be long-lived, so we leak the closure that is produced here!

pub fn attach_resize_event_listener<F>(
    &self,
    listener: F
) -> DisposableWrapper<Disposable> where
    F: FnMut(ResizeEventData),
    F: 'static, 
[src]

This is supported on feature="ext" only.

Attaches a resize event listener and returns a DisposableWrapper that can be dropped to make xterm.js stop sending the event listener events. This is sugar for Terminal::on_resize.

We assume event listener closures are going to be long-lived, so we leak the closure that is produced here!

pub fn attach_scroll_event_listener<F>(
    &self,
    listener: F
) -> DisposableWrapper<Disposable> where
    F: FnMut(u32),
    F: 'static, 
[src]

This is supported on feature="ext" only.

Attaches a scroll event listener and returns a DisposableWrapper that can be dropped to make xterm.js stop sending the event listener events. This is sugar for Terminal::on_scroll.

We assume event listener closures are going to be long-lived, so we leak the closure that is produced here!

pub fn attach_selection_change_event_listener<F>(
    &self,
    listener: F
) -> DisposableWrapper<Disposable> where
    F: FnMut(),
    F: 'static, 
[src]

This is supported on feature="ext" only.

Attaches a selection change event listener and returns a DisposableWrapper that can be dropped to make xterm.js stop sending the event listener events. This is sugar for Terminal::on_selection_change.

We assume event listener closures are going to be long-lived, so we leak the closure that is produced here!

pub fn attach_title_change_event_listener<F>(
    &self,
    listener: F
) -> DisposableWrapper<Disposable> where
    F: FnMut(Str),
    F: 'static, 
[src]

This is supported on feature="ext" only.

Attaches a title change event listener and returns a DisposableWrapper that can be dropped to make xterm.js stop sending the event listener events. This is sugar for Terminal::on_title_change.

We assume event listener closures are going to be long-lived, so we leak the closure that is produced here!

Methods from Deref<Target = Disposable>

pub fn dispose(&self)[src]

Disposes of the instance.

This can involve unregistering an event listener or cleaning up resources or anything else that should happen when an instance is disposed of.

Trait Implementations

impl AsRef<Disposable> for Terminal[src]

impl AsRef<JsValue> for Terminal[src]

impl AsRef<Terminal> for Terminal[src]

impl Clone for Terminal[src]

impl Debug for Terminal[src]

impl Deref for Terminal[src]

type Target = Disposable

The resulting type after dereferencing.

impl<'a> From<&'a Terminal> for XtermJsCrosstermBackend<'a>[src]

impl From<JsValue> for Terminal[src]

impl From<Terminal> for JsValue[src]

impl From<Terminal> for Disposable[src]

impl FromWasmAbi for Terminal[src]

type Abi = <JsValue as FromWasmAbi>::Abi

The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more

impl IntoWasmAbi for Terminal[src]

type Abi = <JsValue as IntoWasmAbi>::Abi

The wasm ABI type that this converts into when crossing the ABI boundary. Read more

impl<'a> IntoWasmAbi for &'a Terminal[src]

type Abi = <&'a JsValue as IntoWasmAbi>::Abi

The wasm ABI type that this converts into when crossing the ABI boundary. Read more

impl JsCast for Terminal[src]

impl OptionFromWasmAbi for Terminal[src]

impl OptionIntoWasmAbi for Terminal[src]

impl<'a> OptionIntoWasmAbi for &'a Terminal[src]

impl RefFromWasmAbi for Terminal[src]

type Abi = <JsValue as RefFromWasmAbi>::Abi

The wasm ABI type references to Self are recovered from.

type Anchor = ManuallyDrop<Terminal>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don't persist beyond one function call, and so that they remain anonymous. Read more

impl WasmDescribe for Terminal[src]

Auto Trait Implementations

impl RefUnwindSafe for Terminal

impl !Send for Terminal

impl !Sync for Terminal

impl Unpin for Terminal

impl UnwindSafe for Terminal

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<X> IntoJsInterface<Disposable> for X where
    X: XtermDisposable + Clone + 'static, 
[src]

fn to(Self) -> Disposable[src]

This is supported on feature="ext" only.

Converts the XtermDisposable implementor into an instance of Disposable (the corresponding JS interface).

fn by_ref(&Self) -> Disposable[src]

This is supported on feature="ext" only.

Converts the XtermDisposable implementor into an instance of Disposable (the corresponding JS interface) by reference.

impl<T> ReturnWasmAbi for T where
    T: IntoWasmAbi
[src]

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<X> XtermDisposable for X where
    X: Clone + 'static + AsRef<Disposable>, 
[src]

fn dispose(&Self)[src]

This is supported on feature="ext" only.

dispose for types that implement the Disposable interface.

fn into_js_by_ref(&Self) -> Disposable[src]

This is supported on feature="ext" only.

into_js_by_ref for types that implement the Disposable interface.

This differs from the default impl in that it manages to avoid a Clone before effectively doing what into_js does.

fn into_js(Self) -> Disposable[src]

This is supported on feature="ext" only.

into_js for types that implement the Disposable interface.

This differs from the default impl in that it manages to avoid "double wrapping" the methods in the interface (types that impl Disposable the wasm-bindgen way already have a wrapped up Object they can hand us).