Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ There is no retry loop for ordinary editor commands.
Stable file reads retry up to three times, and temporary-file creation tries up to 128 random names.

The main UI path is synchronous.
The only runtime background work is the terminal-disconnect monitor thread.
The only persistent runtime background work is the terminal-disconnect monitor thread.
Explicit clipboard commands spawn pbcopy or pbpaste with piped input/output and an enforced UTF-8 locale.
Nonblocking pipe I/O and child exit polling share a two-second deadline; failures kill and reap the child.
Transfers are limited to 16 MiB, and copy checks the selected Rope byte length before materializing text.
Clipboard paste uses the same application text path as terminal paste, including single-line prompt conversion.
Tree-sitter work is bounded by visible ranges, read-ahead windows, per-line character limits, and a small checkpoint cache for Rust and Markdown.
The retained renderer rejects terminal sizes above 1,000,000 cells, which turns an uncontrolled allocation into a recoverable render error followed by terminal cleanup.

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ It includes shared prompts for commands and buffer navigation, a directory picke
| `C-k` | Cut to the end of the line |
| `C-y` | Yank the newest cut |
| `M-y` | Replace the last yank with an older cut |
| `M-w` | Copy the active region to the macOS clipboard |
| `C-c C-v` | Paste the macOS clipboard into the buffer or active prompt |
| `C-/` or `C-_` | Undo the last edit |
| `C-x u` | Undo the last edit |
| `Command-z` | Undo the last edit |
Expand Down Expand Up @@ -186,6 +188,8 @@ Escape cancels the prompt; unknown names and invalid arguments report an error w
| `delete-char`, `delete-backward-char` | Delete one grapheme | |
| `set-mark`, `kill-region`, `kill-line`, `yank` | Select, cut, or insert cut text | |
| `yank-pop` | Replace the last yank with an older cut | |
| `copy-region` | Copy the region without deleting it | `clipboard-copy` |
| `clipboard-paste` | Insert literal clipboard text | |
| `self-insert-command <character>` | Insert one printable character | |
| `execute-extended-command` | Open the command prompt | |
| `help`, `help <command>` | List commands or describe one | `/help`, `/commands` |
Expand Down Expand Up @@ -216,6 +220,12 @@ Movement, edits, save, buffer changes, and undo/redo end yank-pop, so it cannot
Each kill, yank, and yank-pop is one undo step.
The ring is local to this process and does not read or write the system clipboard.

Clipboard commands run only when requested, using macOS `pbcopy` and `pbpaste`.
Copy keeps the region and buffer unchanged; clipboard paste is one literal undo step and clears the selection.
In editable prompts, `C-c C-v` flattens line breaks and tabs without submitting the prompt.
Clipboard commands time out after two seconds and reject transfers above 16 MiB or invalid UTF-8, leaving buffer text intact.
Clipboard errors in a prompt remain visible until the next prompt key; the entered text is preserved.

Contiguous typing and same-direction deletion undo as a group.
A pause of at least 750 ms, movement, save, prompt entry, buffer switch, or deliberate edit starts a new group.
Paste, indentation, kills, and yanks remain separate undo steps.
Expand Down
23 changes: 23 additions & 0 deletions docs/issues/167-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Issue 167: Explicit macOS clipboard commands

## Task and acceptance

Add copy-region, with clipboard-copy as an alias, bound to M-w.
Copy the active region without changing text, mark, history, or the local kill ring.
An empty region produces a clear no-op status and does not invoke a clipboard program.
Add clipboard-paste, bound to C-c C-v, inserting literal text as one undo edit with the same Unicode and mark rules as terminal paste.
The clipboard shortcut also works inside editable prompts, applying the existing single-line conversion without submitting them.
Clipboard commands cannot answer a dirty-quit confirmation.

Use a small adapter with fixed /usr/bin/pbcopy and /usr/bin/pbpaste programs.
Access the clipboard only when an explicit copy or paste command executes.
Bound process I/O and exit waiting by a two-second deadline, avoid blocking pipe reads or writes, and reap failed or timed-out children.
Limit one clipboard transfer to 16 MiB; report oversized data or invalid UTF-8 without editing the buffer.
Do not include clipboard contents in failure messages.

## Checks

Use controlled executable adapters in automated tests, never the real clipboard.
Test copy/no-region behavior, named aliases and keybindings, literal paste and undo, prompt conversion, mark and kill-ring preservation, process failures, invalid UTF-8, oversized data, and timeout cleanup.
Run formatting, strict Clippy, the full suite, release build, independent review, and a terminal copy/paste/edit/undo/save/quit session with shell restoration.
If manual testing changes the system clipboard, save and restore its prior bytes without displaying them.
6 changes: 3 additions & 3 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,18 @@ Shipped:
- Find file.
- Switch buffer.
- Command registry and `M-x` with prefix completion.
- Kill ring and yank-pop.

Planned:
- Incremental search.
- Kill ring and yank-pop.

Tracking issues:
- [closed] [#27 Add undo and redo](https://github.com/owainlewis/cortex/issues/27)
- [closed] [#28 Add minibuffer foundation](https://github.com/owainlewis/cortex/issues/28)
- [open] [#29 Add incremental search](https://github.com/owainlewis/cortex/issues/29)
- [closed] [#30 Add multiple buffers, find-file, and switch-buffer](https://github.com/owainlewis/cortex/issues/30)
- [closed] [#46 Add command registry and M-x](https://github.com/owainlewis/cortex/issues/46)
- [open] [#47 Replace cut slot with a real kill ring](https://github.com/owainlewis/cortex/issues/47)
- [closed] [#47 Replace cut slot with a real kill ring](https://github.com/owainlewis/cortex/issues/47)

Release notes should focus on editing safety, search, and buffer navigation.

Expand All @@ -141,7 +141,7 @@ Delivery order:
- [closed] [#164 Add typing and region indentation](https://github.com/owainlewis/cortex/issues/164)
- [closed] [#165 Handle literal terminal paste](https://github.com/owainlewis/cortex/issues/165)
- [closed] [#166 Group typing and deletion undo steps](https://github.com/owainlewis/cortex/issues/166)
- [open] [#47 Add kill ring and yank-pop](https://github.com/owainlewis/cortex/issues/47)
- [closed] [#47 Add kill ring and yank-pop](https://github.com/owainlewis/cortex/issues/47)
- [open] [#167 Add explicit macOS clipboard commands](https://github.com/owainlewis/cortex/issues/167)
- [open] [#168 Add word, page, and line navigation](https://github.com/owainlewis/cortex/issues/168)
- [open] [#29 Add incremental search](https://github.com/owainlewis/cortex/issues/29)
Expand Down
Loading