Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dejlek
Copy link

@dejlek dejlek commented Dec 17, 2025

Where other event types are Event, PasteEvent, FocusEvent and ResizeEvent.

Summary by CodeRabbit

  • New Features
    • Added human-readable string representations for coordinates, mouse events, and various input/event types to improve readability of system output and debug logs.

✏️ Tip: You can customize this high-level summary in your review settings.

…es (Event, PasteEvent, FocusEvent and ResizeEvent).
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

Walkthrough

Added string-representation methods and supporting imports: toString() implementations were added to Coord, Event, ResizeEvent, PasteEvent, FocusEvent, and MouseEvent, emitting formatted text for each type.

Changes

Cohort / File(s) Summary
String representation implementations
source/dcell/coord.d, source/dcell/event.d, source/dcell/mouse.d
Added toString() methods and required imports (std.format and std.array where used). Implementations: Coord.toString() -> "(x, y)"; Event.toString() -> final switch over EventType with nested calls; ResizeEvent.toString() -> "Resize"; PasteEvent.toString() -> content-length/binary-aware description; FocusEvent.toString() -> "Focus[gained

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify all EventType variants are covered and formatted correctly in Event.toString().
  • Check MouseEvent.toString() ordering/formatting of modifiers, button join logic, and use of std.array.Appender.
  • Ensure pure/const annotations and visibility match existing style across structs.

Poem

🐰
I hop through structs with ink and cheer,
Turning numbers, clicks, and focus clear.
Parentheses hug each little coord,
Events sing stories I afford,
A tiny rabbit’s formatted cheer! πŸ₯•πŸ‡

Pre-merge checks and finishing touches

βœ… Passed checks (3 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title accurately summarizes the main changes: implementing toString methods for mouse events and other event types (Event, PasteEvent, FocusEvent, ResizeEvent).
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
source/dcell/mouse.d (1)

84-137: LGTM!

The toString implementation correctly handles all modifiers and button flags, producing a readable representation. The logic is sound and the format is informative for debugging.

The string concatenation approach is acceptable for a toString method. If this becomes a performance bottleneck in the future, consider using std.array.Appender for more efficient string building, but this is not a concern for typical debugging/logging usage.

πŸ“œ Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between acfb4b1 and 2edafde.

πŸ“’ Files selected for processing (3)
  • source/dcell/coord.d (1 hunks)
  • source/dcell/event.d (4 hunks)
  • source/dcell/mouse.d (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
πŸ“š Learning: 2025-12-15T05:12:35.344Z
Learnt from: gdamore
Repo: gdamore/dcell PR: 56
File: source/dcell/vt.d:2-2
Timestamp: 2025-12-15T05:12:35.344Z
Learning: In D (as used in gdamore/dcell), an enum-type variable like Attr attr can be referred to in case statements using either attr.EnumMember or Attr.EnumMember due to aliasing. For consistency and readability, prefer using the type name (Attr.EnumMember) in case statements instead of the lowercase variable name (attr.EnumMember). This guideline applies to D files across the repository (source/**/*.d or any .d files).

Applied to files:

  • source/dcell/coord.d
  • source/dcell/event.d
  • source/dcell/mouse.d
πŸ“š Learning: 2025-12-14T19:56:40.073Z
Learnt from: gdamore
Repo: gdamore/dcell PR: 53
File: source/dcell/screen.d:96-126
Timestamp: 2025-12-14T19:56:40.073Z
Learning: In dcell, the EventQ class is intentionally designed as both an input range and an output range of Event. The output range functionality allows applications to inject synthetic events into the event stream.

Applied to files:

  • source/dcell/event.d
πŸ”‡ Additional comments (8)
source/dcell/coord.d (2)

13-13: LGTM!

The selective import of format is a good practice and keeps the namespace clean.


23-26: LGTM!

The toString implementation is clean and provides a clear coordinate representation. The const pure attributes are appropriate for this method.

source/dcell/mouse.d (1)

13-13: LGTM!

Selective import follows D best practices.

source/dcell/event.d (5)

14-14: LGTM!

Consistent selective import pattern across all modified files.


51-72: LGTM!

Excellent use of final switch to ensure exhaustive handling of all event types. The union member access is safe because each member is only accessed after discriminating on the type field. The delegation to nested toString methods provides a clean, composable design.


82-85: LGTM!

The simple string representation is appropriate for ResizeEvent since it carries no additional payload.


96-104: LGTM!

The PasteEvent.toString implementation correctly handles all three cases (text content, binary data, empty) and provides useful diagnostic information about the payload size.


112-115: LGTM!

The FocusEvent.toString implementation is concise and clearly distinguishes between focus gained and lost states.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
source/dcell/mouse.d (1)

85-138: Excellent implementation of toString()!

The method correctly:

  • Formats modifiers and buttons with "+" separators
  • Handles the no-buttons case with "None"
  • Uses Appender for efficient string building
  • Follows enum naming conventions from project learnings (using Buttons.button1 instead of btn.button1)
  • Maintains const purity guarantees

Example output format: "Ctrl+Shift+Button1+Button2@(5, 10)" or "None@(0, 0)"

Would you like me to generate unit tests for this toString() method to verify the output format for various combinations of modifiers, buttons, and positions?

πŸ“œ Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 2edafde and 83b4115.

πŸ“’ Files selected for processing (1)
  • source/dcell/mouse.d (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
πŸ“š Learning: 2025-12-15T05:12:35.344Z
Learnt from: gdamore
Repo: gdamore/dcell PR: 56
File: source/dcell/vt.d:2-2
Timestamp: 2025-12-15T05:12:35.344Z
Learning: In D (as used in gdamore/dcell), an enum-type variable like Attr attr can be referred to in case statements using either attr.EnumMember or Attr.EnumMember due to aliasing. For consistency and readability, prefer using the type name (Attr.EnumMember) in case statements instead of the lowercase variable name (attr.EnumMember). This guideline applies to D files across the repository (source/**/*.d or any .d files).

Applied to files:

  • source/dcell/mouse.d
πŸ”‡ Additional comments (1)
source/dcell/mouse.d (1)

13-14: LGTM! Imports are appropriate.

The added imports support the toString() implementation efficiently. Appender is correctly used for string building, and format is used for coordinate formatting.

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