Provide a way for authors to center adventure text#18
Merged
Conversation
Introduces a new output keyword, write_centered, that centers its concatenated arguments against the current terminal width, replacing hand-eyeballed leading spaces that assumed an 80-column screen. Adds IUserOutput::center() with a default implementation and a WrappedOutput override that pads against maxColumns_. Updates the starship.arch and gorreven.arch title blocks to use the new statement.
There was a problem hiding this comment.
Pull request overview
Adds a new write_centered output keyword and supporting output API so adventure authors can center title/heading text based on the active terminal width (instead of hardcoded leading spaces).
Changes:
- Introduces
IUserOutput::center()(default implementation) and implements centered output inWrappedOutput. - Extends statement execution/parsing to support the new reserved word
write_centered. - Updates game scripts (
starship.arch,gorreven.arch) to usewrite_centeredin title blocks and adds aWrappedOutputunit test for centering.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main.cc | Changes version banner emission from Universe output to std::cerr. |
| src/UserOutput.hh | Adds IUserOutput::center() with a default behavior. |
| src/WrappedOutput.hh / src/WrappedOutput.cc | Adds centered rendering that pads against maxColumns_. |
| src/Statement.cc | Adds execution + parsing support for write_centered (concat args then center). |
| src/Keywords.hh / src/Keywords.cc | Adds RW_WRITE_CENTERED and reserves "write_centered". |
| src/TestWrappedOutput.hh / src/TestWrappedOutput.cc | Adds a unit test verifying WrappedOutput::center() padding behavior. |
| games/starship.arch / games/gorreven.arch | Migrates title text blocks to write_centered + blank-line writes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses review feedback on PR #18: - TestWrappedOutput::testCenter_ now asserts on output deltas rather than find() or rfind() across cumulative output, and pins the exact-width edge case. - OutputStatement::execute only constructs the ostringstream on the RW_WRITE_CENTERED path; its truthiness doubles as the write-mode flag elsewhere in the function. - TestStatement gains an end-to-end case that exercises keyword reservation, parsing, argument concatenation, and routing to IUserOutput::center(). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Introduces a new output keyword, write_centered, that centers its concatenated arguments against the current terminal width, replacing hand-eyeballed leading spaces that assumed an 80-column screen. Adds
IUserOutput::center()with a default implementation and aWrappedOutputoverride that pads againstmaxColumns_. Updates thestarship.archandgorreven.archtitle blocks to use the new statement.Also tidy up where the "Archetype" banner is printed. It has been going to the standard output all along, but that makes it hard to capture the output into any other file with redirection. Semantically it's better to be
cerranyhow. Fixed here.