Skip to main content

A simple CUI editor for Caffee.

Project description

☕ CAFFEE Terminal Text Editor

A lightweight, modern, and extensible text editor that runs in your terminal.

【Celebration】 PyPI total downloads exceeded 5K! 🎉

PyPI Version Python Version License PyPI Downloads


CAFFEE is a terminal text editor written in Python, designed for a simple, extensible, and efficient editing experience with modern IDE-like features.

Table of Contents


💡 Features

🎨 Modern UI & Navigation

  • Multi-Tab Editing - Handle multiple files simultaneously with a visual tab system (Ctrl+S, Ctrl+L, Ctrl+X).
  • Breadcrumb Bar - Real-time display of file paths and code symbols (functions/classes) for better context.
  • Vim Mode - Optional modal editing support for high-efficiency navigation and text manipulation.
  • Relative Line Numbers (Ctrl+U) - Toggle relative line numbers to speed up navigation.
  • Nerd Font Integration - High-quality icons with an automated font installation helper.
  • Smart Horizontal Scrolling - Nano-style smooth scrolling for long lines.

🚀 Productivity & Editing

  • Interactive Search & Replace (Ctrl+W) - VSCode-style interface for finding and replacing text, including "Replace All" (Ctrl+A).
  • System Clipboard Sync - Seamless copy-paste synchronization across Windows, macOS, and Linux.
  • Predictive Text - Intelligent auto-completion suggestions powered by buffer content.
  • Git Integration - View branch names, file status markers (~: modified, +: new), and unified diffs (Ctrl+D).
  • Enhanced File Explorer (Ctrl+F) - Browse and manage files with sorting, wildcard search, and full-screen mode.
  • Integrated Terminal (Ctrl+N) - Execute shell commands directly from the editor.
  • Command Mode (Ctrl+P) - Execute powerful commands like :open, :saveas, :set, and :delcomm.

⚙️ Extensibility & Advanced Support

  • Automated Build & Run (Ctrl+B) - Optimized templates and build commands for 20+ programming languages.
  • Advanced Syntax Highlighting - Support for Python, JS/TS, C/C++, Go, Rust, Java, Ruby, Swift, and more.
  • Plugin System - Extend functionality with custom Python scripts.
  • Atomic File Saving - Safe file operations with automatic backup creation.
  • Undo/Redo - Comprehensive history management with configurable limits.

💻 Installation

Requirements

  • Python 3.8+
  • Unix-like terminal (Linux, macOS, ChromeOS Linux shell)
  • curses library (usually included with Python)

Quick Start

# Install from PyPI
pip install caffee

# Run the editor
caffee

# Or open a specific file
caffee /path/to/file.py

Upgrade

pip install caffee --upgrade

Optional: Speed Up with Nuitka

For significantly faster startup, compile with Nuitka. See the Nuitka Compilation Guide for detailed instructions.


⌨️ Keybindings

File Operations

Key Action
Ctrl+O Save current file
Ctrl+X Close current tab / Exit
Ctrl+S New tab / Start screen
Ctrl+L Switch to next tab

Editing

Key Action
Ctrl+Z Undo
Ctrl+R Redo
Ctrl+K Cut (line or selection)
Ctrl+V Paste (System Clipboard Sync)
Ctrl+C Copy selection
Ctrl+U Toggle relative line numbers
Ctrl+Y Delete current line
Ctrl+/ Toggle comment

Navigation & Search

Key Action
Ctrl+W Search (with regex support)
Ctrl+G Go to line number
Ctrl+E Move to end of line
Ctrl+A Select all / Clear selection
Ctrl+6 Set/Unset mark (selection start)

Panels & Tools

Key Action
Ctrl+F Toggle file explorer
Ctrl+N Toggle integrated terminal
Ctrl+U Toggle relative line numbers
Ctrl+T Insert template
Ctrl+B Build/Run current file
Ctrl+D Show Git diff for the current file
Ctrl+P Enter Command Mode
Esc Return to editor from panels

🚀 Command Mode

Press Ctrl+P to enter Command Mode, then type a command and press Enter.

Command Alias Description
open <file> o <file> Open a file in a new tab.
save w Save the current file.
saveas <file> Save the current file with a new name.
copy Copy the selected range to the system clipboard.
paste Paste content from the system clipboard.
close q Close the current tab.
quit qa Exit the editor (prompts for unsaved files).
new Create a new empty tab.
set <key> <val> Change a setting (e.g., set tab_width 2).
undo Undo the last action.
redo Redo the last undone action.
goto <line> Jump to the specified line number.
next tabn Switch to the next tab.
prev tabp Switch to the previous tab.
find <query> Search for the specified query.
replace <old> <new> Replace occurrences of <old> with <new>.
expw <width> explorer_width Set the file explorer width.
termh <height> terminal_height Set the integrated terminal height.
diff Show a Git diff of the current file in a new tab.
delcomm Remove all comments from the current buffer.
template <lang> Insert a template for the specified language.

⚙️ Configuration

User settings are stored in ~/.caffee_setting/setting.json. You can edit this file directly or use the interactive settings manager from the start screen (Ctrl+S -> [2] Choice setting).

Example Configuration

{
  "tab_width": 4,
  "history_limit": 50,
  "use_soft_tabs": true,
  "auto_indent": true,
  "backup_count": 5,
  "enable_predictive_text": true,
  
  "templates": {
    "python": "def main():\\n    print(\"Hello, world!\")\\n\\nif __name__ == \"__main__\":\\n    main()",
    "javascript": "function main() {\\n    console.log('Hello, world!');\\n}\\n\\nmain();"
  },

  "start_screen_mode": true,
  "show_explorer_default": true,
  "explorer_show_details": true,
  
  "colors": {
    "header_text": "BLACK",
    "header_bg": "WHITE",
    "keyword": "YELLOW",
    "string": "GREEN",
    "comment": "MAGENTA",
    "number": "BLUE",
    "diff_add": "GREEN",
    "diff_remove": "RED"
  }
}

Key Configuration Options

  • auto_indent: Enable/disable automatic indentation.
  • enable_predictive_text: Enable/disable auto-completion suggestions.
  • explorer_show_details: Show file size and modification date in the explorer.
  • displayed_keybindings: Customize which keybindings appear in the footer bar.
  • colors: Comprehensive color customization for all UI elements.

🧩 Plugin System

Extend CAFFEE's functionality with custom Python scripts placed in ~/.caffee_setting/plugins/. Use the interactive Plugin Manager (Start Screen -> Ctrl+P) to enable or disable plugins.

Plugin API

Plugins can access the editor's state and functions via an init(editor) entry point, allowing you to:

  • Bind custom key combinations.
  • Register new syntax highlighting rules.
  • Add new build commands.
  • Manipulate buffers and the cursor.
  • Display custom messages in the status bar.

🛠️ Troubleshooting

  • Display Issues: If colors or special characters don't render correctly, ensure your terminal supports 256 colors and UTF-8. For environments like iSH, CAFFEE attempts to set a compatible TERM variable automatically.
  • File Access: If you encounter errors saving files or creating backups, check the permissions for ~/.caffee_setting/.
  • Terminal Not Working: The integrated terminal requires pty support (standard on Linux and macOS).

🤝 Contributing

Contributions are welcome! Please fork the repository, make focused changes in a feature branch, and submit a pull request.


📄 License

This project is licensed under the GNU General Public License v3. See the LICENSE file for details.


Made with ☕ and Python.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

caffee-2.8.3.tar.gz (90.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

caffee-2.8.3-py3-none-any.whl (60.1 kB view details)

Uploaded Python 3

File details

Details for the file caffee-2.8.3.tar.gz.

File metadata

  • Download URL: caffee-2.8.3.tar.gz
  • Upload date:
  • Size: 90.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for caffee-2.8.3.tar.gz
Algorithm Hash digest
SHA256 910a0bdbb725c6b52520709844c9d6beb6a059ae4c82c9ce6dbbe896e79653de
MD5 d4524d3ea9bf39349f9ebd425867d075
BLAKE2b-256 56d7d18a0f9332e89e5908e469cb869927aa8396c34a24dec3154eb2c4dbfd50

See more details on using hashes here.

Provenance

The following attestation bundles were made for caffee-2.8.3.tar.gz:

Publisher: pypi_publish.yml on iamthe000/CAFFEE_Editor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file caffee-2.8.3-py3-none-any.whl.

File metadata

  • Download URL: caffee-2.8.3-py3-none-any.whl
  • Upload date:
  • Size: 60.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for caffee-2.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8701e2e66db375a59b369d5ae22907254584aa1a1aeb7bfa750e42880ef90b35
MD5 4828c203b6038a065405c5738a5c82b9
BLAKE2b-256 15d945cf815db190dc6dc6137e901d75df83b6be9ea109d83851e8a837eb6c99

See more details on using hashes here.

Provenance

The following attestation bundles were made for caffee-2.8.3-py3-none-any.whl:

Publisher: pypi_publish.yml on iamthe000/CAFFEE_Editor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page