# Where Are the Shared Components for Windows Terminal Located?

> Discover where Windows Terminal shared components reside within the microsoft terminal repository. Find the Template Internal Library TIL in srcinc til and LibraryIncludes h for centralized access.

- Repository: [Microsoft/terminal](https://github.com/microsoft/terminal)
- Tags: internals
- Published: 2026-02-26

---

**Windows Terminal's shared components are located in the `src/inc/til/` directory as part of the Template Internal Library (TIL), with centralized access provided through [`src/inc/LibraryIncludes.h`](https://github.com/microsoft/terminal/blob/main/src/inc/LibraryIncludes.h).**

The Microsoft Terminal repository organizes its codebase into distinct layers for the UI, rendering engine, and terminal host. To prevent duplication across these layers, the project maintains a dedicated library of header-only utilities that handle geometry, synchronization, containers, and throttling. Understanding the location and structure of these shared components is essential for contributors working across multiple subsystems.

## The TIL Library: Windows Terminal's Shared Component Architecture

The **Template Internal Library (TIL)** serves as the foundational utility layer for the entire Windows Terminal project. Unlike feature-specific code that lives in `src/cascadia/` (UI) or `src/renderer/` (graphics), TIL provides cross-cutting concerns used by every component.

All TIL headers reside in **`src/inc/til/`**. These are header-only implementations, meaning the compiler inlines the code at the call site for zero runtime overhead. The library is designed to be self-contained and dependency-minimal, relying primarily on the C++ standard library and Windows SDK primitives.

## Core Shared Components in `src/inc/til`

The TIL directory organizes its utilities by functional area. Here are the primary categories of shared components available to Windows Terminal developers.

### Geometry and Color Utilities

Basic geometric types and color manipulation helpers are defined in individual headers under `src/inc/til/`:

- **`til::point`** – 2D coordinate representation ([`src/inc/til/point.h`](https://github.com/microsoft/terminal/blob/main/src/inc/til/point.h))
- **`til::rect`** – Rectangle operations and containment checks ([`src/inc/til/rect.h`](https://github.com/microsoft/terminal/blob/main/src/inc/til/rect.h))
- **`til::color`** – RGB/ARGB color utilities with conversion helpers ([`src/inc/til/color.h`](https://github.com/microsoft/terminal/blob/main/src/inc/til/color.h))

These types provide consistent, bounds-checked alternatives to raw Win32 `POINT` and `RECT` structures.

### Specialized Containers

TIL includes custom container implementations optimized for terminal-specific use cases:

- **`til::small_vector`** – A vector optimized for small buffer sizes, avoiding heap allocations for typical terminal buffer lines
- **`til::static_map`** – A compile-time fixed-size map for configuration key lookups

These reside in their respective headers (e.g., [`src/inc/til/small_vector.h`](https://github.com/microsoft/terminal/blob/main/src/inc/til/small_vector.h)) and are used extensively in the text buffer and settings parsing layers.

### Thread Synchronization Primitives

The **`til::shared_mutex<T>`** template in [`src/inc/til/mutex.h`](https://github.com/microsoft/terminal/blob/main/src/inc/til/mutex.h) combines a `std::shared_mutex` with the data it protects. This pattern enforces lock ownership semantics at the type level, preventing data races by design.

The implementation provides:
- `lock()` – Returns an exclusive guard
- `lock_shared()` – Returns a shared (read-only) guard

### Rate Limiting Helpers

UI components frequently need to throttle expensive operations. The **`til::ThrottledFunc`** template in [`src/inc/til/throttled_func.h`](https://github.com/microsoft/terminal/blob/main/src/inc/til/throttled_func.h) implements a reference-counted, time-based rate limiter.

It accepts:
- A callback function
- A minimum interval between invocations
- An optional initial delay

This is used to debounce window resize events and settings reloads without blocking the UI thread.

## Accessing Shared Components via [`LibraryIncludes.h`](https://github.com/microsoft/terminal/blob/main/LibraryIncludes.h)

While individual TIL headers can be included directly (e.g., `#include <til/point.h>`), the standard entry point is **[`src/inc/LibraryIncludes.h`](https://github.com/microsoft/terminal/blob/main/src/inc/LibraryIncludes.h)**.

This header serves as a centralized hub that:
- Pulls in the most commonly used TIL utilities
- Includes standard library headers required across the project (e.g., `<shared_mutex>`, `<vector>`)
- Defines platform-specific macros and compatibility shims

Every major component in Windows Terminal—including the UI layer (`src/cascadia/`), the renderer (`src/renderer/`), and the terminal host (`src/host/`)—begins by including [`LibraryIncludes.h`](https://github.com/microsoft/terminal/blob/main/LibraryIncludes.h), ensuring a consistent set of shared symbols and preventing include-order bugs.

## Shared Rendering Resources in the Atlas Engine

Beyond the TIL library, the term "shared components" also applies to rendering resources that multiple terminal instances can access. The **Atlas Engine** (`src/renderer/atlas/`) handles these shared graphics resources.

Specifically, the Atlas engine supports **shared fonts**—typefaces declared in the application package manifest via the `<windows.sharedFonts>` extension. These fonts are loaded through:

- **[`src/renderer/atlas/AtlasEngine.h`](https://github.com/microsoft/terminal/blob/main/src/renderer/atlas/AtlasEngine.h)** – Defines the interface for shared font queries
- **[`src/renderer/atlas/AtlasEngine.api.cpp`](https://github.com/microsoft/terminal/blob/main/src/renderer/atlas/AtlasEngine.api.cpp)** – Implements the shared font loading logic (see line 483 for the extension point comment)

This architecture allows multiple terminal windows to reference the same font data in memory rather than loading separate copies per instance.

## Practical Usage Examples

### Protecting State with `til::shared_mutex`

The following pattern from [`src/cascadia/WindowsTerminal/AppHost.cpp`](https://github.com/microsoft/terminal/blob/main/src/cascadia/WindowsTerminal/AppHost.cpp) demonstrates protecting a virtual desktop manager pointer:

```cpp
#include <til/mutex.h>
#include <VirtualDesktopManager.h>

// Static shared mutex protecting the desktop manager instance
static til::shared_mutex<winrt::com_ptr<IVirtualDesktopManager>> s_desktopManager;

void AppHost::_MoveToDesktop(const winrt::guid& desktopId)
{
    // Exclusive lock for writing
    auto guard = s_desktopManager.lock();
    if (!guard.get())
    {
        // Initialize if empty
        guard = winrt::try_create_instance<IVirtualDesktopManager>(
            CLSID_VirtualDesktopManager);
    }
    // Use guard-> to access the protected data
}

```

### Debouncing UI Updates with `til::ThrottledFunc`

This example from the same file shows throttling window visibility changes:

```cpp
#include <til/throttled_func.h>

class AppHost
{
public:
    AppHost()
    {
        // Throttle to 200ms intervals
        _showHideWindowThrottler = std::make_shared<til::ThrottledFunc<bool>>(
            [this](bool show) { _ShowHideWindow(show); },
            std::chrono::milliseconds{200});
    }

    void RequestShow()
    {
        // Safe to call frequently; actual execution is throttled
        _showHideWindowThrottler->operator()(true);
    }

private:
    std::shared_ptr<til::ThrottledFunc<bool>> _showHideWindowThrottler;
    void _ShowHideWindow(bool show) { /* implementation */ }
};

```

### Loading Shared Fonts in Atlas

When working with the Atlas renderer, you can check for and load shared fonts declared in the package manifest:

```cpp
#include "AtlasEngine.h"

void ConfigureAtlasFonts(AtlasEngine& engine)
{
    // Check if shared fonts are available (declared in package manifest)
    if (engine.HasSharedFonts())
    {
        // Load a specific shared font by name
        engine.LoadSharedFont(L"Cascadia Mono");
    }
    else
    {
        // Fall back to system font loading
        engine.LoadSystemFont(L"Consolas");
    }
}

```

## Summary

- **TIL (Template Internal Library)** is the canonical location for Windows Terminal's shared components, residing in **`src/inc/til/`**.
- **Header-only architecture** allows zero-overhead inlining of utilities like `til::point`, `til::color`, `til::small_vector`, and `til::static_map`.
- **Synchronization primitives** such as `til::shared_mutex` in [`src/inc/til/mutex.h`](https://github.com/microsoft/terminal/blob/main/src/inc/til/mutex.h) provide type-safe data protection.
- **Rate limiting** via `til::ThrottledFunc` in [`src/inc/til/throttled_func.h`](https://github.com/microsoft/terminal/blob/main/src/inc/til/throttled_func.h) debounces expensive UI operations.
- **Centralized access** is provided through **[`src/inc/LibraryIncludes.h`](https://github.com/microsoft/terminal/blob/main/src/inc/LibraryIncludes.h)**, which every major component includes to ensure consistent symbol availability.
- **Shared rendering resources** for fonts are handled by the Atlas engine in `src/renderer/atlas/`, supporting package-declared shared fonts via [`AtlasEngine.h`](https://github.com/microsoft/terminal/blob/main/AtlasEngine.h).

## Frequently Asked Questions

### What does TIL stand for in Windows Terminal?

**TIL stands for Template Internal Library.** It is a header-only C++ library located in `src/inc/til/` that provides low-level utilities—such as geometry types, custom containers, and synchronization primitives—used across all layers of Windows Terminal, from the UI down to the rendering engine.

### How do I include TIL components in my Windows Terminal contribution?

**Include [`src/inc/LibraryIncludes.h`](https://github.com/microsoft/terminal/blob/main/src/inc/LibraryIncludes.h) at the top of your source file.** This header acts as a centralized hub that pulls in the most commonly used TIL utilities (like `til::point`, `til::shared_mutex`, and `til::ThrottledFunc`). For specialized components, you can include specific headers directly (e.g., `#include <til/mutex.h>`).

### Are TIL components used outside of Windows Terminal?

**No, TIL is an internal library specific to the Windows Terminal project.** While the code is open source and available in the `microsoft/terminal` repository, it is designed as a private implementation detail for Terminal's architecture. The headers are not distributed as a standalone library for external consumption.

### Where are shared rendering fonts handled in Windows Terminal?

**Shared rendering fonts are handled by the Atlas Engine in `src/renderer/atlas/`.** Specifically, [`AtlasEngine.h`](https://github.com/microsoft/terminal/blob/main/AtlasEngine.h) and [`AtlasEngine.api.cpp`](https://github.com/microsoft/terminal/blob/main/AtlasEngine.api.cpp) implement logic for loading fonts declared via the `<windows.sharedFonts>` extension in the application package manifest. This allows multiple terminal instances to reference the same font data in memory rather than loading duplicate copies.