curd-editor 0.2.0

A tiny terminal text editor
# curd

A tiny terminal text editor written in Rust with `crossterm`, built step by step as a learning project.

Package name: `curd-editor` (`curd` is taken on crates.io). Command name: `curd`.

## Install

One command, no Rust needed. It downloads the latest release for your system.

Linux and macOS:

```sh
curl -fsSL https://raw.githubusercontent.com/vikram5258/crud-editor/main/install.sh | sh
```

Windows (PowerShell):

```powershell
irm https://raw.githubusercontent.com/vikram5258/crud-editor/main/install.ps1 | iex
```

Then run `curd some-file.txt`.

Other ways to get it:

- With Rust installed: `cargo install curd-editor`
- By hand: download a binary from the [releases page]https://github.com/vikram5258/crud-editor/releases

## Run

```sh
cargo run -- src/main.rs
```

## Keys

| Key | What it does |
|---|---|
| Typing, Enter, Tab | insert text, a new line, four spaces |
| Backspace / Delete | delete before / under the cursor (joins lines at a line edge) |
| Arrows, Home, End | move the cursor; the view scrolls in both directions |
| Ctrl+S | save |
| Ctrl+Q | quit (asks for a second press if there are unsaved changes) |

`curd new-file.txt` starts an empty document and creates the file on the first save. The bottom row is a status bar with the file name, a `[modified]` marker and the cursor position.

## Test

```sh
cargo test                # unit tests + end-to-end tests
cargo llvm-cov            # same, with a coverage report (cargo install cargo-llvm-cov)
```

- Unit tests sit next to the code in `src/document/tests.rs` and `src/editor/tests.rs`.
- End-to-end tests in `tests/e2e.rs` start the real `curd` in a pseudo-terminal, send keys and check the screen (Linux/macOS only).

Test files are left out of the published crate (see `include` in `Cargo.toml`).

CI runs the tests on every push and pull request and saves a JUnit test report and a coverage report as artifacts on the run. Pushing a `v*` tag runs the same checks first and only publishes a release (GitHub binaries, then crates.io) if they pass.

## Layout

- `src/main.rs` — starts everything up
- `src/terminal.rs` — raw mode, alternate screen, screen size (restored on drop)
- `src/document.rs` — the text (lines), editing it, opening and saving files
- `src/editor.rs` — main loop, keys, scrolling, drawing, status bar

## Progress

- [x] Step 1: raw mode, read keys, Ctrl+Q
- [x] Step 2: draw the screen with `~` and a welcome message
- [x] Step 3: open a file and show it (modular refactor)
- [x] Step 4: cursor movement and vertical scrolling
- [x] Step 5: typing and deleting
- [x] Step 6: save with Ctrl+S, unsaved-changes warning, new files
- [x] Status bar and horizontal scrolling
- [ ] Challenge: PageUp / PageDown
- [ ] Save as (name a file started without one)
- [ ] Search, syntax highlighting, undo
- [ ] LSP: diagnostics → hover → go to definition → completion