Repository navigation
feat: surface mirror, chain, special-tape via capability-flag pattern - #21
Merged
nbuchwitz merged 1 commit intoJun 13, 2026
Conversation
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
force-pushed
the
feat/capability-flags-mirror-chain-special-tape
branch
from
June 13, 2026 12:19
e11a539 to
fcfbd59
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends the existing
SUPPORTS_X/DEFAULT_X/x: bool | None = Noneruntime-override pattern (currently used forauto_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()hardcodedchain_printing=False, so chain mode was unreachable from the public API.special_tapeno-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
```
Nonefalls 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 with0x0C(no feed) degrade to half-cuts at the print-head position. Soprint_multi(half_cut=False)andprint_multi(half_cut=True)produce indistinguishable physical output. Docstring now points readers at N independentprint()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— newSUPPORTS_*/DEFAULT_*exist on base and inheritedTestCmdAdvancedModeSpecialTape— bit 4 toggles correctly, combines cleanly with other bitsTestCmdModeSettingsMirror— bit 7 toggles correctlyTestPrintNewKwargs— end-to-end throughprint(), mode bytes observed in captureTestPrintDefaultsHonoredFromClass— subclassDEFAULT_*applies when kwarg omitted; runtime kwarg overrides class defaultTestPrintMultiForwardsNewKwargs— every page receives the new settings