A sophisticated desktop GUI editor for the Casebook interactive narrative language, built with Python, Qt6, and Lark.
- Syntax highlighting for multiple languages
- Line numbers and current line highlighting
- Multiple file support with tabs
- Auto-indentation and code folding
- Undo/redo functionality
- Cut, copy, and paste operations
- Find and replace with regex support
- Real-time file search (Ctrl+P)
- Project tree view
- File creation and deletion
- Quick file navigation
- Recent files tracking
- Auto-save functionality
- External file change detection
- Project backup and restore
- Multiple file export formats:
- Plain Text (.txt)
- HTML with syntax highlighting
- Markdown (.md)
- PDF (coming soon)
- Settings export/import
- Progress tracking for large operations
- Non-blocking export operations
- Real-time file search
- Advanced find and replace
- Regular expression support
- Case sensitivity options
- Whole word matching
- Multi-file search
- Search history
-
Requirements:
- Python 3.12 or higher
- PyQt6
- QScintilla
- Lark Parser
-
Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtpython main.pyLARK/
├── src/
│ ├── editor/
│ │ ├── editor.py # Editor widget implementation
│ │ └── lexer.py # Syntax highlighting and token styling
│ └── grammar/
│ ├── base_grammar.py # Core language grammar and token definitions
│ └── grammar_manager.py # Grammar handling and parser configuration
│ └── gui/
│ ├── enhanced_window.py # Main application window
│ ├── editor_tabs.py # Tabbed editor management
│ ├── file_tree.py # Project file navigation
│ ├── file_watcher.py # File system monitoring
│ ├── minimap.py # Code overview widget
│ └── quick_open.py # Quick file search dialog
├── main.py # Application entry point
├── README.md # This file
├── USER_GUIDE.md # Comprehensive user guide
├── STYLING.md # Theme customization guide
└── requirements.txt # Project dependencies
The Casebook editor uses a sophisticated grammar system that supports:
- Scene definitions with nested content blocks
- Function declarations and calls
- Variable declarations and assignments
- Control structures (if/else, while, for)
- Character dialogue system
- Action descriptions
- Game configuration
- Comments (single-line and block)
- String literals (single, double, and triple-quoted)
-
Keywords
- Scene and function definitions
- Control flow statements
- Variable declarations
- Boolean constants
-
String Literals
- Double-quoted strings
- Single-quoted strings
- Triple-quoted strings
- Unicode strings
-
Scene Elements
- Scene names
- Section types
- Configuration blocks
-
Actions
- Configure functions
- Check functions
- Do statements
-
Characters
- Character names (uppercase)
- Dialogue blocks
To extend the Casebook grammar with custom features:
- Create a file named
casebook.override.larkin the project root - Add your custom rules using Lark grammar syntax
- Restart the editor to apply the changes
Example override file:
// Add a new statement type
?statement: base_statement // Include base statements
| special_action // Add custom statement
// Define the new statement
special_action: "SPECIAL" STRING "WITH" expression
// Add custom operator
?operator: base_operator | "CUSTOM_OP"
// Add new token type
SPECIAL_TOKEN: /[A-Z]+_[0-9]+/The editor is built with:
- PyQt6 for the GUI framework
- QScintilla for the code editing widget
- Lark for parsing and lexical analysis
-
Editor (
src/editor/editor.py)- Code editing functionality
- Syntax highlighting
- Scene detection
- Multiple cursors
- Code folding
- Auto-closing brackets
- Error/warning indicators
-
Grammar (
src/grammar/base_grammar.py)- Token definitions
- Grammar rules
- Parsing configurations
-
GUI (
src/gui/)- Main window management
- File tree navigation
- Tab management
- File watching
- Quick file opening
- Code overview minimap
-
To modify syntax highlighting:
- Update token styles in
src/editor/lexer.py - Modify token recognition patterns
- Adjust style colors and categories
- Update token styles in
-
To modify grammar:
- Update token definitions in
src/grammar/base_grammar.py - Add or modify grammar rules
- Configure parser options in
src/grammar/grammar_manager.py
- Update token definitions in
README.md- Project overview and development guideUSER_GUIDE.md- Comprehensive user documentationSTYLING.md- Theme customization guide- Inline code comments - Technical documentation
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
