How nishron03/texgrab works
TexGrab is a macOS menu-bar tool that turns a user-selected screen region into LaTeX and copies only that text to the clipboard. Its main workflow runs from a global shortcut through permission-checked region capture, image recognition, and clipboard output; the app also offers sample OCR, shortcut/preferences controls, and status or notifications. The graph reflects documented capabilities and sampled call paths; some menu callbacks and supporting modules were not fully shown, so uncertain wiring is omitted.
Main entry points: app.py Menu app · pipeline.py Snip service · pix2tex_engine.py pix2tex engine · region.py Region capture
Components 20
App and controls
- Menu app
src/texgrab/app.py - App entry
src/texgrab/__main__.py - Snip service
src/texgrab/pipeline.py
Shortcut and capture
- Global hotkey
src/texgrab/hotkey/carbon.py - Shortcut recorder
src/texgrab/hotkey/recorder.py - Shortcut rules
src/texgrab/hotkey/combo.py - Capture permission
src/texgrab/permissions.py - Region capture
src/texgrab/capture/region.py
OCR processing
- Image pipeline
src/texgrab/pipeline.py - pix2tex engine
src/texgrab/ocr/pix2tex_engine.py - Image preparation
src/texgrab/ocr/preprocess.py - Matrix handling
src/texgrab/ocr/matrix.py
Preferences and outputs
- Saved preferences
src/texgrab/config.py - Clipboard writer
src/texgrab/clipboard.py - Notifications
src/texgrab/notify.py
Other components
- User
- macOS capture tool
- pix2tex model
- macOS pasteboard
- Paste destination
Connections 26
- User → Global hotkey: presses shortcut
- Global hotkey → Menu app: dispatches callback
- Menu app → Capture permission: checks access
- Menu app → Snip service: requests snip
- Snip service → Region capture: calls capture
- Region capture → macOS capture tool: runs selection
- Region capture → Snip service: returns image
- Snip service → Image pipeline: runs recognition
- Image pipeline → pix2tex engine: recognizes image
- pix2tex engine → Image preparation: prepares image
- pix2tex engine → Matrix handling: detects and fits
- pix2tex engine → pix2tex model: runs inference
- Image pipeline → Clipboard writer: writes LaTeX
- Clipboard writer → macOS pasteboard: sets text
- User → Paste destination: pastes text
- Paste destination → macOS pasteboard: reads text
- Menu app → Saved preferences: loads and saves
- Menu app → Shortcut recorder: opens recorder
- Shortcut recorder → Shortcut rules: validates choice
- Menu app → Shortcut rules: applies shortcut
- Menu app → Global hotkey: registers shortcut
- Menu app → Snip service: requests sample OCR
- Snip service → Notifications: reports result
- Menu app → Notifications: reports permission
- App entry → Menu app: starts app
- User → Menu app: uses menu