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

Skip to content

Conversation

@gdamore
Copy link
Owner

@gdamore gdamore commented Dec 11, 2025

There is no reason for focus events to not always be enabled. This is unlike mouse or paste events, where the application might reasonably want to have different behaviors.

Summary by CodeRabbit

  • Refactor
    • Focus handling is now automatically enabled during startup. The ability to manually control focus enablement through a public method has been removed.

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

There is no reason for focus events to not always be enabled.
This is unlike mouse or paste events, where the application might
reasonably want to have different behaviors.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

Walkthrough

These changes remove the public enableFocus() method from the Screen interface and TtyScreen implementation, moving focus initialization into the startup sequence where it executes unconditionally as part of initialization rather than being caller-controlled.

Changes

Cohort / File(s) Change Summary
Focus API refactoring
source/dcell/screen.d, source/dcell/ttyscreen.d, demos/mouse/source/mouse.d
Removed public enableFocus(bool) method from Screen interface and TtyScreen class; moved focus enabling to start() method as unconditional initialization; removed corresponding call from demo code

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

  • Verify that moving focus initialization to start() doesn't conflict with existing initialization order
  • Confirm removal of the API doesn't break other callers (search codebase for other uses of enableFocus)
  • Ensure the vt.enableFocus output in start() produces expected VT sequence

Poem

A rabbit hops through shifting code,
Where focus was a knob to load,
Now baked into the startup's way,
It shines from dawn of every day! 🐰✨

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 'chore!: Remove the focus enable API' clearly and specifically describes the main change: removing the focus enable API from the codebase.
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
  • Commit unit tests in branch gdamore/always-focus-enabled

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb1e2a9 and 6e714ad.

📒 Files selected for processing (3)
  • demos/mouse/source/mouse.d (0 hunks)
  • source/dcell/screen.d (0 hunks)
  • source/dcell/ttyscreen.d (1 hunks)
💤 Files with no reviewable changes (2)
  • source/dcell/screen.d
  • demos/mouse/source/mouse.d
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: gdamore
Repo: gdamore/dcell PR: 27
File: source/dcell/ttyscreen.d:763-766
Timestamp: 2025-12-08T19:10:45.993Z
Learning: In source/dcell/ttyscreen.d, the newTtyScreen() factory function intentionally does not accept a term parameter because the TtyScreen constructor handles environment variable resolution internally with an optional term parameter. Users needing to override the terminal type should call the constructor directly: new TtyScreen(newDevTty(), "custom-term").
📚 Learning: 2025-12-08T19:10:45.993Z
Learnt from: gdamore
Repo: gdamore/dcell PR: 27
File: source/dcell/ttyscreen.d:763-766
Timestamp: 2025-12-08T19:10:45.993Z
Learning: In source/dcell/ttyscreen.d, the newTtyScreen() factory function intentionally does not accept a term parameter because the TtyScreen constructor handles environment variable resolution internally with an optional term parameter. Users needing to override the terminal type should call the constructor directly: new TtyScreen(newDevTty(), "custom-term").

Applied to files:

  • source/dcell/ttyscreen.d
📚 Learning: 2025-12-08T19:17:33.678Z
Learnt from: gdamore
Repo: gdamore/dcell PR: 27
File: source/dcell/ttyscreen.d:448-494
Timestamp: 2025-12-08T19:17:33.678Z
Learning: In source/dcell/ttyscreen.d, Color.reset is defined as a value above the range of valid colors. In the sendColors() function, after emitting the reset sequence (vt.resetFgBg), Color.reset values naturally skip all subsequent color-setting logic (isRGB checks and palette range checks < 8, < 256) because they are out of range, which is the correct behavior by design.

Applied to files:

  • source/dcell/ttyscreen.d
🔇 Additional comments (1)
source/dcell/ttyscreen.d (1)

252-277: Focus enable in start() is consistent with lifecycle and existing teardown

Unconditionally calling puts(vt.enableFocus); during start() matches the existing puts(vt.disableFocus); in stop(), giving a clean, symmetric lifecycle for focus tracking. Given the interface’s enableFocus API has been removed and this is explicitly a breaking change, always enabling focus here looks correct and doesn’t introduce new correctness risks in this class.


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

@gdamore gdamore merged commit f01d9fc into main Dec 11, 2025
3 checks passed
@gdamore gdamore deleted the gdamore/always-focus-enabled branch December 11, 2025 16:56
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.

2 participants