# Architecture

Source: https://libtmux.org/en/java/latest/topics/architecture/

> Locate operations, distinguish snapshots from live commands, and find their implementation.

A server handle selects a tmux server. Object IDs select sessions, windows, and
panes within it. For the object hierarchy and stable IDs, start with [Server,
session, window, pane](https://libtmux.org/en/java/latest/concepts/server-session-window-pane/).

<a id="where-behavior-lives-on-the-object-or-through-the-server"></a>

## Calling operations

Session, window, and pane handles carry their ID and server context. Call an
operation on the object you want to change. The examples below send input and
kill that pane.

```java
pane.sendLine("echo hi");
pane.kill();
```

<a id="a-generated-data-table-under-a-hand-written-surface"></a>

## Reading tmux fields

Object IDs become tmux targets (`-t`). Format variables (`#{...}`) provide
the state returned by tmux.

Typed field classes such as [`Pane_`](<https://libtmux.org/en/java/latest/reference/io-github-libtmux-pane_-pane_/>) and [`Session_`](<https://libtmux.org/en/java/latest/reference/io-github-libtmux-session_-session_/>) support the query layer.
Accessors use `Optional<T>` for fields that may be unavailable on the running
tmux version. [Filtering and queries](https://libtmux.org/en/java/latest/concepts/queries/) explains how to
select and query those fields.

<a id="module-layout-by-port"></a>

## Source layout

[`libtmux/src/main/java/io/github/libtmux/`](<https://github.com/libtmux/libtmux-java/tree/c067fced0dfd19bd6dd3d260e9d4c336becdb063/libtmux/src/main/java/io/github/libtmux>) holds the [`Server`](<https://libtmux.org/en/java/latest/reference/io-github-libtmux-server-server/>), [`Session`](<https://libtmux.org/en/java/latest/reference/io-github-libtmux-session-session/>),
[`Window`](<https://libtmux.org/en/java/latest/reference/io-github-libtmux-window-window/>), and [`Pane`](<https://libtmux.org/en/java/latest/reference/io-github-libtmux-pane-pane/>) classes. Their `options()` and `hooks()` accessors
return [`Options`](<https://libtmux.org/en/java/latest/reference/io-github-libtmux-options-options/>) and [`Hooks`](<https://libtmux.org/en/java/latest/reference/io-github-libtmux-hooks-hooks/>) views scoped to the object.
[`Session_`](<https://libtmux.org/en/java/latest/reference/io-github-libtmux-session_-session_/>), [`Window_`](<https://libtmux.org/en/java/latest/reference/io-github-libtmux-window_-window_/>), and [`Pane_`](<https://libtmux.org/en/java/latest/reference/io-github-libtmux-pane_-pane_/>) are typed-field classes for the query layer.
