# The Sequencer Grid

The sequencer grid is the main view of Cagire (`F5`). This is the one you see when you open the application. On this view, you can see the step sequencer grid and edit each step using the code editor. You can optionally display the following widgets: 
- **an oscilloscope**: visualize the current audio output.
- **a spectrum analyzer**: 32 bands spectrum analyze (mostly cosmetic).
- **a step preview**: visualize the content of the hovered script.

You can press `o` to cycle through layouts. It will basically rotate the sequencer around. Use it to find the view that makes the more sense for you. 

## Navigation

Use arrow keys to move between steps. The grid wraps around at pattern boundaries. Press `:` to jump directly to a step by number. This keybinding is useful for very long patterns.

## Preview

Press `p` to enter preview mode. A read-only code editor opens showing the script of the step under the cursor. You can still navigate the grid while previewing. Press `Esc` to exit preview mode.

## Selection

Hold `Shift` while pressing arrow keys to select multiple steps. Press `Esc` to clear the selection.

## Editing Steps

- `Enter` — Open the script editor
- `t` — Toggle step active/inactive
- `r` — Rename a step
- `Del` — Delete selected steps

## Copy & Paste

- `Ctrl+C` — Copy selected steps
- `Ctrl+V` — Paste as copies
- `Ctrl+B` — Paste as linked steps
- `Ctrl+D` — Duplicate selection
- `Ctrl+H` — Harden links (convert to independent copies)

Linked steps share the same script as their source. When you edit the source, all linked steps update automatically. This is an extremely important and powerful feature. It allows you to create complex patterns with minimal effort. `Ctrl+H` converts linked steps back to independent copies.

## Pattern Controls

- `<` / `>` — Decrease / increase pattern length
- `[` / `]` — Decrease / increase pattern speed
- `L` — Set length directly
- `S` — Set speed directly

## Playback

- `Space` — Toggle play / stop
- `+` / `-` — Adjust tempo
- `T` — Set tempo directly
- `Ctrl+R` — Execute current step once (one-shot)

## Mute & Solo

- `m` — Mute current pattern
- `x` — Solo current pattern
- `Shift+m` — Clear all mutes
- `Shift+x` — Clear all solos

## Prelude

The prelude is a Forth script that runs before every step, useful for defining shared variables and setup code.

- `d` — Open the prelude editor
- `Shift+d` — Evaluate the prelude

## Tools

- `e` — Euclidean rhythm distribution
- `Tab` — Toggle sample browser panel

## Visual Indicators

- **Highlighted cell** — Currently playing step
- **Colored backgrounds** — Linked steps share colors by source
- **Arrow prefix** (`→05`) — Step is linked to step 05

## Keybindings

| Key | Action |
|-----|--------|
| `Arrows` | Navigate grid |
| `Shift+Arrows` | Extend selection |
| `:` | Jump to step |
| `Enter` | Open editor |
| `p` | Preview step |
| `t` | Toggle step active |
| `r` | Rename step |
| `Del` | Delete steps |
| `Ctrl+C` / `Ctrl+V` | Copy / Paste |
| `Ctrl+B` | Paste as links |
| `Ctrl+D` | Duplicate |
| `Ctrl+H` | Harden links |
| `<` / `>` | Pattern length |
| `[` / `]` | Pattern speed |
| `L` / `S` | Set length / speed |
| `Space` | Play / Stop |
| `+` / `-` | Tempo up / down |
| `T` | Set tempo |
| `Ctrl+R` | Execute step once |
| `m` / `x` | Mute / Solo |
| `d` | Prelude editor |
| `e` | Euclidean distribution |
| `o` | Cycle layout |
| `Tab` | Sample browser |
| `Ctrl+Z` | Undo |
| `Ctrl+Shift+Z` | Redo |
| `?` | Show keybindings |
