vimperator / vimperator-labs

Vimperator
http://vimperator.org
Other
1.19k stars 196 forks source link

hintchar needs press enter #214

Open frankyuan opened 9 years ago

frankyuan commented 9 years ago

I want to use hint on one hand, so set the hintchars as bellow: set hintchars=qwertasdfgzxcvb but sometimes, the link's hint char will be one charactor (such as A), but has another link's chars like (AS), so I have to press A and press enter. Can I set min length of hintchars to 2 or another way to avoid this? Thanks.

maxauthority commented 9 years ago

No but that probably would be a good improvement to make hints at least Math.ceil(length(hints) / length(hintchars)) long.

pewpewpewter commented 9 years ago

This is the default behaviour in Luakit, and I quite prefer it to the current implementation in Vimperator. @frankyuan and I might be in the minority, though, so it might be best to have an option for it (called hintpadding, perhaps), with the default being the current model.

WovenTales commented 8 years ago

Coming really late to this, but I'd suggest that -- rather than padding the hints -- it would be better to add an option to require that the user press Enter after entering every one, even if their input only matches a single link. (I use qutebrowser on Linux, and just found Vimperator for my Windows dual-boot, but have definitely gotten used to the page not changing automatically.) That way, the generation algorithm doesn't need any tweaking but we still get consistent behaviour.

quite commented 8 years ago

@WovenTales The behaviour of requiring Enter to at all follow any hinted link currently exists, if followhints is set to 1. But, that concept seems to me unrelated to this issue. The idea here is to allow one-handed link navigation using the hints (and without moving that hand too much; not having to press Enter). As the number of hints on screen often exceed 9, it would make sense to (optionally) ban hints shorted than 2 hintchars, as those would often collide with longer hints and then again require that press on Enter.

quite commented 8 years ago

@maxauthority So if there are 30 hints to be displayed on screen (if that's what length(hints) signifies), and I have say 9 hintchars, then the hints should be minimum 3 chars long? Nah, not workable. I'd go for @pewpewpewter

gkatsev commented 8 years ago

@quite but wouldn't that have the same problem that now you would have ambiguous hints?

quite commented 8 years ago

@gkatsev No? What do you mean by ambiguous? Any two links will never be given the same hint.

gkatsev commented 8 years ago

whoops, sorry, I was doing my math wrong. Maybe the equation length(hintchars) choose x > length(hints on page)? So, for 9 hintchars, we have a hinting power for 81 and so we use two hint chars whenever we have less than 81 choices. Then if we are more than 81 but less than 729, we use 3 chars.

WovenTales commented 8 years ago

@quite Well, that's simple. Thanks! And I didn't catch that the driver behind this was wanting to do it single-handedly, but I do agree that that would be nice.

@gkatsev Unless I am thinking of something else, isn't x choose y "the number of potential combinations disregarding order"? For hints, af is going to be different than fa so we can use the simpler length(charset) ^ hintlength >= hintsonpage. Since that's not the best formula for code (we'd need to iterate over the length of the hint until we get a satisfactory value), it would be faster to rework that to hintlength >= log(hintsonpage) / log(length(charset)), and since we don't actually care about anything but the smallest possible length, we can just ceil the right side to get how many characters we need to use. At least, assuming my math is correct, which, since it's just what @maxauthority said plus the logs, seems suggest it is.

Of course, that does still require that we know how many hints we need to display before calculating, and while I briefly scanned through the code, I couldn't tell whether the current implementation allows for that or whether it simply figures out how many characters to give each on the fly.

zarelit commented 8 years ago

What about using a prefix-free code for code assignment? e.g. you have hintchars=asdf, when you have less than 4 hints they are labelled a,s,d,f. When you have more than 4, say 6, they are labelled so that there is no need for disambiguation with the enter key: a,s,d,fa,fs (for example).

This would mean no need for padding and no need for enter key

WovenTales commented 8 years ago

@zarelit That's how qutebrowser does it (which I use when I'm on Linux) and it does definitely work well. I'm just not sure how easy it would be to implement, and it may wind up with longer hints if that's a consideration here -- I don't see anything longer than three characters in qutebrowser, but it feels almost like vimperator winds up highlighting more links than I'm used to seeing on pages in that.