-
Notifications
You must be signed in to change notification settings - Fork 3
Implemented toString methods for mouse events and for other event types #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
β¦es (Event, PasteEvent, FocusEvent and ResizeEvent).
WalkthroughAdded string-representation methods and supporting imports: Changes
Estimated code review effortπ― 2 (Simple) | β±οΈ ~10 minutes
Poem
Pre-merge checks and finishing touchesβ Passed checks (3 passed)
β¨ Finishing touchesπ§ͺ Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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
toStringimplementation 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
toStringmethod. If this becomes a performance bottleneck in the future, consider usingstd.array.Appenderfor 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
π 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.dsource/dcell/event.dsource/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
formatis a good practice and keeps the namespace clean.
23-26: LGTM!The
toStringimplementation is clean and provides a clear coordinate representation. Theconst pureattributes 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 switchto ensure exhaustive handling of all event types. The union member access is safe because each member is only accessed after discriminating on thetypefield. The delegation to nestedtoStringmethods provides a clean, composable design.
82-85: LGTM!The simple string representation is appropriate for
ResizeEventsince it carries no additional payload.
96-104: LGTM!The
PasteEvent.toStringimplementation correctly handles all three cases (text content, binary data, empty) and provides useful diagnostic information about the payload size.
112-115: LGTM!The
FocusEvent.toStringimplementation is concise and clearly distinguishes between focus gained and lost states.
There was a problem hiding this 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.button1instead ofbtn.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
π 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.
Where other event types are Event, PasteEvent, FocusEvent and ResizeEvent.
Summary by CodeRabbit
βοΈ Tip: You can customize this high-level summary in your review settings.