This commit is contained in:
@@ -9,8 +9,12 @@ The `EbookReader` class provides a complete, user-friendly interface for buildin
|
||||
- 🔖 **Position Management** - Save/load reading positions (stable across font changes)
|
||||
- 📑 **Chapter Navigation** - Jump to chapters by title or index
|
||||
- 🔤 **Font Size Control** - Increase/decrease font size with live re-rendering
|
||||
- 📏 **Spacing Control** - Adjust line and block spacing
|
||||
- 📏 **Spacing Control** - Adjust line, block, and word spacing
|
||||
- 💾 **Persistent Settings** - Save and restore rendering preferences across sessions
|
||||
- 📊 **Progress Tracking** - Get reading progress and position information
|
||||
- 🎨 **Text Highlighting** - Highlight words and passages with colors
|
||||
- 📋 **Overlays** - TOC, Settings, and Bookmarks overlays
|
||||
- 🖱️ **Gesture Support** - Handle tap, swipe, pinch gestures
|
||||
- 💾 **Context Manager Support** - Automatic cleanup with `with` statement
|
||||
|
||||
## Quick Start
|
||||
@@ -235,12 +239,66 @@ with EbookReader(
|
||||
print(f"Reading progress: {progress*100:.1f}%")
|
||||
```
|
||||
|
||||
## Demo Script
|
||||
## Persistent Settings
|
||||
|
||||
Run the comprehensive demo to see all features in action:
|
||||
Settings like font size and spacing are automatically saved and restored across sessions:
|
||||
|
||||
```python
|
||||
from dreader import EbookReader
|
||||
from dreader.state import StateManager
|
||||
from pathlib import Path
|
||||
|
||||
# Initialize state manager
|
||||
state_file = Path.home() / ".config" / "dreader" / "state.json"
|
||||
state_manager = StateManager(state_file=state_file)
|
||||
|
||||
# Load saved state
|
||||
state = state_manager.load_state()
|
||||
print(f"Saved font scale: {state.settings.font_scale}")
|
||||
|
||||
# Create reader with saved settings
|
||||
reader = EbookReader(
|
||||
line_spacing=state.settings.line_spacing,
|
||||
inter_block_spacing=state.settings.inter_block_spacing
|
||||
)
|
||||
|
||||
# Load book and apply all saved settings
|
||||
reader.load_epub("mybook.epub")
|
||||
reader.apply_settings(state.settings.to_dict())
|
||||
|
||||
# User changes settings...
|
||||
reader.increase_font_size()
|
||||
reader.set_line_spacing(10)
|
||||
|
||||
# Save new settings for next session
|
||||
current_settings = reader.get_current_settings()
|
||||
state_manager.update_settings(current_settings)
|
||||
state_manager.save_state()
|
||||
|
||||
# Next time the app starts, these settings will be restored!
|
||||
```
|
||||
|
||||
See [persistent_settings_example.py](persistent_settings_example.py) for a complete demonstration.
|
||||
|
||||
## Demo Scripts
|
||||
|
||||
Run these demos to see features in action:
|
||||
|
||||
```bash
|
||||
# Comprehensive feature demo
|
||||
python examples/ereader_demo.py path/to/book.epub
|
||||
|
||||
# Persistent settings demo
|
||||
python examples/persistent_settings_example.py
|
||||
|
||||
# TOC overlay demo (generates animated GIF)
|
||||
python examples/demo_toc_overlay.py
|
||||
|
||||
# Settings overlay demo (generates animated GIF)
|
||||
python examples/demo_settings_overlay.py
|
||||
|
||||
# Word highlighting examples
|
||||
python examples/word_selection_highlighting.py
|
||||
```
|
||||
|
||||
This will demonstrate:
|
||||
|
||||
Reference in New Issue
Block a user