# hinchley/texteditor architecture

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

- Interactive diagram: https://gitdiagram.com/hinchley/texteditor
- Repository: https://github.com/hinchley/texteditor

## Overview

This is a small, non-modal terminal text editor. The main workflow is: launch with paths, load them into a workspace of documents and views, read terminal input, dispatch commands or insert text, then render the updated views. Editing, file/workspace management, search, clipboard, syntax highlighting, and configurable keys and themes are distinct capabilities. Edges follow the sampled source index and excerpts or README; unsampled module internals and some feature-to-module links are therefore left unasserted.

Main entry points: [`src/app.c`](https://github.com/hinchley/texteditor/blob/main/src/app.c) (Application loop), [`src/editor.c`](https://github.com/hinchley/texteditor/blob/main/src/editor.c) (Editing views), [`src/command.c`](https://github.com/hinchley/texteditor/blob/main/src/command.c) (Command registry), [`src/screen.c`](https://github.com/hinchley/texteditor/blob/main/src/screen.c) (Screen rendering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and input"]
  node_main["Startup<br/>[main.c]"]
  node_app["Application loop<br/>[app.c]"]
  node_input["Key input<br/>[input.c]"]
  node_key["Key decoding<br/>[key.c]"]
  node_terminalio["Terminal control<br/>[terminal.c]"]
  node_keymap["Key bindings<br/>[keymap.c]"]
  node_config["Configuration<br/>[config.c]"]
end

subgraph group_editing["Documents and editing"]
  node_document["Document state<br/>[document.c]"]
  node_buffer["Text buffer<br/>[buffer.c]"]
  node_editor["Editing views<br/>[editor.c]"]
  node_undo["Undo history<br/>[undo.c]"]
  node_clipboard["System clipboard<br/>[clipboard.c]"]
end

subgraph group_commands["Commands and workspace"]
  node_commands["Command registry<br/>[command.c]"]
  node_workspace["Workspace and buffers<br/>[workspace.c]"]
  node_picker["Buffer picker<br/>[picker.c]"]
  node_help["Shortcut help<br/>[help.c]"]
  node_prompt["Interactive prompts<br/>[prompt.c]"]
  node_search["Search and replace<br/>[search.c]"]
end

subgraph group_display["Display and syntax"]
  node_screen["Screen rendering<br/>[screen.c]"]
  node_render["Text layout<br/>[render.c]"]
  node_highlight["Syntax highlighting<br/>[highlight.c]"]
  node_language["Language detection<br/>[lang.c]"]
  node_theme["Theme colors<br/>[theme.c]"]
  node_unicode["UTF-8 support<br/>[unicode.c]"]
end

node_user(("Editor user"))
node_terminal["Terminal"]

node_user -->|"opens files"| node_main
node_main -->|"starts"| node_app
node_app -->|"loads"| node_config
node_app -->|"initializes"| node_keymap
node_app -->|"opens paths"| node_workspace
node_app -->|"reads keys"| node_input
node_input -->|"reads bytes"| node_terminalio
node_input -->|"decodes"| node_key
node_app -->|"looks up keys"| node_keymap
node_app -->|"dispatches"| node_commands
node_app -->|"renders workspace"| node_screen
node_app -->|"controls session"| node_terminalio
node_keymap -->|"binds keys"| node_key
node_keymap -->|"maps commands"| node_commands
node_config -->|"configures"| node_keymap
node_commands -->|"manages buffers"| node_workspace
node_commands -->|"invokes"| node_picker
node_commands -->|"invokes"| node_help
node_commands -->|"uses prompts"| node_prompt
node_commands -->|"invokes"| node_search
node_workspace -->|"creates views"| node_editor
node_document -->|"holds text"| node_buffer
node_document -->|"tracks history"| node_undo
node_document -->|"records language"| node_language
node_editor -->|"edits document"| node_document
node_editor -->|"copies and pastes"| node_clipboard
node_editor -->|"uses layout"| node_render
node_editor -->|"handles codepoints"| node_unicode
node_editor -->|"undoes edits"| node_undo
node_search -->|"updates matches"| node_editor
node_screen -->|"draws text"| node_render
node_screen -->|"requests colors"| node_highlight
node_screen -->|"writes frames"| node_terminalio
node_screen -->|"gets palette"| node_theme
node_highlight -->|"maps captures"| node_theme
node_highlight -->|"uses grammar"| node_language
node_render -->|"measures glyphs"| node_unicode
node_terminal -->|"provides keystrokes"| node_input
node_terminalio -->|"draws interface"| node_terminal

click node_main "https://github.com/hinchley/texteditor/blob/main/src/main.c"
click node_app "https://github.com/hinchley/texteditor/blob/main/src/app.c"
click node_input "https://github.com/hinchley/texteditor/blob/main/src/input.c"
click node_key "https://github.com/hinchley/texteditor/blob/main/src/key.c"
click node_terminalio "https://github.com/hinchley/texteditor/blob/main/src/terminal.c"
click node_keymap "https://github.com/hinchley/texteditor/blob/main/src/keymap.c"
click node_config "https://github.com/hinchley/texteditor/blob/main/src/config.c"
click node_commands "https://github.com/hinchley/texteditor/blob/main/src/command.c"
click node_workspace "https://github.com/hinchley/texteditor/blob/main/src/workspace.c"
click node_picker "https://github.com/hinchley/texteditor/blob/main/src/picker.c"
click node_help "https://github.com/hinchley/texteditor/blob/main/src/help.c"
click node_prompt "https://github.com/hinchley/texteditor/blob/main/src/prompt.c"
click node_search "https://github.com/hinchley/texteditor/blob/main/src/search.c"
click node_document "https://github.com/hinchley/texteditor/blob/main/src/document.c"
click node_buffer "https://github.com/hinchley/texteditor/blob/main/src/buffer.c"
click node_editor "https://github.com/hinchley/texteditor/blob/main/src/editor.c"
click node_undo "https://github.com/hinchley/texteditor/blob/main/src/undo.c"
click node_clipboard "https://github.com/hinchley/texteditor/blob/main/src/clipboard.c"
click node_screen "https://github.com/hinchley/texteditor/blob/main/src/screen.c"
click node_render "https://github.com/hinchley/texteditor/blob/main/src/render.c"
click node_highlight "https://github.com/hinchley/texteditor/blob/main/src/highlight.c"
click node_language "https://github.com/hinchley/texteditor/blob/main/src/lang.c"
click node_theme "https://github.com/hinchley/texteditor/blob/main/src/theme.c"
click node_unicode "https://github.com/hinchley/texteditor/blob/main/src/unicode.c"

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_main,node_app,node_input,node_key,node_terminalio,node_keymap,node_config,node_user toneBlue
class node_document,node_buffer,node_editor,node_undo,node_clipboard toneAmber
class node_commands,node_workspace,node_picker,node_help,node_prompt,node_search toneMint
class node_screen,node_render,node_highlight,node_language,node_theme,node_unicode toneRose
class node_terminal toneIndigo
```

## Components

### Runtime and input

- [Startup](https://github.com/hinchley/texteditor/blob/main/src/main.c): `src/main.c`
- [Application loop](https://github.com/hinchley/texteditor/blob/main/src/app.c): `src/app.c`
- [Key input](https://github.com/hinchley/texteditor/blob/main/src/input.c): `src/input.c`
- [Key decoding](https://github.com/hinchley/texteditor/blob/main/src/key.c): `src/key.c`
- [Terminal control](https://github.com/hinchley/texteditor/blob/main/src/terminal.c): `src/terminal.c`
- [Key bindings](https://github.com/hinchley/texteditor/blob/main/src/keymap.c): `src/keymap.c`
- [Configuration](https://github.com/hinchley/texteditor/blob/main/src/config.c): `src/config.c`

### Documents and editing

- [Document state](https://github.com/hinchley/texteditor/blob/main/src/document.c): `src/document.c`
- [Text buffer](https://github.com/hinchley/texteditor/blob/main/src/buffer.c): `src/buffer.c`
- [Editing views](https://github.com/hinchley/texteditor/blob/main/src/editor.c): `src/editor.c`
- [Undo history](https://github.com/hinchley/texteditor/blob/main/src/undo.c): `src/undo.c`
- [System clipboard](https://github.com/hinchley/texteditor/blob/main/src/clipboard.c): `src/clipboard.c`

### Commands and workspace

- [Command registry](https://github.com/hinchley/texteditor/blob/main/src/command.c): `src/command.c`
- [Workspace and buffers](https://github.com/hinchley/texteditor/blob/main/src/workspace.c): `src/workspace.c`
- [Buffer picker](https://github.com/hinchley/texteditor/blob/main/src/picker.c): `src/picker.c`
- [Shortcut help](https://github.com/hinchley/texteditor/blob/main/src/help.c): `src/help.c`
- [Interactive prompts](https://github.com/hinchley/texteditor/blob/main/src/prompt.c): `src/prompt.c`
- [Search and replace](https://github.com/hinchley/texteditor/blob/main/src/search.c): `src/search.c`

### Display and syntax

- [Screen rendering](https://github.com/hinchley/texteditor/blob/main/src/screen.c): `src/screen.c`
- [Text layout](https://github.com/hinchley/texteditor/blob/main/src/render.c): `src/render.c`
- [Syntax highlighting](https://github.com/hinchley/texteditor/blob/main/src/highlight.c): `src/highlight.c`
- [Language detection](https://github.com/hinchley/texteditor/blob/main/src/lang.c): `src/lang.c`
- [Theme colors](https://github.com/hinchley/texteditor/blob/main/src/theme.c): `src/theme.c`
- [UTF-8 support](https://github.com/hinchley/texteditor/blob/main/src/unicode.c): `src/unicode.c`

### Other components

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

## Connections

- Editor user → Startup: opens files
- Startup → Application loop: starts (evidence: `src/main.c`)
- Application loop → Configuration: loads (evidence: `src/app.c`)
- Application loop → Key bindings: initializes (evidence: `src/app.c`)
- Application loop → Workspace and buffers: opens paths (evidence: `src/app.c`)
- Application loop → Key input: reads keys (evidence: `src/app.c`)
- Key input → Terminal control: reads bytes (evidence: `src/input.c`)
- Key input → Key decoding: decodes (evidence: `src/input.c`)
- Application loop → Key bindings: looks up keys (evidence: `src/app.c`)
- Application loop → Command registry: dispatches (evidence: `src/app.c`)
- Application loop → Screen rendering: renders workspace (evidence: `src/app.c`)
- Application loop → Terminal control: controls session (evidence: `src/app.c`)
- Key bindings → Key decoding: binds keys
- Key bindings → Command registry: maps commands
- Configuration → Key bindings: configures
- Command registry → Workspace and buffers: manages buffers
- Command registry → Buffer picker: invokes (evidence: `src/command.c`)
- Command registry → Shortcut help: invokes (evidence: `src/command.c`)
- Command registry → Interactive prompts: uses prompts (evidence: `src/command.c`)
- Command registry → Search and replace: invokes (evidence: `src/command.c`)
- Workspace and buffers → Editing views: creates views
- Document state → Text buffer: holds text
- Document state → Undo history: tracks history
- Document state → Language detection: records language
- Editing views → Document state: edits document
- Editing views → System clipboard: copies and pastes (evidence: `src/editor.c`)
- Editing views → Text layout: uses layout (evidence: `src/editor.c`)
- Editing views → UTF-8 support: handles codepoints (evidence: `src/editor.c`)
- Editing views → Undo history: undoes edits
- Search and replace → Editing views: updates matches
- Screen rendering → Text layout: draws text (evidence: `src/screen.c`)
- Screen rendering → Syntax highlighting: requests colors (evidence: `src/screen.c`)
- Screen rendering → Terminal control: writes frames (evidence: `src/screen.c`)
- Screen rendering → Theme colors: gets palette (evidence: `src/screen.c`)
- Syntax highlighting → Theme colors: maps captures (evidence: `src/highlight.c`)
- Syntax highlighting → Language detection: uses grammar
- Text layout → UTF-8 support: measures glyphs (evidence: `src/render.c`)
- Terminal → Key input: provides keystrokes (evidence: `src/input.c`)
- Terminal control → Terminal: draws interface
