TUT/KEYBOARD.md
m1ngsama d38cdf93b0 feat: Add complete persistent history system
Completed Phase 1 high priority task - comprehensive browsing history:

HistoryManager (New):
- JSON persistence to ~/.config/tut/history.json
- Auto-records every page visit
- Updates timestamp on revisit (moves to front)
- Limit to 1000 entries maximum
- Each entry stores: title, URL, timestamp
- Handles special characters with JSON escaping
- Auto-creates config directory if needed

UI Integration:
- History panel in bottom (center-left) of UI
- Shows up to 5 most recent visits
- Displays "[1] Title" format with cyan highlighting
- Shows "+N more..." indicator if >5 entries
- Real-time update on every navigation

Auto-Recording:
- Records on navigation via address bar
- Records on link click navigation
- Records on back/forward navigation
- Skips empty URLs and about:blank
- Updates existing entries instead of duplicating

Keyboard Shortcuts:
- F3: Toggle history panel visibility
  * Refreshes history list when opened

Features:
- Persistent storage across browser sessions
- Smart duplicate handling (updates timestamp)
- Move-to-front on revisit
- Automatic trimming to max 1000 entries
- Sorted display (newest first)
- Empty state handling ("(empty)" message)

Technical Implementation:
- HistoryManager class with Pimpl idiom
- Simple JSON format for easy manual editing
- Event-driven architecture (WindowEvent::OpenHistory)
- Lambda callback for history updates
- Integrated with navigation callbacks
- Three-panel bottom layout (Bookmarks | History | Status)

Storage Format:
[
  {"title": "Page Title", "url": "https://...", "timestamp": 1234567890},
  ...
]

Documentation:
- Updated KEYBOARD.md with F3 shortcut
- Updated STATUS.md to reflect completion
- Added history to interactive features list

All Phase 1 features now complete! 📚🎉
2026-01-01 18:07:08 +08:00

136 lines
3.4 KiB
Markdown

# TUT Browser - Keyboard Shortcuts
## 🎯 Quick Reference
### Navigation
| Key | Action |
|-----|--------|
| `o` | Open address bar (type URL and press Enter) |
| `Backspace` | Go back |
| `f` | Go forward |
| `r` or `F5` | Refresh current page |
| `q` or `Esc` or `F10` | Quit browser |
### Scrolling
| Key | Action |
|-----|--------|
| `j` or `↓` | Scroll down one line |
| `k` or `↑` | Scroll up one line |
| `Space` or `PageDown` | Page down |
| `b` or `PageUp` | Page up |
| `g` | Go to top |
| `G` | Go to bottom |
### Links
| Key | Action |
|-----|--------|
| `Tab` | Select next link |
| `Shift+Tab` | Select previous link |
| `1-9` | Jump to link by number |
| `Enter` | Follow selected link |
## 📝 Usage Examples
### Basic Browsing
```bash
./build_ftxui/tut https://example.com
# 1. Press 'j' or 'k' to scroll
# 2. Press 'Tab' to cycle through links
# 3. Press 'Enter' to follow the selected link
# 4. Press 'Backspace' to go back
# 5. Press 'q' to quit
```
### Direct Link Navigation
```bash
./build_ftxui/tut https://tldp.org/HOWTO/HOWTO-INDEX/howtos.html
# See numbered links like [1], [2], [3]...
# Press '1' to jump to first link
# Press '2' to jump to second link
# Press 'Enter' to follow the selected link
```
### Address Bar
```bash
# 1. Press 'o' to open address bar
# 2. Type new URL
# 3. Press 'Enter' to navigate
# 4. Press 'Esc' to cancel
```
### In-Page Search
```bash
# Search for text on current page
# 1. Press '/' to open search bar
# 2. Type your search query (case-insensitive)
# 3. Press 'Enter' to find all matches
# 4. Press 'n' to go to next match
# 5. Press 'N' to go to previous match
# 6. Matches are highlighted (yellow = current, blue = other matches)
# 7. Status bar shows "Match X/Y" count
```
## 🎨 UI Elements
### Top Bar
- `[◀]` - Back button (dimmed when can't go back)
- `[▶]` - Forward button (dimmed when can't go forward)
- `[⟳]` - Refresh
- Address bar - Shows current URL
- `[⚙]` - Settings (not yet implemented)
- `[?]` - Help (not yet implemented)
### Content Area
- Shows rendered HTML content
- Displays page title at top
- Shows scroll position at bottom
### Bottom Panels
- **Bookmarks Panel** - Shows bookmarks (not yet implemented)
- **Status Panel** - Shows:
- Load stats (KB downloaded, time, link count)
- Currently selected link URL
### Status Bar
- Shows function key shortcuts
- Shows current status message
## ⚡ Pro Tips
1. **Fast Navigation**: Use number keys (1-9) to instantly jump to links
2. **Quick Scrolling**: Use `Space` and `b` for fast page scrolling
3. **Link Preview**: Watch the status bar to see link URLs before following
4. **Efficient Browsing**: Use `g` to jump to top, `G` to jump to bottom
5. **Address Bar**: Type `o` quickly to enter a new URL
### Search
| Key | Action |
|-----|--------|
| `/` | Start search (type query and press Enter) |
| `n` | Next search result |
| `N` | Previous search result |
| `Esc` | Cancel search |
### Bookmarks
| Key | Action |
|-----|--------|
| `Ctrl+D` | Add/remove current page as bookmark |
| `F2` | Toggle bookmark panel |
### History
| Key | Action |
|-----|--------|
| `F3` | Toggle history panel |
## 🐛 Known Limitations
- Ctrl+L not yet working for address bar (use 'o' instead)
- Cannot navigate to bookmarks/history from panel yet (coming soon)
## 🚀 Coming Soon
- [ ] Navigate to bookmarks/history from panel (click/select)
- [ ] Better link highlighting
- [ ] Form support