XtermSharp Terminal Emulator Engine

repository·master·Indexed 41 days ago

https://github.com/migueldeicaza/xtermsharp

A VT100/Xterm terminal emulator engine for .NET designed to be decoupled from UI front-ends and data back-ends. It supports keyboard and mouse interaction, Unicode, and interactive applications like Emacs and vi. Includes XtermSharp.Mac for embedding terminal interfaces into macOS applications via NSView.

Tokens
634
Snippets
1
Records
4
Agent score
2%

What's inside XtermSharp

  1. Overview of XtermSharp

    master

    XtermSharp is a VT100/Xterm terminal emulator engine for .NET. It is designed to be agnostic of both front-ends (UI toolkits) and back-ends (data sources).

    Key architectural points:

    • Engine Agnostic: The core engine does not handle connecting to processes or remote servers. It only processes terminal data.
    • Data Input: To send data to the terminal, you must pass a byte array to the Feed method.
    • Integration: Consumers typically use higher-level implementations that integrate the engine with specific UI toolkits (e.g., Cocoa/Mac or Terminal.Gui).
  2. How to feed data to the XtermSharp terminal

    master

    The core XtermSharp engine does not automatically connect to a process or a remote server. To display data in the terminal, you must manually feed data into it by passing a byte array to the Feed method.

    While the core engine requires manual data feeding, convenience classes are available to spawn a subprocess and connect the terminal to a local process, including options to customize environment variables for the child process.

    // Conceptual usage of the Feed method
    // terminal is an instance of the XtermSharp engineyte[] data = GetDataFromProcess();
    terminal.Feed(data);
  3. Use XtermSharp.Mac for macOS applications

    master

    XtermSharp.Mac is a library built on top of XtermSharp specifically for macOS. It provides an NSView that can be embedded directly into macOS applications to provide a terminal interface.

    Key details:

    • Input Mapping: It automatically maps macOS user input to send the appropriate data to the underlying XtermSharp terminal.
    • Backend Responsibility: Like the core engine, XtermSharp.Mac does not wire the terminal to a backend or a process; you must implement the connection to a shell or process in your own code.
    • Reference Implementation: You can refer to the MacTerminal project for an example of how to connect a Unix shell process to the Mac implementation.
  4. Capabilities and limitations of XtermSharp

    master

    Supported Features

    • Interactive Applications: Supports running Emacs, vi, top, mc, blessed, and gui.cs.
    • Input: Supports both keyboard and mouse interaction.
    • Unicode: Provides decent Unicode handling (though Grapheme cluster support is a future roadmap item).

    Current Limitations

    • Scrollback and Reflow: These features are currently missing.
    • Platform Differences: Some features are only available in the Mac version; the text-based version using curses has certain limitations.