Skip to content

[DEVELOP] Handle text_viewer '^' characters - #433

Merged
networkfusion merged 3 commits into
n64brew:developfrom
networkfusion:improve-textviewer
Oct 31, 2026
Merged

networkfusion merged 3 commits into
n64brew:developfrom
networkfusion:improve-textviewer

Conversation

@networkfusion

@networkfusion networkfusion commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

handle escape sequences in txt files.
Works towards #420

Description

Motivation and Context

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that adds a new feature)
  • Bug fix (fixes an issue)
  • Breaking change (breaking change)
  • Documentation Improvement
  • Config and build (change in the configuration and build system, has no impact on code or features)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

You agree with the license terms and that other license types may be granted with permission of the original N64FlashcartMenu project license holders.

Signed-off-by: GITHUB_USER <GITHUB_USER_EMAIL>

Summary by CodeRabbit

  • Bug Fixes
    • The text viewer now displays literal caret (^) characters as written instead of interpreting them as formatting escapes. Files containing carets retain their original visible text, and nearby content is no longer unintentionally affected by escape formatting. This makes the displayed text more consistent with the contents of the file.

handle escape sequences (first attempt).
Works towards n64brew#420
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c450a2aa-48e8-45a6-b981-52a1306a3fc8
Commits

Reviewing files that changed from the base of the PR and between 3e867e3 and 973c900.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • No new commits to review - use @coderabbitai full review for a full pass

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2ff72952-0ba8-48ad-8528-f3b39aa3cd52
Commits

Reviewing files that changed from the base of the PR and between 9c94995 and 3e867e3.

Files selected for processing: 1
  • src/menu/views/text_viewer.c

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

The text viewer now doubles literal carets in file contents before passing them to the renderer. It checks the file position and reports errors if position lookup or expanded-buffer allocation fails.

Changes: Text viewer content handling

Layer / File(s) Summary
Count and escape literal carets
src/menu/views/text_viewer.c
The viewer defines TEXT_VIEWER_ESCAPE_CHAR, counts carets, and doubles each caret in an expanded buffer. It updates the stored length and reports errors if file-position lookup or buffer allocation fails.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · previous review 3e867

Literal carets should display correctly. No merge-blocking risk was identified.

Architecture risk: Low · up to 3e867

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/menu/views/text_viewer.c: Adds TEXT_VIEWER_ESCAPE_CHAR, set to ^.
  • observed — Modified behavior in src/menu/views/text_viewer.c: Initialization documents the need to escape literal carets before rendering and counts them; it also checks ftell and, on failure, deinitializes and reports that the file position could not be determined.
  • observed — Modified behavior in src/menu/views/text_viewer.c: The contents buffer allocation now uses text->length + 1 directly instead of multiplying by sizeof(char); its existing allocation-failure handling remains.
  • observed — Modified behavior in src/menu/views/text_viewer.c: After terminating the read contents, initialization counts ^ characters. If the count is nonzero, it allocates space for the original contents plus one extra character per caret, copies backward while duplicating each caret, then frees the original buffer and updates text->contents and text->length. On allocation failure it deinitializes and reports an error. The previous immediate terminator assignment is replaced by termination of the expanded buffer when escaping occurs; without carets, the original terminator remains.
Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the main change: handling '^' characters in text_viewer.c. The '[DEVELOP]' prefix adds minor noise but does not reduce clarity.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
Simplify code
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@networkfusion
networkfusion marked this pull request as ready for review October 31, 2026 02:39
@networkfusion networkfusion changed the title [DRAFT] Handle text_viewer '^' characters [DEVELOP] Handle text_viewer '^' characters Oct 31, 2026
@networkfusion
networkfusion merged commit 772a7ad into n64brew:develop Oct 31, 2026
3 checks passed
@networkfusion
networkfusion deleted the improve-textviewer branch October 31, 2026 02:48
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.

1 participant