Skip to content

Provide a way for authors to center adventure text#18

Merged
gitosaurus merged 3 commits into
mainfrom
fix/centered
Apr 18, 2026
Merged

Provide a way for authors to center adventure text#18
gitosaurus merged 3 commits into
mainfrom
fix/centered

Conversation

@gitosaurus
Copy link
Copy Markdown
Owner

@gitosaurus gitosaurus commented Apr 18, 2026

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.

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 cerr anyhow. Fixed here.

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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in WrappedOutput.
  • Extends statement execution/parsing to support the new reserved word write_centered.
  • Updates game scripts (starship.arch, gorreven.arch) to use write_centered in title blocks and adds a WrappedOutput unit 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.

Comment thread src/main.cc
Comment thread src/Statement.cc
Comment thread src/Statement.cc Outdated
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>
@gitosaurus gitosaurus merged commit bca0eaf into main Apr 18, 2026
1 check passed
@gitosaurus gitosaurus deleted the fix/centered branch April 18, 2026 23:55
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