# BIgo Reader

Standalone Go book reading application for BIgo book databases.

## Features

- 📖 Read Go books from BIgo SQLite databases
- 📄 View book PDFs with zoom and navigation
- 🎯 View diagrams with SGF rendering
- 🔖 Bookmarks for saving reading positions
- 🔍 Search within pages and across books
- 📑 Table of contents navigation
- 🔗 Clickable diagram and page links in text
- ⚙️ Customizable reading preferences
- 💾 Automatic session restore

## Installation

1. Ensure Python 3.8+ is installed
2. Install dependencies:

```bash
pip install -r requirements.txt
```

## Usage

### Command Line

Run from the bigo_reader directory:

```bash
python -m bigo_reader
```

Or from the main BIgo directory:

```bash
python -m bigo_reader
```

### Opening a Book

1. **File → Open Database...** to select a BIgo `.sqlite` database
2. Select a book from the available books
3. Navigate using the toolbar or keyboard shortcuts

## Keyboard Shortcuts

- **Ctrl+O** - Open database
- **Ctrl+W** - Close window
- **Ctrl+F** - Find in page
- **Ctrl+Shift+F** - Find in book
- **Ctrl+G** - Go to page
- **Ctrl+T** - Table of contents
- **Ctrl+D** - Add bookmark
- **Ctrl+B** - Manage bookmarks
- **Ctrl++** - Increase font size
- **Ctrl+-** - Decrease font size
- **F2** - View PDF (if available)
- **PgUp** - Previous page
- **PgDn** - Next page

## Configuration

Configuration is stored in:
- Windows: `%USERPROFILE%\.bigo_reader\config.json`
- Linux/Mac: `~/.bigo_reader/config.json`

### Settings

```json
{
  "window": {
    "width": 600,
    "height": 1000,
    "remember_size": true,
    "remember_position": true
  },
  "reader": {
    "font_family": "Segoe UI",
    "font_size": 11,
    "auto_open_first_diagram": true,
    "show_full_board": false
  },
  "database": {
    "recent_files": []
  }
}
```

## Session Management

Your reading session is automatically saved, including:
- Current database and book
- Current page position
- Bookmarks
- Window position and size

Session is restored when you restart the application.

## Architecture

```
bigo_reader/
├── core/           # Core application logic
│   ├── app.py      # Main application class
│   ├── config.py   # Configuration management
│   └── session.py  # Session management
├── ui/             # User interface
│   ├── main_window.py           # Main reader window
│   └── book_selection_dialog.py # Book selection
├── data/           # Data layer
│   ├── db_manager.py   # Database operations
│   └── models.py       # Data models
├── features/       # Feature modules
│   ├── text_reader.py   # Text display
│   ├── bookmarks.py     # Bookmarks
│   ├── search.py        # Search
│   └── navigation.py    # Navigation
├── diagrams/       # Diagram viewing
│   └── diagram_viewer.py  # SGF diagram viewer
├── pdf/            # PDF viewing
│   └── pdf_viewer.py      # PDF viewer with zoom
└── utils/          # Utilities
    ├── icons.py           # Icon generation
    └── text_tokens.py     # Token parsing
```

## Database Schema

BIgo Reader expects databases with the following tables:

- **Books** - Book metadata
- **Book_Parts** - Table of contents (chapters/sections)
- **Book_Pages** - Page text content
- **Book_Dias** - Diagram definitions (SGF)
- **Book_Pages_Dias** - Diagram-to-page associations

## Development Status

### ✅ Implemented
- Core application structure
- Configuration management
- Session management
- Main window UI with text display
- Database layer with schema v2.2
- Text reading with clickable tokens (@DIAGRAM@, pg123)
- Book selection dialog with search
- Diagram viewer (SGF rendering, navigation)
- PDF viewer (PyMuPDF/pypdfium2 backends)
- Icon generation for buttons
- Font size adjustment
- Book info display

### 🚧 In Progress
- Diagram navigation (forward/back through moves)
- Variant tree display
- Comments display in diagram viewer
- Table of contents dialog
- Search functionality
- Bookmarks manager

### 📋 Planned
- Advanced diagram features (export SGF/PNG/SVG)
- Diagram-to-PDF page synchronization
- Settings dialog
- Print support
- Multiple book windows

## License

© 2024 BIgo Team

## See Also

- [ARCHITECTURE.md](ARCHITECTURE.md) - Detailed architecture documentation
- [bigo_book](../bigo_book/) - Book editor and manager
- [bigo_problems](../bigo_problems/) - Problem solving system
