CodePad is a lightweight, minimalist, and feature-rich code editor built natively for macOS using Swift and SwiftUI. It combines the simplicity of a scratchpad with the power of a document-based code editor, featuring first-class Swift script execution and an integrated terminal.
- 📂 Multi-Format Document Support: Seamlessly open, edit, and save a wide range of code-related and text files, including
.swift,.json,.java,.cs,.csproj,.cpp,.dart,.env, and.gitignore. - ⚙️ Unified Editor Settings: Configure editor preferences globally, including:
- Indentation settings (tabs vs soft spaces, custom tab widths).
- Smart indentation and character auto-pairing.
- Curated syntax highlighting themes.
- ⌨️ Keyboard Shortcut Manager: View and re-assign keyboard shortcuts dynamically.
- ⚡ First-Class Swift Execution:
- Run
.swiftscripts directly inside the app withCmd + Ror the floating play button. - Asynchronous background execution (uses
/usr/bin/swift) prevents UI lockups. - Interactive play/stop states let you terminate infinite loops or long-running scripts cleanly.
- Sliding glassmorphic console drawer logs
stdoutandstderrin real-time.
- Run
- 🔢 Low-Key Line Numbers: A native, highly optimized
NSRulerViewgutter that renders line numbers cleanly in a small, faint monospaced font so you can focus on code.
| Command | Shortcut | Description |
|---|---|---|
| New Window | Cmd + N |
Open a new scratchpad or editor window |
| Open File | Cmd + O |
Open any supported code/text file |
| Save File | Cmd + S |
Save active file changes |
| Format Document | Ctrl + Shift + F |
Auto-format braces/brackets for C-family, JSON, & Swift |
| Run Script | Cmd + R |
Execute active .swift script / Open Console drawer |
| Settings | Cmd + , |
Open CodePad preferences window |
CodePadApp.swift: Bootstraps the SwiftUI application, configures multi-window groupings for document files (WindowGroup(for: URL.self)), and registers global menu shortcuts.ContentView.swift: Implements the main workspace, coordinates file open/save dialogs, manages theme states, and operates the async Swift script subprocess engine.LineNumberRuler.swift: Houses the native AppKitNSRulerViewsubclass (LineNumberRulerView) and theNSViewRepresentableview tree listener (LineNumberConfigurator) to inject line numbers into the editor's scroll view.FormatterService.swift: Auto-formats brackets and indentation for C-style syntaxes (Swift, C++, C#, Java) and JSON.ShortcutManager.swift&ShortcutsView.swift: Manage global shortcuts and render the shortcut re-assignment panel.
- macOS 14.0 or newer
- Xcode 15.0+ or Swift Toolchain 5.9+
To run CodePad in development mode:
swift runTo package a standalone, production-ready .app bundle inside a .dmg image, run:
bash scripts/build-dmg.shThe final image will be output to .build/CodePad-1.0.0.dmg.