# miheel/tinycurs architecture

> Architecture diagram of the GitHub repository miheel/tinycurs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/miheel/tinycurs
- Repository: https://github.com/miheel/tinycurs

## Overview

This is a small terminal UI/runtime example: the main loop reads keyboard input, updates a movable on-screen figure, and redraws terminal content until Enter exits. The runtime also contains reusable pane and element rendering abstractions, terminal-mode management, resize signaling, and ANSI escape-code utilities. The README is empty, and the tree lacks the stick-figure and parse headers included by main, so those implementation details are not represented; links below are limited to shown source or header declarations.

Main entry points: [`src/main.cpp`](https://github.com/miheel/tinycurs/blob/master/src/main.cpp) (Interactive loop), [`src/keyboard.cpp`](https://github.com/miheel/tinycurs/blob/master/src/keyboard.cpp) (Keyboard input), [`src/pane.cpp`](https://github.com/miheel/tinycurs/blob/master/src/pane.cpp) (Pane buffer), [`src/curs.cpp`](https://github.com/miheel/tinycurs/blob/master/src/curs.cpp) (Screen manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_mainloop["Interactive loop<br/>[main.cpp]"]
end

subgraph group_input["Input"]
  node_keyinput["Keyboard input<br/>[keyboard.cpp]"]
  node_eventqueue["Input events<br/>[keyboard.hpp]"]
  node_resizeflag["Resize signal<br/>[signalHandler.cpp]"]
end

subgraph group_render["Rendering"]
  node_cursor["Screen manager<br/>[curs.cpp]"]
  node_pane["Pane buffer<br/>[pane.cpp]"]
  node_elements["UI elements<br/>[element.cpp]"]
  node_cells["Cells and geometry<br/>[util.hpp]"]
end

subgraph group_terminal["Terminal Runtime"]
  node_term["Terminal modes<br/>[termmode.cpp]"]
  node_esc["ANSI controls<br/>[esc_code.hpp]"]
end

node_user(("Terminal user"))
node_tty["Terminal"]

node_user -->|"provides input"| node_keyinput
node_keyinput -->|"reads bytes"| node_tty
node_keyinput -->|"queues events"| node_eventqueue
node_keyinput -->|"checks resize"| node_resizeflag
node_mainloop -->|"polls keys"| node_keyinput
node_mainloop -->|"updates screen"| node_cursor
node_mainloop -->|"sets terminal mode"| node_term
node_mainloop -->|"registers handler"| node_resizeflag
node_cursor -->|"draws pane"| node_pane
node_cursor -->|"manages terminal"| node_term
node_pane -->|"renders elements"| node_elements
node_elements -->|"writes buffer"| node_pane
node_pane -->|"stores cells"| node_cells
node_term -->|"configures terminal"| node_tty
node_mainloop -->|"writes display"| node_tty
node_esc -->|"emits controls"| node_tty

click node_mainloop "https://github.com/miheel/tinycurs/blob/master/src/main.cpp"
click node_keyinput "https://github.com/miheel/tinycurs/blob/master/src/keyboard.cpp"
click node_eventqueue "https://github.com/miheel/tinycurs/blob/master/include/keyboard.hpp"
click node_resizeflag "https://github.com/miheel/tinycurs/blob/master/src/signalHandler.cpp"
click node_cursor "https://github.com/miheel/tinycurs/blob/master/src/curs.cpp"
click node_pane "https://github.com/miheel/tinycurs/blob/master/src/pane.cpp"
click node_elements "https://github.com/miheel/tinycurs/blob/master/src/element.cpp"
click node_cells "https://github.com/miheel/tinycurs/blob/master/include/util.hpp"
click node_term "https://github.com/miheel/tinycurs/blob/master/src/termmode.cpp"
click node_esc "https://github.com/miheel/tinycurs/blob/master/include/esc_code.hpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mainloop,node_user toneBlue
class node_keyinput,node_eventqueue,node_resizeflag toneAmber
class node_cursor,node_pane,node_elements,node_cells toneMint
class node_term,node_esc toneRose
class node_tty toneIndigo
```

## Components

### Application

- [Interactive loop](https://github.com/miheel/tinycurs/blob/master/src/main.cpp): `src/main.cpp`

### Input

- [Keyboard input](https://github.com/miheel/tinycurs/blob/master/src/keyboard.cpp): `src/keyboard.cpp`
- [Input events](https://github.com/miheel/tinycurs/blob/master/include/keyboard.hpp): `include/keyboard.hpp`
- [Resize signal](https://github.com/miheel/tinycurs/blob/master/src/signalHandler.cpp): `src/signalHandler.cpp`

### Rendering

- [Screen manager](https://github.com/miheel/tinycurs/blob/master/src/curs.cpp): `src/curs.cpp`
- [Pane buffer](https://github.com/miheel/tinycurs/blob/master/src/pane.cpp): `src/pane.cpp`
- [UI elements](https://github.com/miheel/tinycurs/blob/master/src/element.cpp): `src/element.cpp`
- [Cells and geometry](https://github.com/miheel/tinycurs/blob/master/include/util.hpp): `include/util.hpp`

### Terminal Runtime

- [Terminal modes](https://github.com/miheel/tinycurs/blob/master/src/termmode.cpp): `src/termmode.cpp`
- [ANSI controls](https://github.com/miheel/tinycurs/blob/master/include/esc_code.hpp): `include/esc_code.hpp`

### Other components

- **Terminal user**
- **Terminal**

## Connections

- Terminal user → Keyboard input: provides input (evidence: `src/keyboard.cpp`)
- Keyboard input → Terminal: reads bytes (evidence: `src/keyboard.cpp`)
- Keyboard input → Input events: queues events (evidence: `src/keyboard.cpp`)
- Keyboard input → Resize signal: checks resize (evidence: `src/keyboard.cpp`)
- Interactive loop → Keyboard input: polls keys (evidence: `src/main.cpp`)
- Interactive loop → Screen manager: updates screen (evidence: `src/main.cpp`)
- Interactive loop → Terminal modes: sets terminal mode (evidence: `src/main.cpp`)
- Interactive loop → Resize signal: registers handler (evidence: `src/main.cpp`)
- Screen manager → Pane buffer: draws pane
- Screen manager → Terminal modes: manages terminal
- Pane buffer → UI elements: renders elements (evidence: `src/element.cpp`)
- UI elements → Pane buffer: writes buffer (evidence: `src/element.cpp`)
- Pane buffer → Cells and geometry: stores cells
- Terminal modes → Terminal: configures terminal (evidence: `src/termmode.cpp`)
- Interactive loop → Terminal: writes display (evidence: `src/main.cpp`)
- ANSI controls → Terminal: emits controls (evidence: `include/esc_code.hpp`)
