-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Keyboard navigation of clickable link #6649
Comments
I agree this would be super useful. I'd think we could probably leave out I'm maybe rambling a bit. |
Copying some ideas from the dup I accidentally made... Description of the new feature/enhancementWindows Terminal supports automatic detection of hyperlinks and allows you to open the hyperlink using your mouse (specifically ctrl+clicking the link). I've realized that there's no way to do this using only the keyboard. Once mark mode lands, the solution is a little better, but still far from perfect and on par. The user would be able to navigate to the text with the hyperlink, create a selection that encompasses it, copy the URL, then manually open it in their preferred web browser. What if we could make this a nicer experience? Consider this...
Some corner cases...
From Mike...
|
## Summary of the Pull Request Adds support to navigate to clickable hyperlinks using only the keyboard. When in mark mode, the user can press [shift+]tab to go the previous/next hyperlink in the text buffer. Once a hyperlink is selected, the user can press <kbd>Ctrl+Enter</kbd> to open the hyperlink. ## References #4993 ## PR Checklist * [x] Closes #6649 * [x] Documentation updated at MicrosoftDocs/terminal#558 ## Detailed Description of the Pull Request / Additional comments - Main change - The `OpenHyperlink` event needs to be piped down to `ControlCore` now so that we can open a hyperlink at that layer. - `SelectHyperlink(dir)` searches the buffer in a given direction and finds the first hyperlink, then selects it. - "finding the hyperlink" is the tough part because the pattern tree takes in buffer coordinates, searches through the buffer in that given space, then stores everything relative to the defined space. Normally, the given buffer coordinates would align with the viewport's start and end. However, we're now trying to search outside of the viewport (sometimes), so we need to manage two coordinate systems at the same time. - `convertToSearchArea()` lambda was used to convert a given coordinate into the search area coordinate system. So if the search area is the visible viewport, we spit out a viewport position. If the search area is the _next_ viewport, we spit out a position relative to that. - `extractResultFromList()` lambda takes the list of patterns from the pattern tree and spits out the hyperlink we want. If we're searching forwards, we get the next one. Otherwise, we get the previous one. We explicitly ignore the one we're already on. If we don't find any, we return `nullopt`. - Now that we have all these cool tools, we use them to progressively search through the buffer to find the next/previous hyperlink. Start by searching the visible viewport _after_ (or _before_) the current selection. If we can't find anything, go to the next "page" (viewport scrolled up/down). Repeat this process until something comes up. - If we can't find anything, nothing happens. We don't wrap around. - Other relevant changes - the `copy` action is no longer bound to `Enter`. Instead, we manually handle it in `ControlCore.cpp`. This also lets us handle <kbd>Shift+Enter</kbd> appropriately without having to take another key binding. - `_ScrollToPoint` was added. It's a simple function that just scrolls the viewport such that the provided buffer position is in view. This was used to de-duplicate code. - `_ScrollToPoint` was added into the `ToggleMarkMode()` function. Turns out, we don't scroll to the new selection when we enter mark mode (whoops!). We _should_ do that and we should backport this part of the change too. I'll handle that. - add some clarity when some functions are using the viewport position vs the buffer position. This is important because the pattern interval tree works in the viewport space. ## Validation Steps Performed - case: all hyperlinks are in the view - ✅ get next link - ✅ get prev link - ✅ case: need to scroll down for next link - ✅ case: need to scroll up for next link
## Summary of the Pull Request Polishes #13405 with some additional feedback found in testing and post-mortem reviews. Such feedback includes: - [x] ControlInteractivity vs ControlCore split ([link](#13405 (comment))) - [x] clearing the selection should be under lock when copying text via "Enter" - [x] move mark mode keybindings into a helper function - [x] decide if "Enter" should be configurable or non-configurable ([link](#13405 (comment))) - [x] rename `_isTargetingUrl` - [x] bugfix: ctrl+enter when the link is outside of the viewport ## References Original PR: #13405 Relevant issue: #6649 Epic: #4993
🎉This issue was addressed in #13405, which has now been successfully released as Handy links: |
Description of the new feature/enhancement
Keyboard navigation of clickable link in terminal text. Terminal Roadmap v2.0 is describing about clickable link
| Hyperlinking any links that appear in the text buffer. When clicking on the link, the link will open in your default browser.
However, this involves pointing device such as mouse or trackball. I believe many of terminal users love keyboard and it is important to keep using keyboard without switching to pointing device as much as possble.
Proposed technical implementation details (optional)
We may have a command like "NavigateToPreviousClickableLink" or "NavtigateToNextClickableLink" and "InvokeFocusedClickableLink", then we can reassign key binding those command.
bentaudun commented as #204 (comment) but wasn't mentioned in #574
The text was updated successfully, but these errors were encountered: