Repository navigation
[DEVELOP] Handle text_viewer '^' characters - #433
Conversation
handle escape sequences (first attempt). Works towards n64brew#420
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| 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:
srcArchitecture 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
ftelland, 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 + 1directly instead of multiplying bysizeof(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 updatestext->contentsandtext->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: 
5
-
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
handle escape sequences in txt files.
Works towards #420
Description
Motivation and Context
How Has This Been Tested?
Screenshots
Types of changes
Checklist:
You agree with the license terms and that other license types may be granted with permission of the original
N64FlashcartMenuproject license holders.Signed-off-by: GITHUB_USER <GITHUB_USER_EMAIL>
Summary by CodeRabbit
^) 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.