Skip to content
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

[Testing] HyperTextView #281

Closed
wants to merge 6 commits into from
Closed

[Testing] HyperTextView #281

wants to merge 6 commits into from

Conversation

marbetschar
Copy link
Member

Added the current implementation of HyperTextView for testing purposes. See elementary/granite#507 for details.

@mcclurgm
Copy link
Contributor

mcclurgm commented Sep 19, 2021

If this helps track down the tooltip bug, on my system there seems to be an issue with position offset, but only with the hover detector. It starts recognizing text halfway down the line, and continues recognizing the link halfway down the next line. This means that if I position the cursor over what seems like the middle of the text, odds are that it won't see the link. The ctrl+click operation works fine, presumably because you get the iterator a different way.

This does seem to be unique to Tasks, as you said. There may be some way that we're creating a position offset that this function isn't aware of or treating properly. I'm rather stumped, and debugging TextView positions is not easy...

Here's an example:
Screenshot from 2021-09-19 11 49 41


Update: I've found a potential fix, or at least a place where this comes into play. It seems like get_iter_at_location is returning false, even when it's returning an iter that contains text. To be sure, I made the following change to get_uri_at_location:

var over_text = get_iter_at_location (out text_iter, x, y);
if (over_text) {
    var tags = text_iter.get_tags ();

    foreach (var tag in tags) {
        if (tag.get_data<string?> ("uri") != null) {
            uri = tag.get_data<string> ("uri");
            break;
        }
    }
} else {
    warning ("text_iter setting failed.");
    if (text_iter != null) {
        debug (@"Non-null text_iter. Char: $(text_iter.get_char ())");
        debug ("chars_in_line: %i", text_iter.get_chars_in_line ());
    }
}

With this, I get characters printed by the chars_in_line debug, even when over_text is false. It's possible that we could skip using the over_text variable and do our own check. We'd have to be sure how Gtk sets the returned iter, though.

@jeremypw
Copy link
Collaborator

Definitely a problem getting window coords. This is what happens if you add enough text to cause scrolling:
TasksHyperTextView
The first few lines containing hypertext are not recognised as such.

I'll have a look into this and try and fix it.

@jeremypw
Copy link
Collaborator

I have pushed a commit that seems to fix the tooltip problem.

@marbetschar
Copy link
Member Author

@jeremypw thank you very much! Tested your fix and it works smoothly - it is now also part of the official HyperTextView PR over at the granite repo 🥳 elementary/granite#507

@marbetschar
Copy link
Member Author

Supserseded by #314

@marbetschar marbetschar closed this Dec 1, 2021
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.

3 participants