A lightweight, fast terminal text editor written in C with syntax highlighting, undo/redo, find & replace, and line numbers.
- Syntax Highlighting - Support for C, Python, JavaScript, and plain text
- Undo/Redo - Full command history with Ctrl-Z and Ctrl-Y
- Find & Replace - Search with Ctrl-F and navigate with Ctrl-N
- Line Numbers - Toggle with Ctrl-L
- Multiple Themes - Dark, Light, Solarized, and Dracula themes (Ctrl-T to cycle)
- Efficient Rendering - Fast screen updates with minimal I/O
- Terminal Native - Works in any terminal, no external dependencies
- GCC or Clang
- POSIX-compliant system (Linux, macOS, BSD)
- Standard C library
bash build.sh releaseOr for debug build:
bash build.sh debug./bin/embedText [filename]| Shortcut | Action |
|---|---|
Ctrl-S |
Save file |
Ctrl-Q |
Quit (with unsaved check) |
Ctrl-F |
Find text |
Ctrl-N |
Find next occurrence |
Ctrl-Z |
Undo |
Ctrl-Y |
Redo |
Ctrl-T |
Cycle themes |
Ctrl-L |
Toggle line numbers |
Ctrl-H |
Backspace |
| Arrow keys | Move cursor |
Page Up/Down |
Scroll page |
Home/End |
Start/end of line |
Delete |
Delete character at cursor |
embedText/
├── include/ # Header files
│ ├── editor.h # Main editor state
│ ├── doc.h # Document management
│ ├── term.h # Terminal control
│ ├── syntax.h # Syntax highlighting
│ ├── theme.h # Color themes
│ ├── abuf.h # Output buffer
│ ├── history.h # Undo/redo history
│ └── search.h # Find functionality
├── src/ # Implementation files
│ ├── main.c # Entry point
│ ├── editor.c # Core editor loop
│ ├── doc.c # Document operations
│ ├── term.c # Terminal I/O
│ ├── syntax.c # Language tokenization
│ ├── theme.c # Theme definitions
│ ├── abuf.c # Buffer implementation
│ ├── history.c # Command history
│ └── search.c # Search algorithm
├── bin/ # Compiled binaries
├── build.sh # Build script
├── .gitignore # Git ignore rules
└── README.md # This file
- Rows are dynamically allocated and stored in a
Docstruct - Each row holds a character array and metadata
- Efficient insertions/deletions with minimal copying
- Tokenization - Break lines into syntax tokens
- Coloring - Apply theme colors based on token type
- Scrolling - Calculate visible viewport based on cursor
- Buffering - Accumulate escape sequences in memory
- Flushing - Write entire screen in one syscall
- Fixed-size circular buffer (100 commands by default)
- Each command stores position, type, and affected content
- Undo/redo traverses history pointer bidirectionally
- O(1) rendering - Constant time screen updates
- O(n) search - Linear search with early termination
- O(1) history - Constant time undo/redo
- Minimal allocations - Most data in fixed-size buffers
- Single-file editing (one file per session)
- Basic syntax highlighting (no regex-based rules)
- Find/replace is find-only (no replace operation yet)
- No multi-byte Unicode support (ASCII/Latin-1 only)
- No plugins or configuration file support
- Multiple file tabs
- Search and replace with regex
- Configuration file support
- Macro recording
- Code folding
- Clipboard integration
- Window splitting
MIT License - See LICENSE file for details
Created as a modern C programming exercise combining systems programming, data structures, and terminal UI techniques.