Add C APIs for keyboard copy-mode selection control#4
Add C APIs for keyboard copy-mode selection control#4lawrencecchen wants to merge 1 commit intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughTwo new public methods are added to the Surface API: Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7dd589824d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| /// Start a selection at the active cursor cell. | ||
| export fn ghostty_surface_select_cursor_cell(surface: *Surface) bool { |
There was a problem hiding this comment.
Declare new selection APIs in the public C header
These two new exports are not declared in include/ghostty.h, so embedders using the shipped header cannot call them directly; in C99+ this typically surfaces as an implicit-declaration build error (often fatal under -Werror) even though the symbols exist at link time. I checked the header section around the existing selection APIs (ghostty_surface_has_selection/ghostty_surface_read_selection) and there are no prototypes for ghostty_surface_select_cursor_cell or ghostty_surface_clear_selection.
Useful? React with 👍 / 👎.
Greptile SummaryAdds C API functions to control terminal selection lifecycle for keyboard copy mode, with smart viewport-aware cursor anchoring.
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant App as C Application
participant API as Embedded C API
participant Surface as Surface.zig
participant Screen as Terminal Screen
Note over App,Screen: Select Cursor Cell Flow
App->>API: ghostty_surface_select_cursor_cell()
API->>Surface: selectCursorCell()
Surface->>Surface: Lock renderer mutex
Surface->>Screen: Check cursor visibility
alt Cursor visible in viewport
Surface->>Screen: Use cursor page_pin
else Cursor off-screen
Surface->>Screen: Use viewport origin pin
end
Surface->>Screen: select(Selection.init(pin, pin, false))
Surface->>Screen: Mark selection dirty
Surface->>Surface: Queue render
Surface->>Surface: Unlock mutex
Surface-->>API: Return true
API-->>App: Return true
Note over App,Screen: Clear Selection Flow
App->>API: ghostty_surface_clear_selection()
API->>Surface: clearSelection()
Surface->>Surface: Lock renderer mutex
alt No selection exists
Surface-->>API: Return false
else Selection exists
Surface->>Surface: setSelection(null)
Surface->>Screen: Mark selection dirty
Surface->>Surface: Queue render
Surface-->>API: Return true
end
Surface->>Surface: Unlock mutex
API-->>App: Return result
Last reviewed commit: 7dd5898 |
Summary
Related: manaflow-ai/cmux#788
Summary by cubic
Add embedded C APIs to start and clear keyboard copy-mode selections, and make copy mode start on visible content. Supports terminal vi copy mode work (cmux#788).
New Features
Bug Fixes
Written for commit 7dd5898. Summary will update on new commits.
Summary by CodeRabbit
Release Notes