Windows Terminal

repository·main·Indexed 13 days ago

https://github.com/microsoft/terminal

Source code and documentation for Windows Terminal, Windows Terminal Preview, and the Windows Console Host (conhost.exe). Includes the base/numerics C++ library for safe numeric operations using CheckedNumeric, ClampedNumeric, and StrictNumeric templates to handle overflow, underflow, and type conversions.

Tokens
120.5K
Snippets
271
Records
505
Agent score
98%

What's inside Windows Terminal

  1. Overview of MiniTerm (Experimental ConPTY Demo)

    main
    MiniTerm is an experimental terminal implementation written in C#. It serves as a demonstration of the Windows Pseudo Console (ConPTY) APIs. It is heavily based on native code examples and is intended to showcase basic API calls rather than for production or "real-world" usage.
  2. Overview of base/numerics library

    main

    The base/numerics library is a dependency-free, header-only C++ library providing templates for safe and performant numeric operations and conversions. It is organized into several key headers:

    • checked_math.h: Provides CheckedNumeric for arithmetic and conversions that detect errors like overflow or truncation.
    • clamped_math.h: Provides ClampedNumeric for fast, non-sticky saturating (clamped) arithmetic.
    • safe_conversions.h: Provides StrictNumeric and various casting templates for safe type conversion.
    • safe_math.h: A convenience header that includes all the above.

    Type Coercion Priority: When using these numeric types, they implicitly convert according to this priority:

    1. StrictNumeric coerces to ClampedNumeric and CheckedNumeric.
    2. ClampedNumeric coerces to CheckedNumeric.
  3. Navigate the Windows Terminal Settings UI

    main

    The Settings UI is organized into a hierarchical navigation structure accessible via a left-hand navigation bar. The top-level categories and their sub-items are:

    • General
      • Startup
      • Interaction
      • Rendering
    • Appearance
      • Global
      • Color schemes
      • Themes (Planned)
    • Profiles
      • Defaults
      • Individual profiles (Enumerate profiles)
      • Add new profile
    • Keyboard
    • Mouse (Planned)
    • Command Palette (Planned)
    • Marketplace (Planned)
  4. Terminal 2.0 Feature Scenarios

    main

    The Terminal 2.0 roadmap outlines key functional scenarios categorized by priority. These scenarios define the evolution of the terminal's user experience, ranging from mandatory core features to optional stretch goals.

    Priority Levels

    • 0 (Mandatory): Core features required for the 2.0 release (e.g., Settings UI, Command Palette).
    • 1 (Optimal): High-value features intended for the release (e.g., Clickable links, Default terminal, Tab tear-off).
    • 2 (Optional / Stretch-goal): Features that may be included if time permits (e.g., Infinite scrollback, Pane management).
    • 3 (Future): Features planned for later cycles (e.g., Quake mode, Session restoration).

    Key Shipped Features (Status: ✔️)

    • Settings UI: A graphical interface for editing settings.json.
    • Command palette: A popup menu for listing and executing actions/commands.
    • Clickable links: Hyperlinks in the text buffer that open in the default browser.
    • Default terminal: Ability to set Windows Terminal as the default handler for command-line applications.
    • Open tab in existing window: New tabs automatically open in existing Terminal windows.
    • Traditional opacity: Transparent backgrounds without the acrylic blur effect.
    • Jump list: Accessing profiles via the taskbar right-click menu or Start menu.
    • Open with multiple tabs: Launching Terminal with a specific tab configuration.
    • Open in Windows Terminal: Context menu option for files/folders.
    • Session restoration: Restoring previous tab, pane, and directory configurations on launch.
  5. Proposed Accessibility Priorities for Windows Terminal

    main

    The Windows Terminal accessibility roadmap prioritizes work items based on their impact on the command-line ecosystem. The priorities are categorized into three buckets:

    • Priority 1: Features that are currently practically unusable for users with accessibility needs.
    • Priority 2: Issues where active but potentially cumbersome workarounds exist.
    • Priority 3: Innovative features intended to provide an exceptional user experience.

    Key work items include VT Screen Reader Control, Shell suggestions, Search improvements, and Mark Mode support for degenerate ranges (Priority 1), as well as respecting High Contrast Mode and Text Size OS settings (Priority 2).

  6. What is Quake Mode in Windows Terminal

    main
    Quake Mode is a feature that allows a user to summon the Windows Terminal application from anywhere in the OS using a global hotkey. This is typically accompanied by a "dropdown" animation where the terminal window slides into view from the top of the screen. This behavior is inspired by the console interface in the game Quake and is common in other terminal emulators like Tilda and Guake.
  7. What is the Suggestions UI in Windows Terminal

    main

    The Suggestions UI is an ephemeral, Intellisense-like interface within Windows Terminal that appears at the point of text insertion. It provides actionable UI elements to the user based on context, helping to provide immediate content suggestions directly within the terminal control.

    Key capabilities include:

    • Displaying recent commands and directories (powered by shell integration).
    • Showing shell completions (e.g., PowerShell completions).
    • Presenting Tasks (defined as sendInput actions in user settings).
    • Providing Buffer Completions (autocomplete based on words in the current buffer).
    • Supporting third-party extensions that provide custom suggestion sources.
  8. Overview of Windows Terminal and Windows Console Host

    main

    This repository contains two primary command-line experiences:

    1. Windows Terminal: A modern, feature-rich terminal application supporting tabs, rich text, globalization, and advanced styling. It is built using a C++ codebase designed for high performance and low resource consumption.
    2. Windows Console Host (conhost.exe): The original Windows command-line experience. It hosts the Windows Console API server, input/rendering engines, and user preferences. While it maintains backward compatibility, it lacks modern features like tabs and advanced Unicode support found in Windows Terminal.

    Shared Components: The repository also contains modernized components (like a DirectWrite-based text engine and a VT parser) that are shared between the Console and the Terminal.

  9. Understand TerminalConnection states and events

    main

    The ITerminalConnection interface uses a state machine to track the lifecycle of a connection. Implementations must treat states as a directed acyclic graph (DAG) and must not transition in reverse.

    Connection States (TerminalConnection::ConnectionState):

    • NotConnected: The initial state for all new connections.
    • Connecting: The connection process has started but is not yet active.
    • Connected: The connection is active and ready.
    • Closing: The connection is being closed (typically via user request).
    • Closed: The connection terminated successfully (normal exit).
    • Failed: The connection was unexpectedly terminated (e.g., process crash or failed to spawn).

    Events:

    • StateChanged(ITerminalConnection, IInspectable): This event is triggered whenever the connection transitions between states. It replaces the deprecated TerminalDisconnected event.
  10. Proposed multi-mode architecture for Windows Terminal

    main

    To support features like tab tearoff and improved reliability, the design proposes moving away from a single-process model to a multi-mode architecture where wt.exe can run in different functional roles:

    1. Manager Mode: A headless broker (no UI) that manages kernel objects for a specific window station, session, and integrity level. It handles protocol handler routines, relays connections between frame hosts during tab movement, and determines where to instantiate new default-app tabs.
    2. Frame Host Mode: The outer shell of the application. It hosts the UI elements outside of individual tabs, such as the tab bar, settings dropdowns, and the title bar.
    3. Tab Host Mode: The inner shell of an individual tab. It hosts the rendering area, scroll bar, and inputs.
    4. Pane Host Mode: A potential deeper level of nesting for individual panes within a tab (or a recursive application of Tab Host mode).
    wt.exe - Manager Mode
    |- wt.exe - Frame Host Mode
    |   |- wt.exe - Tab Host Mode
    |   |  |- conhost.exe - ConPTY mode
    |   |     |- pwsh.exe - Client application
    |   |- wt.exe - Tab Host Mode
    |      |- conhost.exe - ConPTY mode
    |         |- cmd.exe - Client application
    |- wt.exe - Frame Host Mode
        |- wt.exe - Tab Host Mode
           |- conhost.exe - ConPTY mode
              |- pwsh.exe - Client application
  11. Proposal 2: Use `__default__` GUID in profiles list

    main

    Another proposal involves adding a special profile object to the profiles array with the magic GUID "__default__". Any settings defined in this specific profile object are applied to all other profiles in the list.

    {
        "profiles":
        [
            {
                "guid": "__default__",
                "useAcrylic": true,
                "acrylicOpacity": 0.1,
                "fontFace": "Cascadia Code",
                "fontSize": 10
            },
            {
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe"
            }
        ]
    }
  12. Conceptual design for Default Application IPC

    main

    This design describes how Windows Terminal handles being launched as the default application for console client applications (via conhost.exe) to ensure a seamless user experience.

    Scenario: No Windows Terminal instance is running

    When conhost.exe is triggered by the system to host a client application, it locates the installed wt.exe package and launches it with specific parameters to use the client's connection as its first tab (instead of the default startup tab). In this mode, conhost.exe remains invisible, operating in ConPTY mode, so only the new wt.exe window is visible to the user.

    Scenario: Windows Terminal is already running

    If a wt.exe instance is already active, conhost.exe identifies the running instance and adds the new client application as a new tab at the end of the existing tab bar.

    Scenario: Multiple Windows Terminal instances are running

    If multiple instances exist, the system must determine which instance should receive the new tab (e.g., the foreground instance, the active instance, or a designated primary/manager instance).