# posprint

Cross-platform designer for POS (point-of-sale) receipt documents. Edit templates in a markdown-like syntax, preview output live, substitute runtime parameters, and print via raw ESC/POS (USB printer-class, Windows spooler, or USB-serial).

**Target platforms:** Windows and Linux (x64).

## Status

**v0.5.5** — Tab completion caret fix, multi-word barcode/QR data, native HRI off by default.

## Build and run

Requires **Rust 1.88+** ([rustup](https://rustup.rs/) or `pacman -S rust` on Arch). See [docs/BUILD.md](docs/BUILD.md) for OS libraries and package scripts.

```bash
cargo test          # unit tests
cargo run           # launch the designer
cargo build --release
```

**Scripts:** `scripts/build-windows.ps1`, `scripts/build-linux.sh`, `scripts/build-arch.sh`  
(Interactive shells offer to install missing dependencies.)

### Command-line printing

```bash
# Windows (serial or spooler queue name)
posprint print receipt.pos -p COM3 --set StoreName="Shop" --set DocumentNumber=42

# Linux
posprint print receipt.pos -p /dev/ttyUSB0 --set StoreName="Shop" --set DocumentNumber=42

# Embedded CLI help for this OS
posprint cli-help
```

All `${Parameters}` must be supplied via `--set NAME=VALUE` or the command fails.

**Linux serial:** add your user to the `dialout` group.

## Releases (GitLab CI)

| Platform | Artifact | Install |
|----------|----------|---------|
| Linux (Debian/Ubuntu) | `.deb` (amd64) | `sudo dpkg -i posprint_*_amd64.deb` then `sudo apt-get install -f` |
| Linux (Arch) | `.pkg.tar.zst` (x86_64) | `sudo pacman -U posprint_*_x86_64.pkg.tar.zst` |
| Windows | `posprint.exe` | Download from GitLab release job artifacts |

Tag a version (e.g. `0.4.0`) to trigger release builds. If AUR publishing is configured, the same tag pipeline also updates the AUR package.

## Features

- Markdown-like template editor with live preview (Design tab)
- Page width (mm) and calibrated preview zoom
- Save and load `.pos` files
- Parameter tokens: `${Name}` (text) and `$[Name]` (bool checkbox) via print dialog and CLI `--set`
- Inline ASCII checkboxes (`[]` / `[ ]` / `[x]`) — CP437-safe on thermal printers
- Nested bullet lists, headings, `@date` / `@time`, barcodes, QR, images
- Print via USB-direct, Windows spooler, or serial (baud probed)
- In-app **Help** tab (from [docs/HELP.md](docs/HELP.md))

## Documentation

| Document | Description |
|----------|-------------|
| [HELP.md](docs/HELP.md) | **User reference** (mirrored in-app Help tab) |
| [ARCHITECTURE.md](docs/ARCHITECTURE.md) | System architecture and module breakdown |
| [DSL-SPEC.md](docs/DSL-SPEC.md) | Document markup language (`.pos` body syntax) |
| [FILE-FORMAT.md](docs/FILE-FORMAT.md) | `.pos` file envelope (metadata + body) |
| [PRINTING.md](docs/PRINTING.md) | Printer discovery, transport, ESC/POS pipeline |
| [POSPRINT-URL.md](docs/POSPRINT-URL.md) | `posprint://` deep links and `lib/` helpers |
| [AUR.md](docs/AUR.md) | AUR package layout, secrets, and tag-driven publishing |
| [BUILD.md](docs/BUILD.md) | Local build scripts and Linux package formats |

Documentation must stay aligned with the codebase; see `.cursor/rules/documentation.mdc`.

## Dependencies (minimal)

| Crate | Why |
|-------|-----|
| `eframe` / `egui` | Native UI |
| `serde` / `serde_json` | `.pos` file format |
| `serialport` | Serial printer I/O |
| `rusb` | USB printer-class devices |
| `image` | Load PNG/JPEG for `@image` |
| `rfd` | Native open/save dialogs |
| `barcoders` | Raster barcode rendering |
| `qrcode` | Raster QR rendering |
| `clap` | CLI `print` / `link` / `cli-help` |
| `flate2` / `base64` | `posprint://` URL payload |
| `ureq` | Download `@image http(s)://…` |

ESC/POS encoding is implemented in-tree.
