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
33 changes: 33 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ description = "A fast, lightweight, macOS-only terminal code editor."

[dependencies]
crossterm = "0.27"
libc = "0.2"
ropey = "1.6"
tree-sitter = "0.26.9"
tree-sitter-highlight = "0.26.9"
Expand All @@ -20,3 +21,5 @@ tree-sitter-ruby = "0.23.1"
tree-sitter-rust = "0.24.2"
tree-sitter-toml-ng = "0.7.0"
tree-sitter-typescript = "0.23.2"
unicode-casefold = "0.2.0"
unicode-normalization = "0.1.25"
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A small macOS-only terminal code editor written in Rust.

Cortex is currently in v0.3 development.
The current goal is one fast editing loop: open a file or directory, edit one buffer, save it, and quit cleanly.
The current goal is one fast editing loop: open files or a directory, edit and switch buffers, save, and quit cleanly.

## Platform

Expand Down Expand Up @@ -94,13 +94,16 @@ Existing files open with their current contents.
Missing files open as empty clean buffers attached to the requested path.
Saving can create the target file when its parent directory already exists.
Saving does not create missing parent directories.
Inside Cortex, `C-x C-f` accepts an existing or missing file path.
Enter a missing path, edit the empty buffer, and save to create the file.
Enter a directory path to browse it in the directory picker.
Directories open a picker that lists non-hidden entries.
The picker can open regular files.
The picker can expand and collapse directories.

## Current Scope

The current editor supports one buffer in the terminal alternate screen.
The current editor supports multiple file buffers in the terminal alternate screen.
It uses raw terminal mode while running and should restore the shell after exit.
It shows file text, cursor position, dirty state, save errors, and short status messages in a modeline.
It includes a directory picker, a slash command line, visual theme and modeline polish, and syntax highlighting for supported file types.
Expand All @@ -127,7 +130,8 @@ It includes a directory picker, a slash command line, visual theme and modeline
| `C-/` or `C-_` | Undo the last edit |
| `C-x u` | Undo the last edit |
| `Command-z` | Undo the last edit |
| `C-x C-f` | Open the file picker when the current buffer is clean |
| `C-x C-f` | Enter a path to find or create a file buffer |
| `C-x b` | Switch to an open buffer by path or unique file name |
| `C-x C-s` | Save the file |
| `C-x C-c` | Quit |
| `/` | Open the slash command line |
Expand All @@ -153,7 +157,7 @@ Press `n` or Escape to cancel.

Escape cancels the command line.
Unknown slash commands leave the editor open and show an error message.
`/open <path>` rejects directories and keeps the current buffer in place when it has unsaved changes.
`/open <path>` rejects directories and opens another buffer without discarding unsaved changes.

## Directory Picker Keybindings

Expand Down Expand Up @@ -185,7 +189,8 @@ See [docs/release.md](docs/release.md) for the release checklist.
## Known Limitations

Redo is available from the slash command line, but does not have a dedicated keybinding yet.
Cortex has one active buffer at a time.
Cortex shows one active buffer at a time.
The switch-buffer prompt requires an exact path or a unique file name and does not offer completion yet.
The directory picker can expand directories, but it is still a minimal picker.
The slash command `/open <path>` opens files only, not directories.
There are no splits, tabs, minibuffer, config, plugins, LSP, AI integration, or embedded terminal pane yet.
Expand Down
38 changes: 38 additions & 0 deletions docs/issues/30-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Issue 30 Plan

## Goal

Add multiple in-memory file buffers with Emacs-style find-file and switch-buffer commands.

`C-x C-f` must accept an editable path.
An existing path opens its file.
A missing path opens an empty buffer and saving creates the file when its parent directory exists.

## Implementation

1. Add an editor-level buffer list that owns each buffer and its view state.
2. Keep one active buffer and switch to an already-open path instead of duplicating it.
3. Generalize the existing bottom command input enough to support find-file and switch-buffer prompts.
4. Bind `C-x C-f` to find-file and `C-x b` to switch-buffer.
5. Keep dirty state per buffer, save only the active buffer, and protect dirty inactive buffers on quit.
6. Update the README for the new keys, file creation behavior, and remaining limitations.

## Acceptance Checks

- Opening another file retains the first buffer and its unsaved edits.
- Switching buffers restores the selected buffer and its view state.
- Saving affects only the active buffer.
- Quitting warns when any buffer is dirty.
- `C-x C-f` opens existing files and missing paths.
- Saving a missing path creates the file when its parent exists.
- Saving fails clearly when the parent directory is missing.
- Canceling a prompt leaves the active buffer unchanged.
- Directory startup and picker browsing still work.

## Verification

- Run focused buffer-list, app, keymap, and renderer tests.
- Run `cargo fmt --check`.
- Run `cargo clippy --all-targets --all-features -- -D warnings`.
- Run `cargo test`.
- Manually smoke test find-file, buffer switching, save creation, dirty quit, and terminal cleanup.
Loading
Loading