# kyx0r/nextvi architecture

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

- Interactive diagram: https://gitdiagram.com/kyx0r/nextvi
- Repository: https://github.com/kyx0r/nextvi

## Overview

Nextvi is a modal terminal text editor. The principal workflow starts with a user invoking vi on files, then uses the vi command loop for editing and ex commands, stores text and edit history in buffers, and renders the result through the terminal. The graph also preserves documented highlighting, macros, keymaps, and bidirectional UTF-8 support. The source index establishes vi.c’s dependencies; several finer-grained links rely on excerpts or README descriptions because much of the implementation was not sampled.

Main entry points: [`vi.c`](https://github.com/kyx0r/nextvi/blob/master/vi.c) (Vi command loop), [`ren.c`](https://github.com/kyx0r/nextvi/blob/master/ren.c) (Screen and syntax rendering), [`ex.c`](https://github.com/kyx0r/nextvi/blob/master/ex.c) (Ex commands), [`led.c`](https://github.com/kyx0r/nextvi/blob/master/led.c) (Prompt and line rendering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Editor interaction"]
  node_vi["Vi command loop<br/>[vi.c]"]
  node_ex["Ex commands<br/>[ex.c]"]
  node_keymaps["Keymaps<br/>[kmap.h]"]
end

subgraph group_editing["Editing and files"]
  node_config["Options and highlighting rules<br/>[conf.c]"]
  node_buffers["Text buffers and history<br/>[lbuf.c]"]
  node_regex["Regular expressions<br/>[regex.c]"]
end

subgraph group_display["Display and text"]
  node_terminal_io["Terminal input and output<br/>[term.c]"]
  node_line_editor["Prompt and line rendering<br/>[led.c]"]
  node_render["Screen and syntax rendering<br/>[ren.c]"]
end

subgraph group_support["Language support"]
  node_unicode["Unicode handling<br/>[uc.c]"]
  node_shared["Shared editor definitions<br/>[vi.h]"]
end

node_user(("User"))
node_terminal["Terminal"]
node_filesystem[("Files")]

node_user -->|"invokes"| node_vi
node_vi -->|"reads and writes"| node_terminal_io
node_terminal_io -.->|"communicates"| node_terminal
node_vi -->|"dispatches commands"| node_ex
node_vi -->|"edits text"| node_buffers
node_ex -->|"reads and updates"| node_buffers
node_ex -->|"reads and writes"| node_filesystem
node_vi -->|"uses mappings"| node_keymaps
node_vi -->|"uses options"| node_config
node_vi -->|"prompts"| node_line_editor
node_vi -->|"renders screen"| node_render
node_line_editor -->|"renders text"| node_render
node_line_editor -->|"reads input"| node_terminal_io
node_render -.->|"matches highlight patterns"| node_regex
node_render -->|"uses highlight rules"| node_config
node_render -.->|"measures and shapes text"| node_unicode
node_vi -.->|"handles UTF-8"| node_unicode
node_shared -->|"declares buffer API"| node_buffers

click node_vi "https://github.com/kyx0r/nextvi/blob/master/vi.c"
click node_ex "https://github.com/kyx0r/nextvi/blob/master/ex.c"
click node_keymaps "https://github.com/kyx0r/nextvi/blob/master/kmap.h"
click node_config "https://github.com/kyx0r/nextvi/blob/master/conf.c"
click node_buffers "https://github.com/kyx0r/nextvi/blob/master/lbuf.c"
click node_regex "https://github.com/kyx0r/nextvi/blob/master/regex.c"
click node_terminal_io "https://github.com/kyx0r/nextvi/blob/master/term.c"
click node_line_editor "https://github.com/kyx0r/nextvi/blob/master/led.c"
click node_render "https://github.com/kyx0r/nextvi/blob/master/ren.c"
click node_unicode "https://github.com/kyx0r/nextvi/blob/master/uc.c"
click node_shared "https://github.com/kyx0r/nextvi/blob/master/vi.h"

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_vi,node_ex,node_keymaps,node_user toneBlue
class node_config,node_buffers,node_regex,node_filesystem toneAmber
class node_terminal_io,node_line_editor,node_render toneMint
class node_unicode,node_shared toneRose
class node_terminal toneIndigo
```

## Components

### Editor interaction

- [Vi command loop](https://github.com/kyx0r/nextvi/blob/master/vi.c): `vi.c`
- [Ex commands](https://github.com/kyx0r/nextvi/blob/master/ex.c): `ex.c`
- [Keymaps](https://github.com/kyx0r/nextvi/blob/master/kmap.h): `kmap.h`

### Editing and files

- [Options and highlighting rules](https://github.com/kyx0r/nextvi/blob/master/conf.c): `conf.c`
- [Text buffers and history](https://github.com/kyx0r/nextvi/blob/master/lbuf.c): `lbuf.c`
- [Regular expressions](https://github.com/kyx0r/nextvi/blob/master/regex.c): `regex.c`

### Display and text

- [Terminal input and output](https://github.com/kyx0r/nextvi/blob/master/term.c): `term.c`
- [Prompt and line rendering](https://github.com/kyx0r/nextvi/blob/master/led.c): `led.c`
- [Screen and syntax rendering](https://github.com/kyx0r/nextvi/blob/master/ren.c): `ren.c`

### Language support

- [Unicode handling](https://github.com/kyx0r/nextvi/blob/master/uc.c): `uc.c`
- [Shared editor definitions](https://github.com/kyx0r/nextvi/blob/master/vi.h): `vi.h`

### Other components

- **User**
- **Terminal**
- **Files**

## Connections

- User → Vi command loop: invokes (evidence: `README`)
- Vi command loop → Terminal input and output: reads and writes (evidence: `vi.c`)
- Terminal input and output → Terminal: communicates
- Vi command loop → Ex commands: dispatches commands (evidence: `vi.c`)
- Vi command loop → Text buffers and history: edits text (evidence: `vi.c`)
- Ex commands → Text buffers and history: reads and updates (evidence: `ex.c`)
- Ex commands → Files: reads and writes (evidence: `ex.c`)
- Vi command loop → Keymaps: uses mappings
- Vi command loop → Options and highlighting rules: uses options (evidence: `vi.c`)
- Vi command loop → Prompt and line rendering: prompts (evidence: `vi.c`)
- Vi command loop → Screen and syntax rendering: renders screen (evidence: `vi.c`)
- Prompt and line rendering → Screen and syntax rendering: renders text (evidence: `led.c`)
- Prompt and line rendering → Terminal input and output: reads input (evidence: `led.c`)
- Screen and syntax rendering → Regular expressions: matches highlight patterns (evidence: `README`)
- Screen and syntax rendering → Options and highlighting rules: uses highlight rules (evidence: `conf.c`)
- Screen and syntax rendering → Unicode handling: measures and shapes text (evidence: `README`)
- Vi command loop → Unicode handling: handles UTF-8 (evidence: `README`)
- Shared editor definitions → Text buffers and history: declares buffer API (evidence: `vi.h`)
