-
Notifications
You must be signed in to change notification settings - Fork 175
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
Filter hint markers by element text #803
Conversation
This looks great - I like the improvements! I don't see any obvious bugs after playing around with it for a bit, but I'll keep trying it and let you know if I notice anything. |
One thing that pentadactyl does (that I've never used personally, but which I noticed when I was fiddling with it to compare) is to not match literal spaces, but split the typed characters on whitespace and require that all of the parts match individually. So for instance, if I type "abc def" in hints mode, it will select all elements which contain both "abc" and "def" as substrings (so "defabc" would be selected, but not "abcfed" or "cbadef"). I'm not sure this is worth replicating (it seems a bit weird and potentially confusing), but just thought I'd mention it as a point of comparison. |
Thanks for testing, @doy! I suggest keep testing by using this branch in your main Firefox profile for a week or so. 👍 Thanks for mentioning that Pentadactyl difference regarding how it handles typing a space. That’s really helpful. Since you don’t use it, and since it is more complicated to both explain and to implement, I too think that we should leave it out. I also think that behavior sounds confusing. I just added highlighting of the matched text. What do you think of that? |
@doy Also, what do you set |
I like the idea of highlighting the matching text, but I don't think the current implementation is very readable with the semi-transparent overlays. Could the hint characters be offset a bit, so that they don't always cover up the first handful of characters? Pentadactyl puts them above and to the left of the link they are attached to, which allows you to see both the hint characters and the link text at the same time. The pentadactyl hint characters are also quite a bit smaller by default, which helps with this. As for the hint matching input suppression, Pentadactyl uses a hardcoded value of 500ms. I agree that the VimFX default of 200ms (for |
Great. I'll try to use Firefox with this branch for a few days and share how it performs. There are my first few thoughts: I agree with @doy that the semi-transparent overlays are a bit annoying. In my opinion they should be offset or made a bit more transparent. Right now both letters in overlays and text under them are almost impossible to read. Another option could be to only highlight with a border or something which elements are clickable without displaying hint char overlays. They could only appear when users start to hold shift as that's when they are needed. Although it's possible that this behavior could be too confusing for most of users... There is a bug with transparency of hint overlays. After typing first character they turn transparent and require to stop holding shift and hold it again to make them opaque. The behavior of space which @doy described is something what I had in mind when mentioning them. I thinks it's a very useful feature to be able to break mid-word with space and type next one. This mostly helps when clickable elements start with the same text but you don't notice it at first. Simply pressing space and typing one of following words greatly speeds up getting where intended. Of course it's also possible to use hint chars in that case. I'll have to test it a bit longer to know how often I try to hit space to break words. Default timeout is definitely too short. I type too fast to notice in time when links activate. It already got me few times when I entered ignore mode and got confused why VimFx stopped working. I'm going to find few settings to come up with perfect time for my typing. |
I agree that the semi-transparent thing is a bit too hard to read many times. I’ve pushed a new commit now which tries to put hints to the left of text instead. Also, instead of flipping the shift-to-peek-through behavior of holding shift in text mode, I now use ctrl+shift instead. @Tunous Thanks for providing feedback! 👍
Another bad thing about the semi-transparent thing that I came to think about is that everyone won’t need to hold shift to be able to type hint chars. I suspect many will use numbers as hint chars. So I think that it’s best to always show all hint markers, and rely on the new positioning instead.
That depends on how you see it. VimFx has a feature that allows you to hold shift to peek through all hint markers (they get very transparent while shift is held). What I did was simply flipping that behavior when using text mode: The hint markers are quite transparent (but not as much as in non-text mode) by default and become opaque when shift is held. Anyhow, we seem to be leaving this semi-transparent thing anyway, so it doesn’t matter.
Would you mind elaborating on this with a real example? Many people like to bring up how they navigate on Hackernews.
Please do and report back! |
@doy Thanks for the screenshots! That’s super helpful. I’ve fixed the case of wrapping links now. I’ll add your remaining items to the first post. |
@doy The point of the text mode is to know what to type before seeing the hints, right? That’s not the case for image alt text, so I don’t see how that’s any more useful than simply typing its hint. It just sounds like it might generate lots of really large hint marker that might obscure other things. |
I think I found a prefect timeout which is 400ms. Didn't perform any accidental actions with it. Some issues:
It is mostly useful in websites like google where there are many results with common words. It's often natural to start typing the word which I used when performing search instead of trying to find unique one. Let's say that my intention is to enter 3rd result from here. In this example I started typing pull as that's what first came to my mind. But I quickly start noticing that it doesn't get me far enough. I would have to first type Alternatively if I started typing overwrite I would have to type that whole word and then the one after it. If I could press space and immediately start typing the following word I wouldn't have to type it all. Instead of Although, so far I counted only about 3 times where I wanted to break word earlier and I worked around it by using hint chars. Probably it's not really worth trying to implement it considering this alternative ^^ Bonus observation: Making typing of special characters like |
@Tunous Thanks you very much for your detailed feedback! Much appreciated!
Fixed.
Does this only happen on this branch? If not, please open a separate issue.
I'm totally convinced now. I've implemented something along the lines you describe. Please test and see how it works for you!
I guess that makes sense, and that it should quite easy to do. The hard thing is to decide the set of characters. Another idea would be to make I guess this one needs a bit of thinking before rushing off to implementation. :) Regarding the TODO list:
I've pushed an experiment that I'm really excited about:
Many sites (especially forums) have really small pagination numbers. There, it is very difficult to see which hint goes where. Therefore I think it makes sense to have text mode always one. Being able to type for example "5" when I want click the pagination link for page 5 is so useful. What do you think about this? Does it make sense? Finally, when I was browsing through Pentadactyl's source code, I noticed that it has quite a few hints-related options that might be relevant: options.add(["followhints", "fh"],
"Define the conditions under which selected hints are followed",
"number", 0,
{
values: {
"0": "Follow the first hint as soon as typed text uniquely identifies it. Follow the selected hint on <Return>.",
"1": "Follow the selected hint on <Return>."
}
});
options.add(["hintmatching", "hm"],
"How hints are filtered",
"stringlist", "contains",
{
values: {
"contains": "The typed characters are split on whitespace. The resulting groups must all appear in the hint.",
"custom": "Delegate to a custom function: dactyl.plugins.customHintMatcher(hintString)",
"firstletters": "Behaves like wordstartswith, but all groups must match a sequence of words.",
"wordstartswith": "The typed characters are split on whitespace. The resulting groups must all match the beginnings of words, in order.",
"transliterated": UTF8("When true, special latin characters are translated to their ASCII equivalents (e.g., é ⇒ e)")
},
validator: function (values) {
return Option.validateCompleter.call(this, values) &&
1 === values.reduce((acc, v) => acc + (["contains", "custom", "firstletters", "wordstartswith"].indexOf(v) >= 0),
0);
}
});
options.add(["wordseparators", "wsp"],
"Regular expression defining which characters separate words when matching hints",
"string", '[.,!?:;/"^$%&?()[\\]{}<>#*+|=~ _-]',
{ validator: function (value) { return RegExp(value); } });
Thoughts? |
Never mind my question there. It's fixed on master as of commit 0d630e9. Nice catch! |
2f1eaa4
to
6511945
Compare
Something else that I just realized is that another point in favor of the new space behavior is that it's also the behavior that the awesomebar uses for choosing autocomplete options. |
I'm not super familiar with the pentadactyl source, but I believe that https://github.com/5digits/dactyl/blob/master/common/content/hints.js#L496 is where the hint completion timeout is set, and then used here https://github.com/5digits/dactyl/blob/master/common/content/hints.js#L536-L542. |
I did some testing, and it seems like Pentadactyl treats characters like |
My guess is that |
To extend on using Thanks for working on this feature ! |
Except that the awesomebar allows matching the words in any order, while my algorithm does not (the words must follow each other). Not sure what’s best here.
Thanks!
Thanks for letting us know.
While moving the markers out of the way from text was kind of essential to be able to use the text matching feature, that’s not really related to this issue.
My thinking was that the timeout doesn’t make sense in that case, so a special value of it could mean something else. Also, I was thinking of not making
I think a really good example (like the one(s) by @Tunous above) is needed for this to happen. I’m not convinced that this is a good feature.
Thanks! Good defaults are important. |
@Tunous Thanks, that makes sense! Again, thank you so much for helping with testing and providing such clear feedback! 👍 |
The hint markers are styled with `font: menu;` to get as close to the user's system and preferences as possible. However, that turns out to be slighly too big on all systems I've seen. This commit still uses `font: menu;`, but then reduces the font size of that to 80%, by using a clever CSS trick: `font: menu;` was moved to the hints container, and the markers themselves use `font-size: 0.8em;`.
This brings several more or less breaking changes: - Non-hint chars now filter hint markers by the text of their elements, using an algorithm similar to the location bar (split the search term on whitespace; all the items must occur in the search text, case insensitively, and may overlap). The matched text is highlighted on screen. If all remaining hints are the same, they are automatically activated. All of this can be turned off via prefs, though. - Since space is used to filter hint markers by element text, the already existing `<space>` shortcut for rotating hint markers had to be changed. It is now `<c-space>`. (`<s-space>` remains unchanged.) - Uppercase hint chars are now allowed. This is so that people who prefer filtering by text in the first hand can use uppercase hint chars. If mixed case is used, `text-transform: uppercase;` is not applied, to avoid confusion. - Since using uppercase characters for filtering hint markers by element text and lowercase characters for hint chars (or vice versa) is now a thing, holding shift no longer lets you peek through the hint markers, because that felt like the markers blinking all the time. Instead, you now have to hold shift+control to peek through. - Hint markers are now placed immediately to left of its element's text if it would cover the text otherwise. This is because when filtering hints by text, it can be quite difficult to see what to type otherwise. This also turned out to be helpful even when only using the hints (like before). It’s nice being able to see all the link text in many cases. - Hint markers now get their `z-index` assigned based on their element's area, not their weight. It's confusing when a smaller element's hint cover the hint of a larger element. This could be the case where there are lots of small profile image links all with the same `href`. Previously, all those links got `z-index` based on their combined area. Now, their individual areas are used instead. This problem became apparent because of the above bullet point. - The hint marker(s) with the best hint are now highlighted in blue. - `<enter>` now activates the highlighted marker(s). `<c-enter>` and `<a-enter>` can be used to toggle where links open, just as when using those modifiers with the last hint char. However, these shortcuts were already taken, so the old ones had to be given new shortcuts: - "Increase count" now uses `<up>` (instead of `<enter>`). - "Toggle complementary" now uses `<c-backspace>` (instead of `<c-enter>`). - All existing hints prefs were renamed from starting with `hint_` or `hints_` to starting with `hints.`, for consistency and organization. A few new prefs starting with `hints.` were added as well. Migrations are written for this. This also unveiled a problem. If a config file tries to set an old pref and VimFx is upgraded, the config file will throw errors. This is bad user experience, so a system for allowing old names was added. However, that might mean that users never notice that they use an outdated name and never update their config files. Therefore, old names are only allowed when the config file is loaded automatically (on startup), but _not_ when it is reloaded using `gC`. The idea is that people use `gC` while working on their config file, which usually involves fixing errors. Then they could just as well fix the old pref names as well. - The options in VimFx's settings page in the Add-ons Manager have been slightly re-ordered to play better with the new options added, and to promote some very important prefs to the top. All of the above required some significant refactoring of Hints mode, that should make it more robust. Fixes #340. A big thanks to @doy who got this all started with #789.
- [email protected] simply has a smaller download size. - [email protected] creates better hints for links with the same area. Instead of giving the _last_ of those the best hint, the _first_ one gets it.
I now want to merge this into develop rather than to master, so I have to close this PR. Don’t worry it doesn’t mean that the feature got scrapped! You’ll find it in the develop branch from now on. Feel free to keep commenting here if you’ve got any feedback. |
@lydell: any thoughts on using a different color than blue? (#803 (comment)) |
@doy Sorry, I didn't see your comment! Thanks for pinging me about it. This is the current status on the styling of highlighted markers:
This is another alternative I considered: #VimFxMarkersContainer .marker--highlighted {
filter: hue-rotate(90deg) brightness(90%) !important;
} I would be more than happy for a contribution of better styling! (Or at least a color suggestion or something.) :) |
@doy Here is yet an alternative: filter: none !important;
--color-primary: black !important;
--color-secondary: white !important;
border-color: var(--color-primary) !important;
box-shadow: 0 0 0 1px var(--color-primary), 0 0 0 2px var(--color-secondary) !important;
color: var(--color-primary) !important; |
@Tunous @doy I've pushed several bug fixes and improvements to develop now. A change is that the entire element text is now selected for highlighted markers (when you have typed at least one non-hint char). That should make it more obvious when you can stop typing and press |
@doy Could you please help out and come with a concrete suggestion. This styling problem is driving me crazy here :) |
Of the options given so far, I think #803 (comment) is the best (and I would be happy with that as the implementation). For a concrete suggestion that I think would probably be better, I think it'd be nice to have something more along the lines of what Pentadactyl does (although with some modifications). Pentadactyl highlights the entire element for all matching elements in yellow, and highlights the entire selected element in green: |
Thanks. We’ll probably go with that, then.
|
@doy The latest iteration: |
Seeing which part of the element triggered the match makes it a lot easier to see what other part of the text isn't matched in case I need to keep typing to get a more specific match. It's not a huge deal though - I'm happy with the latest iteration. |
I agree with this. Didn't notice that the latest iteration had whole text highlighted. For me the hint colored in green is good enough. |
So, what happened to me was that the hint marker was too far away from the part of a link I was trying to match, so I didn’t notice it becoming green. That’s why I came up with the idea of highlighting the entire element (as a complement). Are you saying that when your initial guess on which part of a link to type didn’t work out, you start looking at other links to figure out what to continue typing, and are then bothered by one (or a few) of them being fully highlighted? Also, which is more true to you:
|
Option 1. It just makes it slightly easier to see what to type in some cases. But I'm sure highlighting the entire element will come more useful than that. |
Original PR description below (which is a bit out-of-date now):
Here is my attempt at fixing #340, heavily inspired by @doy’s #789. A few differences compared to that PR:
eb
command.eb
out of habit.ignore_keyboard_layout
option when typing chars to match against element text.<delete>
as typing the characters<delete>
.hints_timeout
milliseconds if a hint was activated by matching its text.<space>
shortcut).@doy, @progandy, @Tunous, @e12e, @erjoalgo, @frangio please test this PR if you can!
TODO:
hints_text_mode
pref should be in VimFx’s settings page in the Add-ons Manager or not.