Skip to content

feat: surface mirror, chain, special-tape via capability-flag pattern - #21

Merged
nbuchwitz merged 1 commit into
nbuchwitz:mainfrom
johntrandall:feat/capability-flags-mirror-chain-special-tape
Jun 13, 2026
Merged

nbuchwitz merged 1 commit into
nbuchwitz:mainfrom
johntrandall:feat/capability-flags-mirror-chain-special-tape

Conversation

@johntrandall

Copy link
Copy Markdown
Contributor

Extends the existing SUPPORTS_X / DEFAULT_X / x: bool | None = None runtime-override pattern (currently used for auto_cut, half_cut, page_number_cuts, high_resolution) to three features whose byte-level support already exists in internal _cmd_* methods but had no public surface.

Addresses items (a), (b), (c), and the documentation half of (d) from #20.

Changes

  • mirror_print (ESC i M bit 7): was reachable only by subclassing and overriding _cmd_mode_settings.
  • chain_printing (ESC i K bit 3, inverted): print() hardcoded chain_printing=False, so chain mode was unreachable from the public API.
  • special_tape no-cut (ESC i K bit 4): entirely absent from the library; added to _cmd_advanced_mode_settings.

Each feature now gets all four surfaces:

```python
SUPPORTS_MIRROR_PRINT: bool = True
DEFAULT_MIRROR_PRINT: bool = False # plus _CHAIN_PRINTING, _SPECIAL_TAPE

print(..., mirror: bool | None = None,
chain: bool | None = None,
special_tape: bool | None = None)

print_multi(..., mirror=, chain=, special_tape=) # forwarded per-page
```

None falls back to the class default — subclasses can flip behavior en masse by setting e.g. DEFAULT_MIRROR_PRINT = True, or callers can pass the runtime kwarg per-call.

I also expanded print_multi(half_cut=...)'s docstring to honestly explain a hardware constraint I verified on PT-P750W: because the full-cutter blade is downstream of the print head, inter-page cuts with 0x0C (no feed) degrade to half-cuts at the print-head position. So print_multi(half_cut=False) and print_multi(half_cut=True) produce indistinguishable physical output. Docstring now points readers at N independent print() calls for true full-cut-separated labels.

Verification

Bit positions verified against Brother Raster Command Reference v1.02 page 33.

On-hardware verified end-to-end on PT-P750W over TCP/9100 for half-cut multi-copy and chain printing. (mirror and special-tape verified via byte-level capture; chain across CLI calls verified physically.)

Tests

17 new tests, 233 total pass:

  • TestLabelPrinterCapabilityFlags — new SUPPORTS_* / DEFAULT_* exist on base and inherited
  • TestCmdAdvancedModeSpecialTape — bit 4 toggles correctly, combines cleanly with other bits
  • TestCmdModeSettingsMirror — bit 7 toggles correctly
  • TestPrintNewKwargs — end-to-end through print(), mode bytes observed in capture
  • TestPrintDefaultsHonoredFromClass — subclass DEFAULT_* applies when kwarg omitted; runtime kwarg overrides class default
  • TestPrintMultiForwardsNewKwargs — every page receives the new settings

Extends the existing SUPPORTS_X / DEFAULT_X / `x: bool | None = None`
runtime-override pattern (currently in place for auto_cut, half_cut,
page_number_cuts) to three more features whose byte-level support
already exists in the internal `_cmd_*` methods but had no public
surface:

- mirror_print (ESC i M bit 7) — was reachable only by subclassing
  and overriding `_cmd_mode_settings`.
- chain_printing (ESC i K bit 3, inverted) — `print()` hardcoded
  `chain_printing=False`, so chain mode was unreachable.
- special_tape no-cut (ESC i K bit 4) — entirely absent from the
  library; added to `_cmd_advanced_mode_settings`.

Each feature now gets:

  SUPPORTS_MIRROR_PRINT: bool = True
  DEFAULT_MIRROR_PRINT: bool = False        # plus _CHAIN_PRINTING, _SPECIAL_TAPE

  print(..., mirror: bool | None = None,
        chain: bool | None = None,
        special_tape: bool | None = None)

  print_multi(..., mirror=, chain=, special_tape=)  # forwarded per-page

`None` falls back to the class default. Subclasses can flip behavior
en masse by setting e.g. `DEFAULT_MIRROR_PRINT = True`, or callers
can pass the runtime kwarg per-call.

Closes issue nbuchwitz#20 items (a), (b), (c). Bit positions verified against
Brother Raster Command Reference v1.02 page 33.

Tests added (17 new, 233 total still passing):

- TestLabelPrinterCapabilityFlags: new SUPPORTS_* / DEFAULT_* exist
  on base + inherited by PTE550W and PTP750W
- TestCmdAdvancedModeSpecialTape: bit 4 toggles correctly, combines
  cleanly with half_cut / chain / high_resolution
- TestCmdModeSettingsMirror: bit 7 toggles correctly
- TestPrintNewKwargs: end-to-end through print() — mode bytes
  observed in MockConnection capture confirm each kwarg lands
- TestPrintDefaultsHonoredFromClass: subclass DEFAULT_MIRROR_PRINT
  applies when kwarg omitted; runtime kwarg overrides class default
- TestPrintMultiForwardsNewKwargs: every page in a multi-page job
  receives the new settings

Claude-Session-Id: $CLAUDE_SESSION_ID
Resume: claude --resume $CLAUDE_SESSION_ID
@nbuchwitz
nbuchwitz force-pushed the feat/capability-flags-mirror-chain-special-tape branch from e11a539 to fcfbd59 Compare June 13, 2026 12:19
@nbuchwitz
nbuchwitz merged commit fba71d7 into nbuchwitz:main Jun 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants