Skip to content

Conversation

@ReagentX
Copy link
Owner

@ReagentX ReagentX commented Jun 4, 2025

@ReagentX ReagentX self-assigned this Jun 4, 2025
@ReagentX ReagentX added bug Something isn't working render Problems with screen rendering handler Problems with the input handler classes labels Jun 4, 2025
@ReagentX ReagentX requested a review from Copilot June 4, 2025 23:41
Copy link

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

This PR fixes issue #118 by enhancing how multiline messages are centered in the terminal UI.

  • Adds get_rows_and_length to the length sanitizer to compute both rows needed and real length of ANSI-colored strings.
  • Refactors reader logic: changes center_row to usize, uses the new sanitizer API, and implements a center-expanding window for multiline messages.
  • Updates tests for the new API, resets scroll state in the highlight handler, and bumps the clap dependency version.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

File Description
src/util/sanitizers.rs Flattened imports, made get_real_length private, added get_rows_and_length, and updated tests.
src/communication/reader.rs Changed center_row to usize, replaced manual row calculus with get_rows_and_length, and rewrote centered scroll logic.
src/communication/handlers/highlight.rs Reset scroll_state to Free on clear.
Cargo.toml Bumped clap from 4.5.38 to 4.5.39.
Comments suppressed due to low confidence (2)

src/util/sanitizers.rs:26

  • The doc comment for get_rows_and_length explains calculating rows but doesn’t mention the returned tuple also contains the real length. Clarify that it returns (rows, length).
/// Given a string's real length and the terminal width, return the number of rows it would take to display the string.

src/util/sanitizers.rs:18

  • The method get_real_length is no longer pub, but it's still invoked by your tests. Make it pub fn get_real_length or adjust visibility so tests can access it.
fn get_real_length(&self, content: &str) -> usize {

@ReagentX ReagentX merged commit 6487992 into develop Jun 5, 2025
1 check passed
@ReagentX ReagentX deleted the feat/cs/multiline-center branch June 5, 2025 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working handler Problems with the input handler classes render Problems with screen rendering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ScrollState::Centered doesn't contain multiline logic

2 participants