-
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
Add support for autodetecting URLs and making hyperlinks #7691
Conversation
It doesn't look like this PR adds any custom logic to the UIA text range, so I doubt UIA clients will be able to detect clickable links with this implementation. Have you tested for this (i.e. with Narrator/NVDA)? As an aside, this PR makes a good case for allowing browse mode in terminals (nvaccess/nvda#11172). |
Regarding accessibility. I haven't had a chance to test this out yet. Especially since it's in draft. But here's some resources and an idea of the work we'll probably have to do (probably in a separate PR): In
Another thought. Hyperlink support is just for Windows Terminal, not ConHost, right? That'll complicate things a bit with our accessibility model because |
If this is the plan, might this be reconsidered? While Windows Terminal is very feature-filled, in my experience conhost has much wider usage. |
@codeofdusk, @carlos-zamora Hyperlink support is Terminal-FIRST, not Terminal-ONLY. Sorry for the confusion. Since we can move so much faster in Terminal it lets us figure out the interaction model a lot sooner than if we throw something together and hope that people jump on the Windows Insider builds and test our thing out. Many, many changes that make it into Terminal will eventually flow back. This is especially true for anything that deals with accessibility, standards compliance and text rendering. We'd like to figure out the interaction model for formatted text and browseable regions in Terminal before we bring anything like this back into conhost, absolutely. |
src/buffer/out/textBuffer.cpp
Outdated
const auto startRow = gsl::narrow<SHORT>(start / rowSize); | ||
const auto startCol = gsl::narrow<SHORT>(start % rowSize); | ||
const auto endRow = gsl::narrow<SHORT>(end / rowSize); | ||
const auto endCol = gsl::narrow<SHORT>(end % rowSize); | ||
const COORD startCoord{ startCol, startRow }; | ||
const COORD endCoord{ endCol, endRow }; |
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.
I am pretty sure this level of math is also done in Find/Selection and it might be using TIL or one of the utilities/types classes to help with it. Consider deduplicating with those.
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.
Hm I can't seem to find the similar math - those parts of the code seem to begin with coordinates already (buffer or viewport) whereas here, since we only search after concatenating all the text together, we need to calculate the coordinates from the concatenated string
Now I don't want to go too crazypants here, but I'm thinking about future extensions to some degree. I'm curious if you considered a design where the text buffer figures out the patterns on its own instead of being pumped to do that action by a thread from way outside itself, in this case from up in the Terminal* and friends. I'm not saying this one is bad or wrong, but an alternate vision I have is that you would register an object with the TextBuffer that contained a pattern, region of interest, and a callback method/event inside of it. The TextBuffer would just... of its own accord as things are written in on the other methods (and maybe with its own internal, private thread or threadpool worker) grind through the region with the pattern and make callbacks as necessary. Almost like you have an |
As Dustin and I are musing about this... your |
OK we all discussed this with Teams. I'm willing to concede this point because Hyperlinks are so interesting here that they push the boundaries of this sort of unified model. And where the threads live is a bit contentious. And Dustin keeps coming up with more ideas why, while this model sort of works, it has sharp edges. So I'm fine with proceeding per what this draft has as a design. |
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.
Very close to signoff. Just a few oddball comments.
I edited your PR body down to be a nice commit body :) |
Hello @PankajBhojwani! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
… URL detecting (#8124) Fix #8121 ![image](https://user-images.githubusercontent.com/1068203/97811235-2081ca80-1cb4-11eb-82bd-1ddaf15c757c.png) <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request When calculating the position of the matched pattern, consider the width of the characters. However, if there are some wide glyphs in the detected hyperlink(not possible for now, for the existing regex will not match wide-character?). The repeated character in the tooltip is not fixed by this PR. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [ ] Closes #8121 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments When calculating the coordinate of the match in #7691, it simply uses the `prefix.size()` as the total prefix width on the screen. This PR fixes that behavior. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed Manually Verified
🎉 Handy links: |
Scott's wish finally became true: https://youtu.be/veqs2WVou9M?t=797 |
I love this feature! I have a question, would it be possible to make this hovering on the link customizeable? I know it gives an underline effects, but in the scenario where I have all of the links already "underlined", I can't see if I am hovering on a link or not. The example of custom customization would be to give a background color for the text with link or something similar. |
I guess that would be another issue |
@xeho91 today it underlines on hover. Is that not working for you? |
It does. However, in the example when I am using When I am hovering with the cursor, there's no "visual feedback", except this small dialogue box "Ctrl + Click to follow link.". What I am asking for to give us ability to define the style effect in settings for hovering on links. Like make the background white, and black text. If that's possible, no pressure, I still love this feature. ❤️ |
@xeho91 I've tossed this request into #5001, since this isn't actually the first time this has come up 😉 Thanks! |
I'd like to use this ability to open an html file stored on a remote computer using the UNC path. I haven't been able to get it to open. Any ideas? Example: \COMPUTER\UNC\Path\To\File.html |
This pull request is the initial implementation of hyperlink auto
detection
Overall design:
should know about
output/scrolling), TerminalControl tells TerminalCore (through a
throttled function for performance) to retrieve the visible pattern
locations from the TextBuffer
pattern, it paints that region differently
References #5001
Closes #574